EvEmu  0.8.4
11 September 2021
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
CommandDispatcher.h
Go to the documentation of this file.
1 #ifndef __COMMANDDISPATCHER_H_INCL__
2 #define __COMMANDDISPATCHER_H_INCL__
3 
4 #include "admin/CommandDB.h"
5 
6 
7 class Client;
8 class Seperator;
9 class PyResult;
10 class PyServiceMgr;
11 
13 public:
14  //this is the prototype for a command function:
15  typedef PyResult (*CommandFunc)(Client *who, CommandDB *db, PyServiceMgr *services, const Seperator &args);
16 
17  class CommandRecord {
18  public:
19  CommandRecord( const char * cmd, const char * desc, int64 req_role, CommandFunc& callback )
20  : command(cmd), description(desc), required_role(req_role), function(callback) {}
21 
22  std::string command;
23  std::string description;
25  CommandFunc function;
26  };
27 
29  virtual ~CommandDispatcher();
30 
31  void Close();
32 
33  PyResult Execute(Client *from, const char *msg);
34 
35  void AddCommand(const char *cmd, const char *desc, int64 required_role, CommandFunc function);
36  void ListCommands();
37 
38 protected:
41 
42  std::map<std::string, CommandRecord *> m_commands; //we own these pointers
43 };
44 
45 #endif
CommandDispatcher(PyServiceMgr &services)
PyResult Execute(Client *from, const char *msg)
Separates string to arguments.
Definition: Seperator.h:36
* args
void AddCommand(const char *cmd, const char *desc, int64 required_role, CommandFunc function)
std::map< std::string, CommandRecord * > m_commands
PyResult(* CommandFunc)(Client *who, CommandDB *db, PyServiceMgr *services, const Seperator &args)
PyServiceMgr & m_services
Definition: Client.h:66
signed __int64 int64
Definition: eve-compat.h:51
CommandRecord(const char *cmd, const char *desc, int64 req_role, CommandFunc &callback)