-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCommandList.cpp
More file actions
45 lines (38 loc) · 1.28 KB
/
Copy pathCommandList.cpp
File metadata and controls
45 lines (38 loc) · 1.28 KB
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
#include "CommandFunctor.h"
#include "CommandList.h"
#include "EmployeesCommand.h"
#include "HireCommand.h"
#include "InterviewCommand.h"
#include "MasterState.h"
#include "PeopleCommand.h"
#include "ProjectCommand.h"
#include "QuitCommand.h"
#include "StatusCommand.h"
#include "WaitCommand.h"
#include <string.h>
CommandList::CommandList(MasterState *ms) {
this->_commands = new vector<CommandFunctor *>();
this->_commands->push_back(new EmployeesCommand(ms));
this->_commands->push_back(new HireCommand(ms));
this->_commands->push_back(new InterviewCommand(ms));
this->_commands->push_back(new PeopleCommand(ms));
this->_commands->push_back(new ProjectCommand(ms));
this->_commands->push_back(new StatusCommand(ms));
this->_commands->push_back(new WaitCommand(ms));
this->_commands->push_back(new QuitCommand(ms));
}
void CommandList::executeCommand(const char *command) {
if (command[0] != '\0') {
int found = 0;
for (vector<CommandFunctor *>::iterator it = this->_commands->begin(); it != this->_commands->end(); ++it) {
CommandFunctor *commandFunctor = *it;
string prefix = commandFunctor->getPrefix();
if (strncmp(prefix.c_str(), command, strlen(prefix.c_str())) == 0) {
commandFunctor->executeCommand(command);
return;
}
}
}
}
CommandList::~CommandList() {
}