source: tags/0.55/stopos_pool.h @ 9

Last change on this file since 9 was 9, checked in by willem, 11 years ago

willem

File size: 2.8 KB
Line 
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 
8class datarecord
9{
10  public:
11    datarecord();
12    datarecord(const std::string &s,char sep);
13    stopos_key prev;
14    stopos_key next;
15    longuint retrieved;
16    std::string value;
17    std::string str(char dbsep);
18} ;
19class statusrecord
20{
21  public:
22  stopos_key next;      // points to first line for the 'next' command
23  stopos_key first;     // points to first record
24  stopos_key last;      // points to last record
25  stopos_key nextd;     // points to record to be dumped
26  longuint count;       // total number of records added
27  longuint present;     // total number of records now availabe
28  longuint present0;    // ditto, but uncommitted
29
30  statusrecord(void);
31  statusrecord(const std::string &s,char dbsep);
32  std::string str(char dbsep);
33  void init(void);
34};
35
36class stopos_pool
37{
38  protected:
39    char* db_name;        // name for database
40    std::string sdb_name; // idem
41    static const unsigned int reclen = 256; // 1024;
42    bool kvp; //true if Koot-Vermin paradigm is to be used
43    bool db_open;
44   
45    stopos_key statuskey;
46    stopos_key nextkey;
47    statusrecord status;
48
49    virtual int get_record(datarecord &r,const stopos_key &k)=0;
50    virtual int put_record(datarecord &r,const stopos_key &k)=0;
51    virtual int remove_record(const stopos_key &k)=0;
52    virtual int get_status(void)=0;
53    virtual int put_status(void)=0;
54
55  public:
56
57    stopos_pool();
58    ~stopos_pool();
59
60    virtual int create_db(void) = 0;
61    virtual int purge_db(void)  = 0;
62    virtual int open_db(void)   = 0;
63    virtual int close_db(void)  = 0;
64    virtual void dump_db(void)  = 0;
65
66    virtual void set_db_name(std::string filename);
67    virtual std::string get_db_name(void);
68
69    virtual int add_line(const std::string line,std::string &key);
70    virtual int get_line(std::string &line,longuint &retrieved,std::string &key);
71    virtual int remove_line(const std::string &key);
72
73    virtual void set_kvp(const bool v);
74    virtual bool get_kvp(void);
75
76    int get_counts(longuint &count, 
77                   longuint &present, 
78                   longuint &present0);
79
80    int dump_line(std::string  &line,
81                  longuint     &retrieved,
82                  std::string  &key);
83
84    const static int NOFILENAME        =  1;
85    const static int OPENERROR         =  2;
86    const static int STOREERROR        =  3;
87    const static int FETCHERROR        =  4;
88    const static int NOTFOUND          =  5;
89    const static int NOTIMPLEMENTED    =  6;
90    const static int REMOVEERROR       =  7;
91    const static int LOCKERROR         =  8;
92    const static int CLOSEERROR        =  9;
93    const static int UNLOCKERROR       = 10;
94    const static int DBNOTOPEN         = 11;
95    const static int CREATEERROR       = 12;
96    const static int PURGEERROR        = 13;
97
98};
99#endif
Note: See TracBrowser for help on using the repository browser.