summaryrefslogtreecommitdiffstats
path: root/src/Client/CommandParser.h
diff options
context:
space:
mode:
authorMatthias Schiffer <matthias@gamezock.de>2009-06-18 22:03:02 +0200
committerMatthias Schiffer <matthias@gamezock.de>2009-06-18 22:03:02 +0200
commit7234fe326d16d6bf9f4374a09ddc6ef790e6723f (patch)
tree437d4c40eeb1e9b34b369e4b82064a1572c7dac9 /src/Client/CommandParser.h
parentbf561f8226e97f4ace4f04bddf198175e91ee7f0 (diff)
downloadmad-7234fe326d16d6bf9f4374a09ddc6ef790e6723f.tar
mad-7234fe326d16d6bf9f4374a09ddc6ef790e6723f.zip
Globale Variablen durch Application-Klasse ersetzt
Diffstat (limited to 'src/Client/CommandParser.h')
-rw-r--r--src/Client/CommandParser.h27
1 files changed, 10 insertions, 17 deletions
diff --git a/src/Client/CommandParser.h b/src/Client/CommandParser.h
index a7157ed..64dab1f 100644
--- a/src/Client/CommandParser.h
+++ b/src/Client/CommandParser.h
@@ -38,6 +38,7 @@ class Connection;
namespace Client {
+class Application;
class SystemCommands;
class UserCommands;
@@ -52,12 +53,12 @@ class CommandParser {
const char* desc;
const char* longdesc;
- boost::function2<void, const std::vector<std::string>, Common::Connection*> function;
+ boost::function2<void, CommandParser*, const std::vector<std::string> > function;
};
static const Command commands[];
- static CommandParser commandParser;
+ Application *application;
Common::Connection *connection;
@@ -65,32 +66,24 @@ class CommandParser {
static const Command* findCommand(const std::string& command);
- static void printUsage(const std::string& command);
- static std::map<std::string, Common::HostInfo> parseHostList(const std::vector<std::string> &args, bool mustBeActive = false);
+ void printUsage(const std::string& command);
+ std::map<std::string, Common::HostInfo> parseHostList(const std::vector<std::string> &args, bool mustBeActive = false);
- static void helpCommand(const std::vector<std::string> &args, Common::Connection *connection);
- static void listHostsCommand(const std::vector<std::string> &args, Common::Connection *connection);
- static void exitCommand(const std::vector<std::string> &args, Common::Connection *connection);
-
- CommandParser() : connection(0), disconnect(false) {}
+ void helpCommand(const std::vector<std::string> &args);
+ void listHostsCommand(const std::vector<std::string> &args);
+ void exitCommand(const std::vector<std::string> &args);
public:
- static CommandParser *get() {
- return &commandParser;
- }
+ CommandParser(Application *application0, Common::Connection *connection0);
Common::Connection *getConnection() const {
return connection;
}
- void setConnection(Common::Connection *con) {
- connection = con;
- }
-
bool parse(const std::string &cmd);
void requestDisconnect() {
- exitCommand(std::vector<std::string>(), connection);
+ exitCommand(std::vector<std::string>());
}
bool willDisconnect() const {