-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoutput_handler.cpp
45 lines (38 loc) · 1.07 KB
/
output_handler.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
#include <iostream>
#include "bulk_writer.h"
#include "output_handler.h"
using namespace std;
OutputHandler::OutputHandler(shared_ptr<ControlUnit> controlUnit, shared_ptr<Accumulator> accumulator)
:m_control_unit(controlUnit), m_accumulator(accumulator)
{
}
void OutputHandler::ExecuteCommand(const ExecutableCommand& command)
{
UNUSED(command);
//cout << m_control_unit->GetState() << endl;
OutputBulkIfReady();
}
void OutputHandler::HandleControlFlow(const ControlCommand& command)
{
UNUSED(command);
//cout << m_control_unit->GetState() << endl;
OutputBulkIfReady();
}
void OutputHandler::OutputBulkIfReady() const
{
if ((m_control_unit->ShouldProcessBulk()))
{
auto bulk = m_accumulator->GetBulk();
//string separator = "";
cout << GREEN;
BulkWriter bulk_writer(cout);
bulk_writer.WriteBulk(bulk);
/* << "bulk: ";
for(const auto& command: bulk)
{
cout << separator << command.Text;
separator = ", ";
}*/
cout << RESET << endl;
}
}