1 | #ifndef STOPOS_POOL_H |
---|
2 | #define STOPOS_POOL_H |
---|
3 | #include <string> |
---|
4 | #include "stopos.h" |
---|
5 | #include "stopos_key.h" |
---|
6 | #include <iostream> |
---|
7 | |
---|
8 | typedef unsigned long long longuint; |
---|
9 | class datarecord |
---|
10 | { |
---|
11 | public: |
---|
12 | datarecord(); |
---|
13 | datarecord(const std::string &s,char sep); |
---|
14 | stopos_key prev; |
---|
15 | stopos_key next; |
---|
16 | longuint retrieved; |
---|
17 | std::string value; |
---|
18 | std::string str(char dbsep); |
---|
19 | } ; |
---|
20 | class statusrecord |
---|
21 | { |
---|
22 | public: |
---|
23 | stopos_key next; |
---|
24 | stopos_key first; |
---|
25 | stopos_key last; |
---|
26 | longuint count; |
---|
27 | |
---|
28 | statusrecord(void); |
---|
29 | statusrecord(const std::string &s,char dbsep); |
---|
30 | std::string str(char dbsep); |
---|
31 | void init(void); |
---|
32 | }; |
---|
33 | |
---|
34 | class stopos_pool |
---|
35 | { |
---|
36 | protected: |
---|
37 | char* db_name; // name for database |
---|
38 | std::string sdb_name; // idem |
---|
39 | static const unsigned int reclen = 1024; |
---|
40 | bool kvp; //true if Koot-Vermin paradigm is to be used |
---|
41 | bool db_open; |
---|
42 | |
---|
43 | stopos_key statuskey; |
---|
44 | stopos_key nextkey; |
---|
45 | statusrecord status; |
---|
46 | |
---|
47 | virtual int get_record(datarecord &r,const stopos_key &k)=0; |
---|
48 | virtual int put_record(datarecord &r,const stopos_key &k)=0; |
---|
49 | virtual int remove_record(const stopos_key &k)=0; |
---|
50 | virtual int get_status(void)=0; |
---|
51 | virtual int put_status(void)=0; |
---|
52 | |
---|
53 | |
---|
54 | public: |
---|
55 | |
---|
56 | stopos_pool(); |
---|
57 | ~stopos_pool(); |
---|
58 | |
---|
59 | virtual int create_db(void) = 0; |
---|
60 | virtual int purge_db(void) = 0; |
---|
61 | virtual int open_db(void) = 0; |
---|
62 | virtual int close_db(void) = 0; |
---|
63 | virtual void dump_db(void) = 0; |
---|
64 | |
---|
65 | virtual void set_db_name(std::string filename); |
---|
66 | virtual std::string get_db_name(void); |
---|
67 | |
---|
68 | virtual int add_line(const std::string line,std::string &key); |
---|
69 | virtual int get_line(std::string &line,unsigned int &retrieved,std::string &key); |
---|
70 | virtual int remove_line(const std::string &key); |
---|
71 | |
---|
72 | virtual void set_kvp(const bool v); |
---|
73 | virtual bool get_kvp(void); |
---|
74 | |
---|
75 | |
---|
76 | const static int NOFILENAME = 1; |
---|
77 | const static int OPENERROR = 2; |
---|
78 | const static int STOREERROR = 3; |
---|
79 | const static int FETCHERROR = 4; |
---|
80 | const static int NOTFOUND = 5; |
---|
81 | const static int NOTIMPLEMENTED = 6; |
---|
82 | const static int REMOVEERROR = 7; |
---|
83 | const static int LOCKERROR = 8; |
---|
84 | const static int CLOSEERROR = 9; |
---|
85 | const static int UNLOCKERROR = 10; |
---|
86 | const static int DBNOTOPEN = 11; |
---|
87 | const static int CREATEERROR = 12; |
---|
88 | const static int PURGEERROR = 13; |
---|
89 | |
---|
90 | }; |
---|
91 | #endif |
---|