-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
73 lines (60 loc) · 1.65 KB
/
main.cpp
File metadata and controls
73 lines (60 loc) · 1.65 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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#include <map>
#include <string>
#include <queue>
#include <stdlib.h>
#include <iostream>
#include "config.h"
#include "modules/Data/Data.h"
#include "modules/PQueue/PQueue.h"
/* Value definitions of the different values */
enum CommandValues{
c_not_defined,
c_exit,
c_print,
c_get,
c_remove
};
/* Map to associate the strings with the enum values */
static std::map<std::string, CommandValues>s_mapCommandValues;
static void InitCommands(void);
int main(){
/* Declare a priority_queue and specify the order as < */
/* The priorities will be assigned in the ascending order of priority */
PQueue pqData;
std::string command;
std::cout << "Priority Buffer" << std::endl;
std::cout << "Version: " << VERSION_MAJOR << "." << VERSION_MINOR << std::endl;
InitCommands();
while(true){
std::cout << "Please, enter a command" << std::endl;
std::cin >> command;
switch(s_mapCommandValues[command]){
case c_exit:
exit(EXIT_SUCCESS);
break;
case c_print:
pqData.print();
break;
case c_get:
pqData.get();
break;
case c_remove:
pqData.remove();
break;
default:
pqData.check_command(command);
break;
}
}
return 0;
}
/**
* @brief function to initialize command values.
*
*/
static void InitCommands(void){
s_mapCommandValues["exit"] = c_exit;
s_mapCommandValues["print"] = c_print;
s_mapCommandValues["get"] = c_get;
s_mapCommandValues["remove"] = c_remove;
}