summaryrefslogtreecommitdiff
path: root/noncore/apps/tableviewer/db/datacache.h
Unidiff
Diffstat (limited to 'noncore/apps/tableviewer/db/datacache.h') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/tableviewer/db/datacache.h24
1 files changed, 15 insertions, 9 deletions
diff --git a/noncore/apps/tableviewer/db/datacache.h b/noncore/apps/tableviewer/db/datacache.h
index c5dc637..e38050c 100644
--- a/noncore/apps/tableviewer/db/datacache.h
+++ b/noncore/apps/tableviewer/db/datacache.h
@@ -18,68 +18,74 @@
18** 18**
19**********************************************************************/ 19**********************************************************************/
20 20
21/* 21/*
22 * This file is used to load the xml files that represent the database. 22 * This file is used to load the xml files that represent the database.
23 * The main requirment for said file is each data entry must contain a key, 23 * The main requirment for said file is each data entry must contain a key,
24 * otherwise any other data headings are allowed. 24 * otherwise any other data headings are allowed.
25 */ 25 */
26 26
27#ifndef __DATACACHE_H__ 27#ifndef __DATACACHE_H__
28#define __DATACACHE_H__ 28#define __DATACACHE_H__
29 29
30#include "common.h"
31
32/* OPIE */
33#include <opie2/odebug.h>
34using namespace Opie::Core;
35
36/* QT */
30#include <qstring.h> 37#include <qstring.h>
31#include <qvector.h> 38#include <qvector.h>
32#include "common.h"
33 39
34class DBStore; 40class DBStore;
35 41
36/*! Abstract class that defines how database stuff can be accessed */ 42/*! Abstract class that defines how database stuff can be accessed */
37class DBAccess { 43class DBAccess {
38public: 44public:
39 45
40// DBAccess(DBStore *d) { dstore = d; } 46// DBAccess(DBStore *d) { dstore = d; }
41 virtual ~DBAccess() {} 47 virtual ~DBAccess() {}
42 48
43 virtual QString type() { 49 virtual QString type() {
44 return QString(); 50 return QString();
45 } 51 }
46 52
47 virtual bool openSource(QIODevice *) { 53 virtual bool openSource(QIODevice *) {
48 qWarning("DBAccess::openSource not yet implemented"); 54 owarn << "DBAccess::openSource not yet implemented" << oendl;
49 return false; 55 return false;
50 } 56 }
51 57
52 virtual bool saveSource(QIODevice *) { 58 virtual bool saveSource(QIODevice *) {
53 qWarning("DBAccess::saveSource(QString) not yet implemented"); 59 owarn << "DBAccess::saveSource(QString) not yet implemented" << oendl;
54 return false; 60 return false;
55 } 61 }
56 62
57protected: 63protected:
58 DBStore *dstore; 64 DBStore *dstore;
59 QString source_name; 65 QString source_name;
60}; 66};
61 67
62class DBStore { 68class DBStore {
63public: 69public:
64 DBStore(); 70 DBStore();
65 ~DBStore(); 71 ~DBStore();
66 72
67 bool openSource(QIODevice *, const QString &source); 73 bool openSource(QIODevice *, const QString &source);
68 bool saveSource(QIODevice *, const QString &source); 74 bool saveSource(QIODevice *, const QString &source);
69 75
70 // Add an item 76 // Add an item
71 void addItem(DataElem *); 77 void addItem(DataElem *);
72 void addItemInternal(DataElem *); 78 void addItemInternal(DataElem *);
73 void removeItem(DataElem *); 79 void removeItem(DataElem *);
74 80
75 // Set the name of the database 81 // Set the name of the database
76 void setName(const QString &name); 82 void setName(const QString &name);
77 83
78 // Get the name of the database 84 // Get the name of the database
79 QString getName(); 85 QString getName();
80 86
81 KeyList *getKeys(); 87 KeyList *getKeys();
82 void setKeys(KeyList *); 88 void setKeys(KeyList *);
83 89
84 /*! gets the number of fields defined in the database */ 90 /*! gets the number of fields defined in the database */
85 inline int getNumFields() { 91 inline int getNumFields() {
@@ -97,34 +103,34 @@ public:
97 } 103 }
98 104
99 /*! gets the name of a key given its index */ 105 /*! gets the name of a key given its index */
100 inline QString getKeyName(int i) { 106 inline QString getKeyName(int i) {
101 return kRep->getKeyName(i); 107 return kRep->getKeyName(i);
102 } 108 }
103 109
104// Access functions.. iterator type stuff 110// Access functions.. iterator type stuff
105 111
106 void first(); 112 void first();
107 void last(); 113 void last();
108 114
109 bool next(); 115 bool next();
110 bool previous(); 116 bool previous();
111 117
112 DataElem* getCurrentData(); 118 DataElem* getCurrentData();
113 119
114private: 120private:
115 /* does the work of freeing used memory */ 121 /* does the work of freeing used memory */
116 void freeTable(); 122 void freeTable();
117 QString name; 123 QString name;
118 124
119 QVector<DataElem> master_table; 125 QVector<DataElem> master_table;
120 DBAccess *archive; 126 DBAccess *archive;
121 127
122 KeyList *kRep; 128 KeyList *kRep;
123 129
124 unsigned int number_elems; 130 unsigned int number_elems;
125 unsigned int table_size; /* should always be a power of 2 */ 131 unsigned int table_size; /* should always be a power of 2 */
126 bool full; /* since because we are using an int for indexing there is 132 bool full; /* since because we are using an int for indexing there is
127 an upper limit on the number of items we can store. */ 133 an upper limit on the number of items we can store. */
128 unsigned int current_elem; 134 unsigned int current_elem;
129}; 135};
130#endif 136#endif