-
Notifications
You must be signed in to change notification settings - Fork 0
/
record.h
48 lines (38 loc) · 1.11 KB
/
record.h
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
#pragma once
#include "basicType.h"
#include "typeHelper.hpp"
#include "typeHelper.hpp"
#include <vector>
using namespace std;
enum recType{ADD,DEL,MOD};
class record
{
private:
void setAddTarget(vector<Basic*> addTarget) //“增”时需要指定增进去的元组,会自动拷贝
{
for(Basic* v : addTarget)
this->targetTuple.push_back(typeHelper::typehelper->copy(v));
}
public:
int opSub=-1;
recType type;
record(vector<Basic*> addTarget) : type(ADD) //“增”的构造函数
{
this->setAddTarget(addTarget);
}
record(int opSub) : opSub(opSub), type(DEL) {} //“删”的构造函数
record(int opSub, vector<Basic*> modTarget) : opSub(opSub), type(MOD) //“改”的构造函数
{
this->setAddTarget(modTarget);
}
record(const record &r) : opSub(r.opSub), type(r.type)
{
this->setAddTarget(r.targetTuple);
}
~record()
{
for(Basic* v : targetTuple)
delete v;
}
vector<Basic*> targetTuple; //仅当type!=del时使用,变更之后的元组,placeholder对象为不修改
};