summaryrefslogtreecommitdiffstats
path: root/src/Client/CommandParser.cpp
diff options
context:
space:
mode:
authorMatthias Schiffer <matthias@gamezock.de>2009-03-16 19:13:42 +0100
committerMatthias Schiffer <matthias@gamezock.de>2009-03-16 19:13:42 +0100
commit8f098fc3070f791302ec1f497588fab6ed409980 (patch)
tree6cff9f7bb973342344a22636a5d9ef26c7a0d940 /src/Client/CommandParser.cpp
parentaef0f2e7a5085b8da3aa2e97565215d182d3dd2d (diff)
downloadmad-8f098fc3070f791302ec1f497588fab6ed409980.tar
mad-8f098fc3070f791302ec1f497588fab6ed409980.zip
Request- und RequestHandler-Interfaces vereinfacht
Diffstat (limited to 'src/Client/CommandParser.cpp')
-rw-r--r--src/Client/CommandParser.cpp28
1 files changed, 16 insertions, 12 deletions
diff --git a/src/Client/CommandParser.cpp b/src/Client/CommandParser.cpp
index 27aac78..7e3a90e 100644
--- a/src/Client/CommandParser.cpp
+++ b/src/Client/CommandParser.cpp
@@ -110,9 +110,9 @@ std::map<std::string, Common::HostInfo> CommandParser::parseHostList(const std::
void CommandParser::fsinfoCommand(const std::vector<std::string> &args) {
if(args.size() == 1)
- Common::RequestManager::get()->sendRequest(connection, std::auto_ptr<Common::Request>(new Common::Requests::FSInfoRequest(sigc::mem_fun(CommandManager::get(), &CommandManager::fsInfoRequestFinished))));
+ Common::RequestManager::get()->sendRequest<Common::Requests::FSInfoRequest>(connection, sigc::mem_fun(CommandManager::get(), &CommandManager::fsInfoRequestFinished));
else if(args.size() == 2)
- Common::RequestManager::get()->sendRequest(connection, std::auto_ptr<Common::Request>(new Requests::DaemonFSInfoRequest(args[1], sigc::mem_fun(CommandManager::get(), &CommandManager::daemonFSInfoRequestFinished))));
+ Common::RequestManager::get()->sendRequest<Requests::DaemonFSInfoRequest>(connection, sigc::mem_fun(CommandManager::get(), &CommandManager::daemonFSInfoRequestFinished), args[1]);
else {
Common::Logger::logf(Common::Logger::ERROR, "%s: Too many arguments.", args[0].c_str());
printUsage("fsinfo");
@@ -213,9 +213,9 @@ void CommandParser::rebootCommand(const std::vector<std::string> &args) {
std::map<std::string, Common::HostInfo> hosts = parseHostList(std::vector<std::string>(args.begin()+1, args.end()), true);
for(std::map<std::string, Common::HostInfo>::iterator host = hosts.begin(); host != hosts.end(); ++host) {
- Common::RequestManager::get()->sendRequest(connection, std::auto_ptr<Common::Request>(
- new Requests::DaemonCommandRequest(host->first, true, sigc::mem_fun(CommandManager::get(), &CommandManager::daemonCommandRequestFinished))
- ));
+ Common::RequestManager::get()->sendRequest<Requests::DaemonCommandRequest>(connection,
+ sigc::mem_fun(CommandManager::get(), &CommandManager::daemonCommandRequestFinished), host->first, true
+ );
++CommandManager::get()->activeRequests;
}
@@ -231,9 +231,9 @@ void CommandParser::shutdownCommand(const std::vector<std::string> &args) {
std::map<std::string, Common::HostInfo> hosts = parseHostList(std::vector<std::string>(args.begin()+1, args.end()), true);
for(std::map<std::string, Common::HostInfo>::iterator host = hosts.begin(); host != hosts.end(); ++host) {
- Common::RequestManager::get()->sendRequest(connection, std::auto_ptr<Common::Request>(
- new Requests::DaemonCommandRequest(host->first, false, sigc::mem_fun(CommandManager::get(), &CommandManager::daemonCommandRequestFinished))
- ));
+ Common::RequestManager::get()->sendRequest<Requests::DaemonCommandRequest>(connection,
+ sigc::mem_fun(CommandManager::get(), &CommandManager::daemonCommandRequestFinished), host->first, false
+ );
++CommandManager::get()->activeRequests;
}
@@ -241,9 +241,11 @@ void CommandParser::shutdownCommand(const std::vector<std::string> &args) {
void CommandParser::statusCommand(const std::vector<std::string> &args) {
if(args.size() == 1)
- Common::RequestManager::get()->sendRequest(connection, std::auto_ptr<Common::Request>(new Common::Requests::StatusRequest(sigc::mem_fun(CommandManager::get(), &CommandManager::statusRequestFinished))));
+ Common::RequestManager::get()->sendRequest<Common::Requests::StatusRequest>(connection,
+ sigc::mem_fun(CommandManager::get(), &CommandManager::statusRequestFinished));
else if(args.size() == 2)
- Common::RequestManager::get()->sendRequest(connection, std::auto_ptr<Common::Request>(new Requests::DaemonStatusRequest(args[1], sigc::mem_fun(CommandManager::get(), &CommandManager::daemonStatusRequestFinished))));
+ Common::RequestManager::get()->sendRequest<Requests::DaemonStatusRequest>(connection,
+ sigc::mem_fun(CommandManager::get(), &CommandManager::daemonStatusRequestFinished), args[1]);
else {
Common::Logger::logf(Common::Logger::ERROR, "%s: Too many arguments.", args[0].c_str());
printUsage("status");
@@ -256,13 +258,15 @@ void CommandParser::statusCommand(const std::vector<std::string> &args) {
void CommandParser::listUsersCommand(const std::vector<std::string>&) {
++CommandManager::get()->activeRequests;
- Common::RequestManager::get()->sendRequest(connection, std::auto_ptr<Common::Request>(new Common::Requests::UserListRequest(sigc::mem_fun(CommandManager::get(), &CommandManager::userListRequestFinished))));
+ Common::RequestManager::get()->sendRequest<Common::Requests::UserListRequest>(connection,
+ sigc::mem_fun(CommandManager::get(), &CommandManager::userListRequestFinished));
}
void CommandParser::exitCommand(const std::vector<std::string>&) {
++CommandManager::get()->activeRequests;
- Common::RequestManager::get()->sendRequest(connection, std::auto_ptr<Common::Request>(new Common::Requests::DisconnectRequest(sigc::mem_fun(CommandManager::get(), &CommandManager::disconnectRequestFinished))));
+ Common::RequestManager::get()->sendRequest<Common::Requests::DisconnectRequest>(connection,
+ sigc::mem_fun(CommandManager::get(), &CommandManager::disconnectRequestFinished));
}
bool CommandParser::parse(const std::string &cmd) {