diff options
Diffstat (limited to 'src/Client/CommandParser.h')
-rw-r--r-- | src/Client/CommandParser.h | 27 |
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 { |