-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCLI.cpp
More file actions
65 lines (54 loc) · 1.65 KB
/
Copy pathCLI.cpp
File metadata and controls
65 lines (54 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
#include "CLI.h"
CLI::CLI(DefaultIO* dio) {
this->dio = dio;
sharedData = new SharedData;
commands.push_back(new UploadTimeSeries(dio,sharedData));
commands.push_back(new ChangeThreshold(dio,sharedData));
commands.push_back(new DetectAnomalies(dio,sharedData));
commands.push_back(new DisplayResults(dio,sharedData));
commands.push_back(new AnalyzeResults(dio, sharedData));
}
void CLI::start(){
int key;
do {
dio->write("Welcome to the Anomaly Detection Server.");
dio->write("Please choose an option:");
dio->write("1.upload a time series csv file");
dio->write("2.algorithm settings");
dio->write("3.detect anomalies");
dio->write("4.display results");
dio->write("5.upload anomalies and analyze results");
dio->write("6.exit");
stringstream stream(dio->read());
stream >> key;
switch (key) {
case 1:
commands[0]->execute();
break;
case 2:
commands[1]->execute();
break;
case 3:
commands[2]->execute();
break;
case 4:
commands[3]->execute();
break;
case 5:
commands[4]->execute();
break;
}
} while (key != 6);
}
CLI::~CLI() {
if(sharedData != nullptr) {
delete(sharedData);
sharedData = nullptr;
}
for (auto item : commands) {
if(item != nullptr) {
delete(item);
item = nullptr;
}
}
}