-
Notifications
You must be signed in to change notification settings - Fork 0
/
InterpretationEngine.h
56 lines (46 loc) · 1.96 KB
/
InterpretationEngine.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
46
47
48
49
50
51
52
53
54
55
56
#ifndef _INTERPRETATION_ENGINE_
#define _INTERPRETATION_ENGINE_
#include <deque>
#include <memory>
#include "Command.h"
/******************* INTERPRETATION ENGINE *******************/
//PImpl to store keys of accepted commands
struct PImplIntEngine {
std::set<std::string> commands_;
std::map<std::string, std::string> cmdAlias; //future -> adapt command renaming
bool isValidCmd;
};
class InterpretationEngine {
private:
InterpretationEngine();
static std::shared_ptr<InterpretationEngine> inpretEngine_; //singleton global obj
std::shared_ptr<PImplIntEngine> PIntEng_; //private impl
//utility methods
bool assertValidCommand();
void assertValidCla(std::string);
//Interpretation specific
int getMultiplicity(std::string);
std::string getPostCommand(std::string);
std::string getRealCommand(std::string);
std::string getFullCommand(std::string);
std::deque<std::string> MultiplyCommand(std::deque<std::string>, int);
//Special Member Functions
InterpretationEngine(const InterpretationEngine&) = delete; //prevent copying the class
InterpretationEngine& operator= (const InterpretationEngine&) = delete; //prevent copying the class
public:
//get global Interpretation Engine instance
static std::shared_ptr<InterpretationEngine> instance();
std::deque<std::string> interpretCommands(std::istream&);
std::deque<std::string> interpretCLAs(int argc, char** argv);
//mutators
void removeAlias(std::string);
void addAlias(std::string, std::string);
void addCommand(std::string);
void removeCommand(std::string);
void setValidCommand();
void setInvalidCommand();
//utility methods
bool assertRecognizedCommand(std::string);
std::string decodeAliasCommand(std::string);
};
#endif