-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
50 lines (47 loc) · 1.68 KB
/
main.cpp
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
#include "scheduler.hpp"
#include <csignal>
bool on = true; // Global variable to stop the program
/**
* @brief Signal handler
* @details This function is used to stop the program when the user press CTRL+C
* @param signum
*/
void signalHandler(int signum) {
std::cout << "\nStopping program..." << std::endl;
on = false;
}
/**
* @brief Main function
* @param argc number of arguments
* @param argv arguments
* @return 0 if the program is stopped correctly
*/
int main(int argc, char** argv) {
signal(SIGINT, signalHandler);
bool consoleActivation = false;
bool logActivation = false;
std::string arg;
for (int i = 1; i < argc; i++) {
arg = argv[i];
if (arg == "-l" || arg == "--log") {
logActivation = true;
} else if (arg == "-c" || arg == "--console") {
consoleActivation = true;
} else if (arg == "-v" || arg == "--version") {
std::cout << "AP4A Project - v1.0" << std::endl;
std::cout << "Compilation date : " << __DATE__ << " " << __TIME__ << std::endl;
return 0;
} else if (arg == "-h" || arg == "--help") {
std::cout << "Usage : " << argv[0] << " [options]\n\n"
<< "Options : -h, --help Print this help manual.\n"
<< " -v, --version Print program's version and compilation date.\n"
<< " -l, --log Turn on writing on log file.\n"
<< " -c, --console Turn on console writing." << std::endl;
return 0;
}
}
Scheduler* scheduler = new Scheduler(consoleActivation, logActivation);
while(on) {};
delete scheduler;
return 0;
}