summaryrefslogtreecommitdiffstats
path: root/src/Client
diff options
context:
space:
mode:
authorMatthias Schiffer <matthias@gamezock.de>2008-11-19 16:15:17 +0100
committerMatthias Schiffer <matthias@gamezock.de>2008-11-19 16:15:17 +0100
commit854421e2c144ab6454d67beb6640579ad13f1a1f (patch)
tree9856477c9a685be6355b9ef4f0c9485befac3192 /src/Client
parenta3b3e7d83cab57673ba3daf5d71244598cf73f0c (diff)
downloadmad-854421e2c144ab6454d67beb6640579ad13f1a1f.tar
mad-854421e2c144ab6454d67beb6640579ad13f1a1f.zip
Kurze statische get()-Methoden
Diffstat (limited to 'src/Client')
-rw-r--r--src/Client/CommandManager.h2
-rw-r--r--src/Client/CommandParser.cpp32
-rw-r--r--src/Client/CommandParser.h7
-rw-r--r--src/Client/InformationManager.cpp8
-rw-r--r--src/Client/InformationManager.h2
5 files changed, 23 insertions, 28 deletions
diff --git a/src/Client/CommandManager.h b/src/Client/CommandManager.h
index 25b3f2e..ef20e8a 100644
--- a/src/Client/CommandManager.h
+++ b/src/Client/CommandManager.h
@@ -65,7 +65,7 @@ class CommandManager {
CommandManager() : activeRequests(0), disconnect(false) {}
public:
- static CommandManager *getCommandManager() {
+ static CommandManager *get() {
return &commandManager;
}
diff --git a/src/Client/CommandParser.cpp b/src/Client/CommandParser.cpp
index c0c8d7f..efc9c4b 100644
--- a/src/Client/CommandParser.cpp
+++ b/src/Client/CommandParser.cpp
@@ -74,7 +74,7 @@ void CommandParser::printUsage(const std::string& command) {
std::map<std::string, Common::HostInfo> CommandParser::parseHostList(const std::vector<std::string> &args, bool mustBeActive) {
- const std::map<std::string, Common::HostInfo>& hosts = InformationManager::getInformationManager()->getDaemons();
+ const std::map<std::string, Common::HostInfo>& hosts = InformationManager::get()->getDaemons();
std::map<std::string, Common::HostInfo> ret;
for(std::vector<std::string>::const_iterator arg = args.begin(); arg != args.end(); ++arg) {
@@ -110,16 +110,16 @@ 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::getRequestManager()->sendRequest(connection, std::auto_ptr<Common::RequestBase>(new Common::Requests::FSInfoRequest(sigc::mem_fun(CommandManager::getCommandManager(), &CommandManager::fsInfoRequestFinished))));
+ Common::RequestManager::get()->sendRequest(connection, std::auto_ptr<Common::RequestBase>(new Common::Requests::FSInfoRequest(sigc::mem_fun(CommandManager::get(), &CommandManager::fsInfoRequestFinished))));
else if(args.size() == 2)
- Common::RequestManager::getRequestManager()->sendRequest(connection, std::auto_ptr<Common::RequestBase>(new Requests::DaemonFSInfoRequest(args[1], sigc::mem_fun(CommandManager::getCommandManager(), &CommandManager::daemonFSInfoRequestFinished))));
+ Common::RequestManager::get()->sendRequest(connection, std::auto_ptr<Common::RequestBase>(new Requests::DaemonFSInfoRequest(args[1], sigc::mem_fun(CommandManager::get(), &CommandManager::daemonFSInfoRequestFinished))));
else {
Common::Logger::logf(Common::Logger::ERROR, "%s: Too many arguments.", args[0].c_str());
printUsage("fsinfo");
return;
}
- ++CommandManager::getCommandManager()->activeRequests;
+ ++CommandManager::get()->activeRequests;
}
void CommandParser::helpCommand(const std::vector<std::string> &args) {
@@ -152,7 +152,7 @@ void CommandParser::helpCommand(const std::vector<std::string> &args) {
}
void CommandParser::listHostsCommand(const std::vector<std::string> &args) {
- const std::map<std::string, Common::HostInfo>& hosts = InformationManager::getInformationManager()->getDaemons();
+ const std::map<std::string, Common::HostInfo>& hosts = InformationManager::get()->getDaemons();
if(args.size() == 1) {
if(hosts.empty()) {
@@ -213,11 +213,11 @@ 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::getRequestManager()->sendRequest(connection, std::auto_ptr<Common::RequestBase>(
- new Requests::DaemonCommandRequest(host->first, true, sigc::mem_fun(CommandManager::getCommandManager(), &CommandManager::daemonCommandRequestFinished))
+ Common::RequestManager::get()->sendRequest(connection, std::auto_ptr<Common::RequestBase>(
+ new Requests::DaemonCommandRequest(host->first, true, sigc::mem_fun(CommandManager::get(), &CommandManager::daemonCommandRequestFinished))
));
- ++CommandManager::getCommandManager()->activeRequests;
+ ++CommandManager::get()->activeRequests;
}
}
@@ -231,32 +231,32 @@ 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::getRequestManager()->sendRequest(connection, std::auto_ptr<Common::RequestBase>(
- new Requests::DaemonCommandRequest(host->first, false, sigc::mem_fun(CommandManager::getCommandManager(), &CommandManager::daemonCommandRequestFinished))
+ Common::RequestManager::get()->sendRequest(connection, std::auto_ptr<Common::RequestBase>(
+ new Requests::DaemonCommandRequest(host->first, false, sigc::mem_fun(CommandManager::get(), &CommandManager::daemonCommandRequestFinished))
));
- ++CommandManager::getCommandManager()->activeRequests;
+ ++CommandManager::get()->activeRequests;
}
}
void CommandParser::statusCommand(const std::vector<std::string> &args) {
if(args.size() == 1)
- Common::RequestManager::getRequestManager()->sendRequest(connection, std::auto_ptr<Common::RequestBase>(new Common::Requests::StatusRequest(sigc::mem_fun(CommandManager::getCommandManager(), &CommandManager::statusRequestFinished))));
+ Common::RequestManager::get()->sendRequest(connection, std::auto_ptr<Common::RequestBase>(new Common::Requests::StatusRequest(sigc::mem_fun(CommandManager::get(), &CommandManager::statusRequestFinished))));
else if(args.size() == 2)
- Common::RequestManager::getRequestManager()->sendRequest(connection, std::auto_ptr<Common::RequestBase>(new Requests::DaemonStatusRequest(args[1], sigc::mem_fun(CommandManager::getCommandManager(), &CommandManager::daemonStatusRequestFinished))));
+ Common::RequestManager::get()->sendRequest(connection, std::auto_ptr<Common::RequestBase>(new Requests::DaemonStatusRequest(args[1], sigc::mem_fun(CommandManager::get(), &CommandManager::daemonStatusRequestFinished))));
else {
Common::Logger::logf(Common::Logger::ERROR, "%s: Too many arguments.", args[0].c_str());
printUsage("status");
return;
}
- ++CommandManager::getCommandManager()->activeRequests;
+ ++CommandManager::get()->activeRequests;
}
void CommandParser::exitCommand(const std::vector<std::string>&) {
- ++CommandManager::getCommandManager()->activeRequests;
+ ++CommandManager::get()->activeRequests;
- Common::RequestManager::getRequestManager()->sendRequest(connection, std::auto_ptr<Common::RequestBase>(new Common::Requests::DisconnectRequest(sigc::mem_fun(CommandManager::getCommandManager(), &CommandManager::disconnectRequestFinished))));
+ Common::RequestManager::get()->sendRequest(connection, std::auto_ptr<Common::RequestBase>(new Common::Requests::DisconnectRequest(sigc::mem_fun(CommandManager::get(), &CommandManager::disconnectRequestFinished))));
}
bool CommandParser::split(const std::string &str, std::vector<std::string> &ret) {
diff --git a/src/Client/CommandParser.h b/src/Client/CommandParser.h
index e08c775..e01449a 100644
--- a/src/Client/CommandParser.h
+++ b/src/Client/CommandParser.h
@@ -71,7 +71,7 @@ class CommandParser {
CommandParser() : connection(0) {}
public:
- static CommandParser *getCommandParser() {
+ static CommandParser *get() {
return &commandParser;
}
@@ -83,11 +83,6 @@ class CommandParser {
connection = con;
}
- bool requestsActive() {return CommandManager::getCommandManager()->requestsActive();}
- bool willDisconnect() {return CommandManager::getCommandManager()->willDisconnect();}
-
- sigc::signal<void> signalFinished() const {return CommandManager::getCommandManager()->signalFinished();}
-
bool parse(const std::string &cmd);
void requestDisconnect() {
diff --git a/src/Client/InformationManager.cpp b/src/Client/InformationManager.cpp
index 1d54498..37835c1 100644
--- a/src/Client/InformationManager.cpp
+++ b/src/Client/InformationManager.cpp
@@ -57,20 +57,20 @@ void InformationManager::DaemonStateUpdateRequest::handlePacket(Net::Connection
void InformationManager::doInit() {
- Common::RequestManager::getRequestManager()->init();
+ Common::RequestManager::get()->init();
- Common::RequestManager::getRequestManager()->registerPacketType<DaemonStateUpdateRequest>(Net::Packet::DAEMON_STATE_UPDATE);
+ Common::RequestManager::get()->registerPacketType<DaemonStateUpdateRequest>(Net::Packet::DAEMON_STATE_UPDATE);
}
void InformationManager::doUninit() {
- Common::RequestManager::getRequestManager()->unregisterPacketType(Net::Packet::DAEMON_STATE_UPDATE);
+ Common::RequestManager::get()->unregisterPacketType(Net::Packet::DAEMON_STATE_UPDATE);
}
void InformationManager::updateDaemonList(Net::Connection *con) {
if(updating)
return;
- Common::RequestManager::getRequestManager()->sendRequest(con,
+ Common::RequestManager::get()->sendRequest(con,
std::auto_ptr<Common::RequestBase>(
new Requests::DaemonListRequest(sigc::mem_fun(this, &InformationManager::daemonListRequestFinished))
)
diff --git a/src/Client/InformationManager.h b/src/Client/InformationManager.h
index 739c359..4acde37 100644
--- a/src/Client/InformationManager.h
+++ b/src/Client/InformationManager.h
@@ -69,7 +69,7 @@ class InformationManager : public Common::Initializable {
virtual void doUninit();
public:
- static InformationManager* getInformationManager() {
+ static InformationManager* get() {
return &informationManager;
}