-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.cpp
43 lines (35 loc) · 862 Bytes
/
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
/** @brief Main function for Calculation Engines
@author Junsheng Fu
@date 2 July 2017
*/
#include <iostream>
#include <vector>
#include <string>
#include "helper_functions.h"
#include "factory.h"
using namespace std;
int main(int argc, char* argv[]) {
// check the input arguments
if (!checkValidArg(argc, argv)) {
return 0;
}
// get inputs list_files or integers
std::vector<double> arr;
if (!getInputs(arr, argc, argv)) {
return 0;
}
// execute the user selected math engine: Multiplier or Divider
std::string engine_name;
engine_name = argv[1];
if (!arr.empty()) {
try {
Base<double> *f = Base<double>::select_engine(engine_name);
double res = f->compute(arr);
std::cout << res<<std::endl;
}
catch (const char *msg) {
std::cerr << msg << std::endl;
}
}
return 0;
}