-rw-r--r-- | libopie2/opiepim/core/opimaccesstemplate.h | 7 | ||||
-rw-r--r-- | libopie2/opiepim/core/opimcontactfields.h | 2 | ||||
-rw-r--r-- | libopie2/opiepim/core/opimtemplatebase.h | 6 |
3 files changed, 1 insertions, 14 deletions
diff --git a/libopie2/opiepim/core/opimaccesstemplate.h b/libopie2/opiepim/core/opimaccesstemplate.h index 7ab1ea5..f936d4e 100644 --- a/libopie2/opiepim/core/opimaccesstemplate.h +++ b/libopie2/opiepim/core/opimaccesstemplate.h | |||
@@ -157,49 +157,48 @@ public: | |||
157 | * @param t The item to remove | 157 | * @param t The item to remove |
158 | * @return <i>true</i> if successful. | 158 | * @return <i>true</i> if successful. |
159 | */ | 159 | */ |
160 | virtual bool remove( const T& t ); | 160 | virtual bool remove( const T& t ); |
161 | 161 | ||
162 | /** | 162 | /** |
163 | * remove the OPimRecord with uid | 163 | * remove the OPimRecord with uid |
164 | * @param uid The ID of the item to remove | 164 | * @param uid The ID of the item to remove |
165 | * @return <i>true</i> if successful. | 165 | * @return <i>true</i> if successful. |
166 | */ | 166 | */ |
167 | bool remove( int uid ); | 167 | bool remove( int uid ); |
168 | bool remove( const OPimRecord& ); | 168 | bool remove( const OPimRecord& ); |
169 | 169 | ||
170 | /** | 170 | /** |
171 | * replace T from backend | 171 | * replace T from backend |
172 | * @param t The item to replace | 172 | * @param t The item to replace |
173 | * @return <i>true</i> if successful. | 173 | * @return <i>true</i> if successful. |
174 | */ | 174 | */ |
175 | virtual bool replace( const T& t) ; | 175 | virtual bool replace( const T& t) ; |
176 | 176 | ||
177 | void setReadAhead( uint count ); | 177 | void setReadAhead( uint count ); |
178 | /** | 178 | /** |
179 | * @internal | 179 | * @internal |
180 | */ | 180 | */ |
181 | virtual T cacheFind( int uid )const; | ||
182 | void cache( const T& )const; | 181 | void cache( const T& )const; |
183 | void setSaneCacheSize( int ); | 182 | void setSaneCacheSize( int ); |
184 | 183 | ||
185 | QArray<int> records()const; | 184 | QArray<int> records()const; |
186 | protected: | 185 | protected: |
187 | /** | 186 | /** |
188 | * invalidate the cache | 187 | * invalidate the cache |
189 | */ | 188 | */ |
190 | void invalidateCache(); | 189 | void invalidateCache(); |
191 | 190 | ||
192 | void setBackEnd( BackEnd* end ); | 191 | void setBackEnd( BackEnd* end ); |
193 | /** | 192 | /** |
194 | * returns the backend | 193 | * returns the backend |
195 | */ | 194 | */ |
196 | BackEnd* backEnd(); | 195 | BackEnd* backEnd(); |
197 | BackEnd* m_backEnd; | 196 | BackEnd* m_backEnd; |
198 | 197 | ||
199 | Cache m_cache; | 198 | Cache m_cache; |
200 | 199 | ||
201 | private: | 200 | private: |
202 | OPimAccessTemplatePrivate *d; | 201 | OPimAccessTemplatePrivate *d; |
203 | 202 | ||
204 | }; | 203 | }; |
205 | 204 | ||
@@ -245,54 +244,48 @@ template <class T> | |||
245 | QArray<int> OPimAccessTemplate<T>::records()const { | 244 | QArray<int> OPimAccessTemplate<T>::records()const { |
246 | return m_backEnd->allRecords(); | 245 | return m_backEnd->allRecords(); |
247 | } | 246 | } |
248 | template <class T> | 247 | template <class T> |
249 | typename OPimAccessTemplate<T>::List | 248 | typename OPimAccessTemplate<T>::List |
250 | OPimAccessTemplate<T>::queryByExample( const T& t, int settings, const QDateTime& d ) { | 249 | OPimAccessTemplate<T>::queryByExample( const T& t, int settings, const QDateTime& d ) { |
251 | QArray<int> ints = m_backEnd->queryByExample( t, settings, d ); | 250 | QArray<int> ints = m_backEnd->queryByExample( t, settings, d ); |
252 | 251 | ||
253 | List lis(ints, this ); | 252 | List lis(ints, this ); |
254 | return lis; | 253 | return lis; |
255 | } | 254 | } |
256 | template <class T> | 255 | template <class T> |
257 | T OPimAccessTemplate<T>::find( int uid ) const{ | 256 | T OPimAccessTemplate<T>::find( int uid ) const{ |
258 | // First search in cache.. | 257 | // First search in cache.. |
259 | if ( m_cache.contains( uid ) ) | 258 | if ( m_cache.contains( uid ) ) |
260 | return m_cache.find( uid ); | 259 | return m_cache.find( uid ); |
261 | 260 | ||
262 | T t = m_backEnd->find( uid ); | 261 | T t = m_backEnd->find( uid ); |
263 | cache( t ); | 262 | cache( t ); |
264 | 263 | ||
265 | return t; | 264 | return t; |
266 | } | 265 | } |
267 | 266 | ||
268 | template <class T> | 267 | template <class T> |
269 | T OPimAccessTemplate<T>::cacheFind( int uid ) const | ||
270 | { | ||
271 | return m_cache.find( uid ); | ||
272 | } | ||
273 | |||
274 | template <class T> | ||
275 | T OPimAccessTemplate<T>::find( int uid, const QArray<int>& ar, | 268 | T OPimAccessTemplate<T>::find( int uid, const QArray<int>& ar, |
276 | uint current, typename OTemplateBase<T>::CacheDirection dir )const { | 269 | uint current, typename OTemplateBase<T>::CacheDirection dir )const { |
277 | /* | 270 | /* |
278 | * better do T.isEmpty() | 271 | * better do T.isEmpty() |
279 | * after a find this way we would | 272 | * after a find this way we would |
280 | * avoid two finds in QCache... | 273 | * avoid two finds in QCache... |
281 | */ | 274 | */ |
282 | // owarn << "find it now " << uid << oendl; | 275 | // owarn << "find it now " << uid << oendl; |
283 | if ( m_cache.contains( uid ) ) { | 276 | if ( m_cache.contains( uid ) ) { |
284 | return m_cache.find( uid ); | 277 | return m_cache.find( uid ); |
285 | } | 278 | } |
286 | 279 | ||
287 | T t = m_backEnd->find( uid, ar, current, dir ); | 280 | T t = m_backEnd->find( uid, ar, current, dir ); |
288 | cache( t ); | 281 | cache( t ); |
289 | return t; | 282 | return t; |
290 | } | 283 | } |
291 | template <class T> | 284 | template <class T> |
292 | void OPimAccessTemplate<T>::clear() { | 285 | void OPimAccessTemplate<T>::clear() { |
293 | invalidateCache(); | 286 | invalidateCache(); |
294 | m_backEnd->clear(); | 287 | m_backEnd->clear(); |
295 | } | 288 | } |
296 | template <class T> | 289 | template <class T> |
297 | bool OPimAccessTemplate<T>::add( const T& t ) { | 290 | bool OPimAccessTemplate<T>::add( const T& t ) { |
298 | cache( t ); | 291 | cache( t ); |
diff --git a/libopie2/opiepim/core/opimcontactfields.h b/libopie2/opiepim/core/opimcontactfields.h index 3aa3894..2e42951 100644 --- a/libopie2/opiepim/core/opimcontactfields.h +++ b/libopie2/opiepim/core/opimcontactfields.h | |||
@@ -1,27 +1,27 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | Copyright (C) The Main Author <main-author@whereever.org> | 3 | Copyright (C) Stefan Eielrs <eilers.stefan@epost.de> |
4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> | 4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> |
5 | .=l. | 5 | .=l. |
6 | .>+-= | 6 | .>+-= |
7 | _;:, .> :=|. This program is free software; you can | 7 | _;:, .> :=|. This program is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 8 | .> <`_, > . <= redistribute it and/or modify it under |
9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
10 | .="- .-=="i, .._ License as published by the Free Software | 10 | .="- .-=="i, .._ License as published by the Free Software |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 11 | - . .-<_> .<> Foundation; either version 2 of the License, |
12 | ._= =} : or (at your option) any later version. | 12 | ._= =} : or (at your option) any later version. |
13 | .%`+i> _;_. | 13 | .%`+i> _;_. |
14 | .i_,=:_. -<s. This program is distributed in the hope that | 14 | .i_,=:_. -<s. This program is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 16 | : .. .:, . . . without even the implied warranty of |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
19 | ..}^=.= = ; Library General Public License for more | 19 | ..}^=.= = ; Library General Public License for more |
20 | ++= -. .` .: details. | 20 | ++= -. .` .: details. |
21 | : = ...= . :.=- | 21 | : = ...= . :.=- |
22 | -. .:....=;==+<; You should have received a copy of the GNU | 22 | -. .:....=;==+<; You should have received a copy of the GNU |
23 | -_. . . )=. = Library General Public License along with | 23 | -_. . . )=. = Library General Public License along with |
24 | -- :-=` this library; see the file COPYING.LIB. | 24 | -- :-=` this library; see the file COPYING.LIB. |
25 | If not, write to the Free Software Foundation, | 25 | If not, write to the Free Software Foundation, |
26 | Inc., 59 Temple Place - Suite 330, | 26 | Inc., 59 Temple Place - Suite 330, |
27 | Boston, MA 02111-1307, USA. | 27 | Boston, MA 02111-1307, USA. |
diff --git a/libopie2/opiepim/core/opimtemplatebase.h b/libopie2/opiepim/core/opimtemplatebase.h index ec9a94e..787486c 100644 --- a/libopie2/opiepim/core/opimtemplatebase.h +++ b/libopie2/opiepim/core/opimtemplatebase.h | |||
@@ -72,54 +72,48 @@ private: | |||
72 | /** | 72 | /** |
73 | * internal template base | 73 | * internal template base |
74 | * Attention: T needs to implement the copy c'tor!!! | 74 | * Attention: T needs to implement the copy c'tor!!! |
75 | */ | 75 | */ |
76 | class OTemplateBasePrivate; | 76 | class OTemplateBasePrivate; |
77 | template <class T = OPimRecord> | 77 | template <class T = OPimRecord> |
78 | class OTemplateBase : public OPimBase { | 78 | class OTemplateBase : public OPimBase { |
79 | public: | 79 | public: |
80 | /** Look ahead direction of cache */ | 80 | /** Look ahead direction of cache */ |
81 | enum CacheDirection { Forward=0, Reverse }; | 81 | enum CacheDirection { Forward=0, Reverse }; |
82 | 82 | ||
83 | OTemplateBase() { | 83 | OTemplateBase() { |
84 | }; | 84 | }; |
85 | virtual ~OTemplateBase() { | 85 | virtual ~OTemplateBase() { |
86 | } | 86 | } |
87 | virtual T find( int uid )const = 0; | 87 | virtual T find( int uid )const = 0; |
88 | 88 | ||
89 | /** | 89 | /** |
90 | * read ahead find | 90 | * read ahead find |
91 | */ | 91 | */ |
92 | virtual T find( int uid, const QArray<int>& items, | 92 | virtual T find( int uid, const QArray<int>& items, |
93 | uint current, CacheDirection dir = Forward )const = 0; | 93 | uint current, CacheDirection dir = Forward )const = 0; |
94 | 94 | ||
95 | /** | 95 | /** |
96 | * Find in Cache.. | ||
97 | * Returns empty object if nothing found. | ||
98 | */ | ||
99 | virtual T cacheFind( int uid )const = 0; | ||
100 | |||
101 | /** | ||
102 | * Put element into Cache | 96 | * Put element into Cache |
103 | */ | 97 | */ |
104 | virtual void cache( const T& )const = 0; | 98 | virtual void cache( const T& )const = 0; |
105 | virtual void setSaneCacheSize( int ) = 0; | 99 | virtual void setSaneCacheSize( int ) = 0; |
106 | 100 | ||
107 | OPimRecord* record()const; | 101 | OPimRecord* record()const; |
108 | OPimRecord* record(int uid )const; | 102 | OPimRecord* record(int uid )const; |
109 | static T* rec(); | 103 | static T* rec(); |
110 | 104 | ||
111 | 105 | ||
112 | private: | 106 | private: |
113 | OTemplateBasePrivate *d; | 107 | OTemplateBasePrivate *d; |
114 | }; | 108 | }; |
115 | 109 | ||
116 | 110 | ||
117 | template <class T> | 111 | template <class T> |
118 | OPimRecord* OTemplateBase<T>::record()const { | 112 | OPimRecord* OTemplateBase<T>::record()const { |
119 | T* t = new T; | 113 | T* t = new T; |
120 | return t; | 114 | return t; |
121 | } | 115 | } |
122 | template <class T> | 116 | template <class T> |
123 | OPimRecord* OTemplateBase<T>::record(int uid )const { | 117 | OPimRecord* OTemplateBase<T>::record(int uid )const { |
124 | T t2 = find(uid ); | 118 | T t2 = find(uid ); |
125 | T* t1 = new T(t2); | 119 | T* t1 = new T(t2); |