-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprogram.h
More file actions
39 lines (30 loc) · 962 Bytes
/
Copy pathprogram.h
File metadata and controls
39 lines (30 loc) · 962 Bytes
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
#pragma once
#include "assembly.h"
#include "command.h"
#include "log.h"
template<int BITS>
class Program {
public:
Program(const std::string &filename, BasicLogPtr logger = standartLog);
void process(BasicLogPtr logger = standartLog);
int outputData();
private:
AssemblyData inputData_;
};
template<int BITS>
Program<BITS>::Program(const std::string &filename, BasicLogPtr logger) : inputData_(filename, logger) {
logger->info("Program is built");
}
template<int BITS>
void Program<BITS>::process(BasicLogPtr logger) {
logger->info("Start doing operations");
while (!inputData_.isEmpty()) {
auto needToDo(inputData_.getNext(logger));
Command<BITS>::command(needToDo.nameOperation(), inputData_.getValue(needToDo.leftOperand()),
inputData_.getValue(needToDo.rightOperand()), logger);
}
}
template<int BITS>
int Program<BITS>::outputData() {
return inputData_.getAns();
}