MCommandManager.h
00001 #ifndef MCOMMANDMANAGER_H 00002 #define MCOMMANDMANAGER_H 00003 00004 #include "MCommand.h" 00005 #include "MCommandParameter.h" 00006 #include <map> 00007 #include <string> 00008 using namespace std; 00009 00010 //typedef vector<MCommandDesc*> MCommandDescVector; ///< Command Description Vector(ID및 인덱스로 검색을 자주 하므로, 정렬된 벡터를 이용한다.) 00011 typedef map<int, MCommandDesc*> MCommandDescMap; 00012 typedef list<MCommand*> MCommandList; 00013 typedef map<string, string> MCommandAliasMap; 00014 00015 00019 class MCommandManager{ 00020 protected: 00021 //MCommandDescVector m_CommandDescs; ///< Command Description List 00022 MCommandDescMap m_CommandDescs; 00023 MCommandList m_CommandQueue; 00024 MCommandAliasMap m_CommandAlias; 00025 protected: 00026 void InitializeCommandDesc(void); 00027 00028 public: 00029 MCommandManager(void); 00030 virtual ~MCommandManager(void); 00031 00032 void Initialize(void); 00033 00034 int GetCommandDescCount(void) const; 00035 int GetCommandQueueCount(void) const; 00036 MCommandDesc* GetCommandDesc(int i); 00037 MCommandDesc* GetCommandDescByID(int nID); 00038 void AssignDescs(MCommandManager* pTarCM); 00039 00041 void AddCommandDesc(MCommandDesc* pCD); 00042 00044 bool Post(MCommand* pNew); 00045 00047 MCommand* GetCommand(void); 00049 MCommand* PeekCommand(void); 00050 00052 void GetSyntax(char* szSyntax, const MCommandDesc* pCD); 00058 bool ParseMessage(MCommand* pCmd, char* szErrMsg, int nErrMsgMaxLength, const char* szMsg); 00059 00063 void AddAlias(string szName, string szText); 00064 }; 00065 00066 // Post Command Macro For Convenience 00067 #define POSTCMD0(_ID) { MCommand* pC=NEWCMD(_ID); ASPostCommand(pC); } 00068 #define POSTCMD1(_ID, _P0) { MCommand* pC=NEWCMD(_ID); pC->AP(_P0); ASPostCommand(pC); } 00069 #define POSTCMD2(_ID, _P0, _P1) { MCommand* pC=NEWCMD(_ID); pC->AP(_P0); pC->AP(_P1); ASPostCommand(pC); } 00070 #define POSTCMD3(_ID, _P0, _P1, _P2) { MCommand* pC=NEWCMD(_ID); pC->AP(_P0); pC->AP(_P1); pC->AP(_P2); ASPostCommand(pC); } 00071 #define POSTCMD4(_ID, _P0, _P1, _P2, _P3) { MCommand* pC=NEWCMD(_ID); pC->AP(_P0); pC->AP(_P1); pC->AP(_P2); pC->AP(_P3); ASPostCommand(pC); } 00072 #define POSTCMD5(_ID, _P0, _P1, _P2, _P3, _P4) { MCommand* pC=NEWCMD(_ID); pC->AP(_P0); pC->AP(_P1); pC->AP(_P2); pC->AP(_P3); pC->AP(_P4); ASPostCommand(pC); } 00073 #define POSTCMD6(_ID, _P0, _P1, _P2, _P3, _P4, _P5) { MCommand* pC=NEWCMD(_ID); pC->AP(_P0); pC->AP(_P1); pC->AP(_P2); pC->AP(_P3); pC->AP(_P4); pC->AP(_P5); ASPostCommand(pC); } 00074 00075 #define ENPOSTCMD0(_ID) { MCommand* pC=NEWCMD(_ID); ASEnPostCommand(pC); } 00076 #define ENPOSTCMD1(_ID, _P0) { MCommand* pC=NEWCMD(_ID); pC->AP(_P0); ASEnPostCommand(pC); } 00077 #define ENPOSTCMD2(_ID, _P0, _P1) { MCommand* pC=NEWCMD(_ID); pC->AP(_P0); pC->AP(_P1); ASEnPostCommand(pC); } 00078 #define ENPOSTCMD3(_ID, _P0, _P1, _P2) { MCommand* pC=NEWCMD(_ID); pC->AP(_P0); pC->AP(_P1); pC->AP(_P2); ASEnPostCommand(pC); } 00079 #define ENPOSTCMD4(_ID, _P0, _P1, _P2, _P3) { MCommand* pC=NEWCMD(_ID); pC->AP(_P0); pC->AP(_P1); pC->AP(_P2); pC->AP(_P3); ASPostCommand(pC); } 00080 #define ENPOSTCMD5(_ID, _P0, _P1, _P2, _P3, _P4) { MCommand* pC=NEWCMD(_ID); pC->AP(_P0); pC->AP(_P1); pC->AP(_P2); pC->AP(_P3); pC->AP(_P4); ASEnPostCommand(pC); } 00081 #define ENPOSTCMD6(_ID, _P0, _P1, _P2, _P3, _P4, _P5) { MCommand* pC=NEWCMD(_ID); pC->AP(_P0); pC->AP(_P1); pC->AP(_P2); pC->AP(_P3); pC->AP(_P4); pC->AP(_P5); ASEnPostCommand(pC); } 00082 00083 // Command Description Add Macro For Convenience 00084 #define BEGIN_CMD_DESC(_pCommandManager) { MCommandDesc* pCD4m; MCommandManager* pCM4m = _pCommandManager; 00085 #define END_CMD_DESC() } 00086 #define C(_a, _b, _c, _d) { pCD4m = new MCommandDesc(_a, _b, _c, _d); pCM4m->AddCommandDesc(pCD4m); } 00087 #define P(_a, _b) { pCD4m->AddParamDesc(new MCommandParameterDesc(_a, _b)); } 00088 #define CA(_a, _b) { pCM4m->AddAlias(_a, _b); } 00089 00090 #endif
MAIET entertainment