-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
52 lines (43 loc) · 1.24 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
51
52
#include "accumulate_handler.h"
#include "control_unit_handler.h"
#include "handlers_chain.h"
#include "logging_handler.h"
#include "output_handler.h"
#include "processing_handler.h"
#include <iostream>
using namespace std;
int main (int argc, char ** argv)
{
using namespace std;
if (argc != 2)
{
cout << "Bulk size N should be specified as command-line argument" << endl;
return 0;
}
int N = stoi(argv[1]);
auto accumulator = make_shared<Accumulator>();
auto control_unit = make_shared<ControlUnit>(N);
auto chain = HandlersChain(make_shared<ProcessingHandler>(control_unit, accumulator));
chain.AddFront(make_shared<LoggingHandler>(control_unit, accumulator));
chain.AddFront(make_shared<OutputHandler>(control_unit, accumulator));
chain.AddFront(make_shared<ControlUnitHandler>(control_unit));
chain.AddFront(make_shared<AccumulateHandler>(accumulator));
do
{
string line = "";
if (getline(cin, line))
{
chain.PassThrough(line);
if (line == "EOF")
{
break;
}
}
else
{
chain.PassThrough("EOF");
break;
}
} while (true);
return 0;
}