-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStatementManager.h
More file actions
63 lines (48 loc) · 1.52 KB
/
StatementManager.h
File metadata and controls
63 lines (48 loc) · 1.52 KB
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
53
54
55
56
57
58
59
60
61
62
63
#ifndef STATEMENTMANAGER_H
#define STATEMENTMANAGER_H
#include <vector>
#include "Statement.h"
#include "NumExpr.h"
using namespace std;
class StatementManager {
public:
StatementManager() = default;
//distruttore
~StatementManager() {
auto i = allocated.begin();
for (; i != allocated.end(); i++) {
delete(*i);
}
}
StatementManager(const StatementManager& other) = delete;
StatementManager& operator=(const StatementManager& other) = delete;
Statement* makePrintStmt(NumExpr* element) {
Statement* prin = new PrintStmt(element);
allocated.push_back(prin);
return prin;
}
//metodi per creare oggetti di tipo Statement
Statement* makeSetStmt(Variable* first, NumExpr* second) {
Statement* set = new SetStmt(first, second);
allocated.push_back(set);
return set;
}
Statement* makeInputStmt(Variable* element) {
Statement* input = new InputStmt(element);
allocated.push_back(input);
return input;
}
Statement* makeWhileStmt(BoolExpr* first, Block* second) {
Statement* wh = new WhileStmt(first, second);
allocated.push_back(wh);
return wh;
}
Statement* makeIfStmt(BoolExpr* first, Block* second, Block* third) {
Statement* ifs = new IfStmt(first, second, third);
allocated.push_back(ifs);
return ifs;
}
private:
vector <Statement*> allocated;
};
#endif