-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrecorder.hpp
More file actions
99 lines (76 loc) · 2.07 KB
/
recorder.hpp
File metadata and controls
99 lines (76 loc) · 2.07 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#ifndef _recorder_
#define _recorder_
#include <fstream>
#include <vector>
#include <stdio.h>
#include <map>
#include "bufferManager.hpp"
#include "auxiliary.hpp"
using namespace std;
template<typename T> bool isEqual(void* t1, string& t2, int length)
{
T * val = (T*) t1;
}
class freeList
{
private:
vector<long> offset;
string fileAddr;
short elementSize;
int numOfblocks;
public:
freeList(string& fileAddr, short elementSize);
~freeList();
short getElementSize();
void setIndex();
void addElement(long offset);
bool isEmpty();
long getNext();
friend class recorder;
};
/*
class WhereForRecorder
{
public:
int type; 0-int 1-float 2-char
int length
string op;
string value;
int offset; //the first: 0
};
*/
class conditionJudge
{
private:
vector<WhereForRecorder>* cond;
int elementSize;
bool flag;
public:
conditionJudge(vector<WhereForRecorder>* cond, int elementSize):cond(cond), elementSize(elementSize){flag = false;};
conditionJudge(){flag = true;}
bool isSatisfied(char *p);
bool isSatisfied(void *pt);
//~conditionJudge(){if(!flag) delete cond;}
};
class recorder
{
private:
map<string, int> table2Freelist;
map<int, string> freelist2Table;
vector<freeList* > freeListVector;
string dataPath;
public:
recorder(string& fileAddr);//finish
~recorder();//finish
bool createTable(string& tableName, short elementSize);//finish
bool deleteNoWhere(string& tableName);//fiish
bool updateWhere(string& tableName, long offset, void * data);
bool deleteWhereNoIndex(string& tableName, conditionJudge& judger);
bool deleteWhereIndex(string& tableName, long offset, conditionJudge& judger);
long insert(void* data, string& tableName);
bool dropTable(string& tableName);
vector<void*> selectNoWhere(string& tableName, vector<int>* addr = NULL);
vector<void*> selectWhereIndex(string& tableName, vector<int> offset, conditionJudge& judger);
vector<void*> selectWhereNoIndex(string& tableName, conditionJudge& judger);
};
#endif