-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathCmdList.h
45 lines (34 loc) · 889 Bytes
/
CmdList.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#pragma once
#include <string>
#include <vector>
#include <map>
#include <Windows.h>
#include "CmdInterface.h"
using namespace std;
BOOL WINAPI CmdListMain(
HANDLE Instance, ULONG Reason, PVOID Reserved);
#define CMD_LIST CCmdList::Instance()
class CCmdList
{
public:
static CCmdList* Instance()
{
static CCmdList s_cmd_list;
return &s_cmd_list;
}
void RegisterCmdHandler(string cmd_name, CmdHandler cmd_handler)
{
m_cmd_hanlders[cmd_name] = cmd_handler;
}
bool IsValidCmd(string cmd_name)
{
return m_cmd_hanlders.find(cmd_name) != m_cmd_hanlders.end();
}
void HandleCmd(string cmd_name, vector<string>& args)
{
m_cmd_hanlders[cmd_name](args);
}
vector<string> GetValidCommands();
private:
map<string, CmdHandler> m_cmd_hanlders;
};