summaryrefslogtreecommitdiff
path: root/libopie2/opiepim/backend/opimaccessbackend.h
Unidiff
Diffstat (limited to 'libopie2/opiepim/backend/opimaccessbackend.h') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiepim/backend/opimaccessbackend.h4
1 files changed, 2 insertions, 2 deletions
diff --git a/libopie2/opiepim/backend/opimaccessbackend.h b/libopie2/opiepim/backend/opimaccessbackend.h
index f4bbe35..c3d91f7 100644
--- a/libopie2/opiepim/backend/opimaccessbackend.h
+++ b/libopie2/opiepim/backend/opimaccessbackend.h
@@ -1,57 +1,58 @@
1#ifndef OPIE_PIM_ACCESS_BACKEND 1#ifndef OPIE_PIM_ACCESS_BACKEND
2#define OPIE_PIM_ACCESS_BACKEND 2#define OPIE_PIM_ACCESS_BACKEND
3 3
4#include <qarray.h> 4#include <qarray.h>
5 5
6#include <opie/otemplatebase.h> 6#include <opie/otemplatebase.h>
7#include <opie/opimrecord.h> 7#include <opie/opimrecord.h>
8 8
9 9
10class OPimAccessBackendPrivate;
10/** 11/**
11 * OPimAccessBackend is the base class 12 * OPimAccessBackend is the base class
12 * for all private backends 13 * for all private backends
13 * it operates on OPimRecord as the base class 14 * it operates on OPimRecord as the base class
14 * and it's responsible for fast manipulating 15 * and it's responsible for fast manipulating
15 * the resource the implementation takes care 16 * the resource the implementation takes care
16 * of 17 * of
17 */ 18 */
18template <class T = OPimRecord> 19template <class T = OPimRecord>
19class OPimAccessBackend { 20class OPimAccessBackend {
20public: 21public:
21 typedef OTemplateBase<T> Frontend; 22 typedef OTemplateBase<T> Frontend;
22 23
23 /** The access hint from the frontend */ 24 /** The access hint from the frontend */
24 OPimAccessBackend(int access = 0); 25 OPimAccessBackend(int access = 0);
25 virtual ~OPimAccessBackend(); 26 virtual ~OPimAccessBackend();
26 27
27 /** 28 /**
28 * load the resource 29 * load the resource
29 */ 30 */
30 virtual bool load() = 0; 31 virtual bool load() = 0;
31 32
32 /** 33 /**
33 * reload the resource 34 * reload the resource
34 */ 35 */
35 virtual bool reload() = 0; 36 virtual bool reload() = 0;
36 37
37 /** 38 /**
38 * save the resource and 39 * save the resource and
39 * all it's changes 40 * all it's changes
40 */ 41 */
41 virtual bool save() = 0; 42 virtual bool save() = 0;
42 43
43 /** 44 /**
44 * return an array of 45 * return an array of
45 * all available uids 46 * all available uids
46 */ 47 */
47 virtual QArray<int> allRecords()const = 0; 48 virtual QArray<int> allRecords()const = 0;
48 49
49 /** 50 /**
50 * return a List of records 51 * return a List of records
51 * that match the regex 52 * that match the regex
52 */ 53 */
53 virtual QArray<int> matchRegexp(const QRegExp &r) const = 0; 54 virtual QArray<int> matchRegexp(const QRegExp &r) const = 0;
54 55
55 /** 56 /**
56 * queryByExample for T with the given Settings 57 * queryByExample for T with the given Settings
57 * 58 *
@@ -62,98 +63,97 @@ public:
62 * find the OPimRecord with uid @param uid 63 * find the OPimRecord with uid @param uid
63 * returns T and T.isEmpty() if nothing was found 64 * returns T and T.isEmpty() if nothing was found
64 */ 65 */
65 virtual T find(int uid )const = 0; 66 virtual T find(int uid )const = 0;
66 67
67 virtual T find(int uid, const QArray<int>& items, 68 virtual T find(int uid, const QArray<int>& items,
68 uint current, typename Frontend::CacheDirection )const ; 69 uint current, typename Frontend::CacheDirection )const ;
69 /** 70 /**
70 * clear the back end 71 * clear the back end
71 */ 72 */
72 virtual void clear() = 0; 73 virtual void clear() = 0;
73 74
74 /** 75 /**
75 * add T 76 * add T
76 */ 77 */
77 virtual bool add( const T& t ) = 0; 78 virtual bool add( const T& t ) = 0;
78 79
79 /** 80 /**
80 * remove 81 * remove
81 */ 82 */
82 virtual bool remove( int uid ) = 0; 83 virtual bool remove( int uid ) = 0;
83 84
84 /** 85 /**
85 * replace a record with T.uid() 86 * replace a record with T.uid()
86 */ 87 */
87 virtual bool replace( const T& t ) = 0; 88 virtual bool replace( const T& t ) = 0;
88 89
89 /* 90 /*
90 * setTheFrontEnd!!! 91 * setTheFrontEnd!!!
91 */ 92 */
92 void setFrontend( Frontend* front ); 93 void setFrontend( Frontend* front );
93 94
94 /** 95 /**
95 * set the read ahead count 96 * set the read ahead count
96 */ 97 */
97 void setReadAhead( uint count ); 98 void setReadAhead( uint count );
98protected: 99protected:
99 int access()const; 100 int access()const;
100 void cache( const T& t )const; 101 void cache( const T& t )const;
101 102
102 /** 103 /**
103 * use a prime number here! 104 * use a prime number here!
104 */ 105 */
105 void setSaneCacheSize( int ); 106 void setSaneCacheSize( int );
106 107
107 uint readAhead()const; 108 uint readAhead()const;
108 109
109private: 110private:
110 class Private; 111 OPimAccessBackendPrivate *d;
111 Private* d;
112 Frontend* m_front; 112 Frontend* m_front;
113 uint m_read; 113 uint m_read;
114 int m_acc; 114 int m_acc;
115 115
116}; 116};
117 117
118template <class T> 118template <class T>
119OPimAccessBackend<T>::OPimAccessBackend(int acc) 119OPimAccessBackend<T>::OPimAccessBackend(int acc)
120 : m_acc( acc ) 120 : m_acc( acc )
121{ 121{
122 m_front = 0l; 122 m_front = 0l;
123} 123}
124template <class T> 124template <class T>
125OPimAccessBackend<T>::~OPimAccessBackend() { 125OPimAccessBackend<T>::~OPimAccessBackend() {
126 126
127} 127}
128template <class T> 128template <class T>
129void OPimAccessBackend<T>::setFrontend( Frontend* fr ) { 129void OPimAccessBackend<T>::setFrontend( Frontend* fr ) {
130 m_front = fr; 130 m_front = fr;
131} 131}
132template <class T> 132template <class T>
133void OPimAccessBackend<T>::cache( const T& t )const { 133void OPimAccessBackend<T>::cache( const T& t )const {
134 if (m_front ) 134 if (m_front )
135 m_front->cache( t ); 135 m_front->cache( t );
136} 136}
137template <class T> 137template <class T>
138void OPimAccessBackend<T>::setSaneCacheSize( int size) { 138void OPimAccessBackend<T>::setSaneCacheSize( int size) {
139 if (m_front ) 139 if (m_front )
140 m_front->setSaneCacheSize( size ); 140 m_front->setSaneCacheSize( size );
141} 141}
142template <class T> 142template <class T>
143T OPimAccessBackend<T>::find( int uid, const QArray<int>&, 143T OPimAccessBackend<T>::find( int uid, const QArray<int>&,
144 uint, typename Frontend::CacheDirection )const { 144 uint, typename Frontend::CacheDirection )const {
145 return find( uid ); 145 return find( uid );
146} 146}
147template <class T> 147template <class T>
148void OPimAccessBackend<T>::setReadAhead( uint count ) { 148void OPimAccessBackend<T>::setReadAhead( uint count ) {
149 m_read = count; 149 m_read = count;
150} 150}
151template <class T> 151template <class T>
152uint OPimAccessBackend<T>::readAhead()const { 152uint OPimAccessBackend<T>::readAhead()const {
153 return m_read; 153 return m_read;
154} 154}
155template <class T> 155template <class T>
156int OPimAccessBackend<T>::access()const { 156int OPimAccessBackend<T>::access()const {
157 return m_acc; 157 return m_acc;
158} 158}
159#endif 159#endif