-
Notifications
You must be signed in to change notification settings - Fork 0
/
Engine.h
26 lines (22 loc) · 894 Bytes
/
Engine.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
#pragma once
#include "Wrapper.h"
class Engine{
public:
Engine() = default;
Engine(Engine const& engine) = delete;
Engine& operator=(Engine const& engine) = delete;
Engine(Engine&& Engine) = default;
Engine& operator=(Engine&& engine) = default;
~Engine() = default;
void register_command(Wrapper* wrapper, std::string command){
assert(commands.find(command) == commands.end() && "Command already exists");
assert(wrapper != nullptr && "Unexpected nullptr in engine");
commands[command] = wrapper;
}
int execute(std::string command, std::vector<std::pair<std::string, int>>const& arguments){
assert(commands.find(command) != commands.end() && "Command doesn't exists");
return(commands[command]->function_execute(arguments));
}
private:
std::map<std::string, Wrapper*> commands;
};