Diffstat (limited to 'libopie/pim/opimaccessbackend.h') (more/less context) (ignore whitespace changes)
-rw-r--r-- | libopie/pim/opimaccessbackend.h | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/libopie/pim/opimaccessbackend.h b/libopie/pim/opimaccessbackend.h index f4bbe35..c3d91f7 100644 --- a/libopie/pim/opimaccessbackend.h +++ b/libopie/pim/opimaccessbackend.h | |||
@@ -1,159 +1,159 @@ | |||
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 | ||
10 | class 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 | */ |
18 | template <class T = OPimRecord> | 19 | template <class T = OPimRecord> |
19 | class OPimAccessBackend { | 20 | class OPimAccessBackend { |
20 | public: | 21 | public: |
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 | * |
58 | */ | 59 | */ |
59 | virtual QArray<int> queryByExample( const T& t, int settings, const QDateTime& d = QDateTime() ) = 0; | 60 | virtual QArray<int> queryByExample( const T& t, int settings, const QDateTime& d = QDateTime() ) = 0; |
60 | 61 | ||
61 | /** | 62 | /** |
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 ); |
98 | protected: | 99 | protected: |
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 | ||
109 | private: | 110 | private: |
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 | ||
118 | template <class T> | 118 | template <class T> |
119 | OPimAccessBackend<T>::OPimAccessBackend(int acc) | 119 | OPimAccessBackend<T>::OPimAccessBackend(int acc) |
120 | : m_acc( acc ) | 120 | : m_acc( acc ) |
121 | { | 121 | { |
122 | m_front = 0l; | 122 | m_front = 0l; |
123 | } | 123 | } |
124 | template <class T> | 124 | template <class T> |
125 | OPimAccessBackend<T>::~OPimAccessBackend() { | 125 | OPimAccessBackend<T>::~OPimAccessBackend() { |
126 | 126 | ||
127 | } | 127 | } |
128 | template <class T> | 128 | template <class T> |
129 | void OPimAccessBackend<T>::setFrontend( Frontend* fr ) { | 129 | void OPimAccessBackend<T>::setFrontend( Frontend* fr ) { |
130 | m_front = fr; | 130 | m_front = fr; |
131 | } | 131 | } |
132 | template <class T> | 132 | template <class T> |
133 | void OPimAccessBackend<T>::cache( const T& t )const { | 133 | void 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 | } |
137 | template <class T> | 137 | template <class T> |
138 | void OPimAccessBackend<T>::setSaneCacheSize( int size) { | 138 | void 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 | } |
142 | template <class T> | 142 | template <class T> |
143 | T OPimAccessBackend<T>::find( int uid, const QArray<int>&, | 143 | T 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 | } |
147 | template <class T> | 147 | template <class T> |
148 | void OPimAccessBackend<T>::setReadAhead( uint count ) { | 148 | void OPimAccessBackend<T>::setReadAhead( uint count ) { |
149 | m_read = count; | 149 | m_read = count; |
150 | } | 150 | } |
151 | template <class T> | 151 | template <class T> |
152 | uint OPimAccessBackend<T>::readAhead()const { | 152 | uint OPimAccessBackend<T>::readAhead()const { |
153 | return m_read; | 153 | return m_read; |
154 | } | 154 | } |
155 | template <class T> | 155 | template <class T> |
156 | int OPimAccessBackend<T>::access()const { | 156 | int OPimAccessBackend<T>::access()const { |
157 | return m_acc; | 157 | return m_acc; |
158 | } | 158 | } |
159 | #endif | 159 | #endif |