-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNumExprManager.h
More file actions
45 lines (36 loc) · 1.08 KB
/
NumExprManager.h
File metadata and controls
45 lines (36 loc) · 1.08 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
#ifndef NUMEXPRMANAGER_H
#define NUMEXPRMANAGER_H
#include <vector>
#include "NumExpr.h"
class NumExprManager {
public:
NumExprManager() = default;
//distruttore
~NumExprManager() {
auto i = allocated.begin();
for (; i != allocated.end(); i++) {
delete(*i);
}
}
NumExprManager(const NumExprManager& other) = delete;
NumExprManager& operator= (const NumExprManager& other) = delete;
////metodi per allocare gli oggetti di tipo NumExpr
NumExpr* makeNumber(int64_t value) {
NumExpr* n = new Number(value);
allocated.push_back(n);
return n;
}
NumExpr* makeVariable(string v, int64_t value) {
NumExpr* var = new Variable(v, value);
allocated.push_back(var);
return var;
}
NumExpr* makeOperator(Operator::OpCode_Operator op, NumExpr* first, NumExpr* second) {
NumExpr* ope = new Operator(op, first, second);
allocated.push_back(ope);
return ope;
}
private:
vector<NumExpr*> allocated;
};
#endif