-
Notifications
You must be signed in to change notification settings - Fork 0
/
THCEvent.cpp
49 lines (41 loc) · 1.18 KB
/
THCEvent.cpp
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
46
47
48
49
#include "THCEvent.h"
#include "THCCommand.h"
#include "THCManager.h"
using namespace ThreadCommand;
THCEvent::THCEvent() {
}
THCEvent::~THCEvent() {
while (list_command.size()) {
THCCommand* _command = list_command.front();
_command->UnRegist();
}
}
THCCommand* THCEvent::FindTagCommand(const std::string _tag) {
std::list<THCCommand*>::iterator _iterator;
for(_iterator = list_command.begin(); _iterator != list_command.end(); _iterator++) {
THCCommand* _command = *_iterator;
if(_command->GetTag() == _tag) {
return _command;
}
}
return NULL;
}
void THCEvent::Run(std::string _category, std::string _tag, THCCommand* _command) {
_command->Regist(_category, _tag, this);
list_command.push_back(_command);
THCManager::Share()->AddCommand(_category, _command);
}
bool THCEvent::Stop(std::string _category, std::string _tag) {
std::list<THCCommand*>::iterator _it = list_command.begin();
while (_it != list_command.end()) {
THCCommand* _command = *_it;
_it++;
if(_command->GetCategory() == _category && _command->GetTag() == _tag) {
_command->UnRegist();
}
}
return true;
}
void THCEvent::RemoveCommandList(THCCommand* _command) {
list_command.remove(_command);
}