summaryrefslogtreecommitdiff
path: root/libopie2/opiepim/core/opimaccesstemplate.h
Unidiff
Diffstat (limited to 'libopie2/opiepim/core/opimaccesstemplate.h') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiepim/core/opimaccesstemplate.h40
1 files changed, 30 insertions, 10 deletions
diff --git a/libopie2/opiepim/core/opimaccesstemplate.h b/libopie2/opiepim/core/opimaccesstemplate.h
index 55d600a..6f01b46 100644
--- a/libopie2/opiepim/core/opimaccesstemplate.h
+++ b/libopie2/opiepim/core/opimaccesstemplate.h
@@ -36,5 +36,4 @@
36#include <opie2/opimrecordlist.h> 36#include <opie2/opimrecordlist.h>
37 37
38#include <opie2/opimcache.h>
39#include <opie2/opimtemplatebase.h> 38#include <opie2/opimtemplatebase.h>
40#include <opie2/odebug.h> 39#include <opie2/odebug.h>
@@ -129,4 +128,5 @@ public:
129 uint current, typename OTemplateBase<T>::CacheDirection dir = OTemplateBase<T>::Forward )const; 128 uint current, typename OTemplateBase<T>::CacheDirection dir = OTemplateBase<T>::Forward )const;
130 129
130
131 /* invalidate cache here */ 131 /* invalidate cache here */
132 /** 132 /**
@@ -140,11 +140,13 @@ public:
140 * @return <i>true</i> if added successfully. 140 * @return <i>true</i> if added successfully.
141 */ 141 */
142 virtual bool add( const T& t ) ; 142 virtual bool add( const T& t ) ;
143
143 bool add( const OPimRecord& ); 144 bool add( const OPimRecord& );
144 // Needed for real generic access (eilers) 145 /**
145 // Info: Take this if you are working with OPimRecord, which is a generic base class, and 146 * Add an Opie PimRecord.
146 // you need to add it into any database, you cannot generate a reference to 147 * Info: Take this if you are working with OPimRecords and you need to add it into any database.
147 // it and casting may be not approriate, too. 148 * But take care that the accessing database is compatible to the real type of OPimRecord !!
148 // But take care that the accessing database is compatible to the real type of OPimRecord !! 149 * Otherwise this access will be rejected !
150 */
149 bool add( const OPimRecord* ); 151 bool add( const OPimRecord* );
150 152
@@ -177,4 +179,5 @@ public:
177 * @internal 179 * @internal
178 */ 180 */
181 virtual T cacheFind( int uid )const;
179 void cache( const T& )const; 182 void cache( const T& )const;
180 void setSaneCacheSize( int ); 183 void setSaneCacheSize( int );
@@ -193,4 +196,5 @@ protected:
193 BackEnd* backEnd(); 196 BackEnd* backEnd();
194 BackEnd* m_backEnd; 197 BackEnd* m_backEnd;
198
195 Cache m_cache; 199 Cache m_cache;
196 200
@@ -219,5 +223,5 @@ bool OPimAccessTemplate<T>::load() {
219template <class T> 223template <class T>
220bool OPimAccessTemplate<T>::reload() { 224bool OPimAccessTemplate<T>::reload() {
221 invalidateCache(); // zecke: I think this should be added (se) 225 invalidateCache();
222 return m_backEnd->reload(); 226 return m_backEnd->reload();
223} 227}
@@ -252,8 +256,20 @@ OPimAccessTemplate<T>::queryByExample( const T& t, int settings, const QDateTime
252template <class T> 256template <class T>
253T OPimAccessTemplate<T>::find( int uid ) const{ 257T OPimAccessTemplate<T>::find( int uid ) const{
258 // First search in cache..
259 if ( m_cache.contains( uid ) )
260 return m_cache.find( uid );
261
254 T t = m_backEnd->find( uid ); 262 T t = m_backEnd->find( uid );
255 cache( t ); 263 cache( t );
264
256 return t; 265 return t;
257} 266}
267
268template <class T>
269T OPimAccessTemplate<T>::cacheFind( int uid ) const
270{
271 return m_cache.find( uid );
272}
273
258template <class T> 274template <class T>
259T OPimAccessTemplate<T>::find( int uid, const QArray<int>& ar, 275T OPimAccessTemplate<T>::find( int uid, const QArray<int>& ar,
@@ -265,5 +281,5 @@ T OPimAccessTemplate<T>::find( int uid, const QArray<int>& ar,
265 */ 281 */
266 // owarn << "find it now " << uid << oendl; 282 // owarn << "find it now " << uid << oendl;
267 if (m_cache.contains( uid ) ) { 283 if ( m_cache.contains( uid ) ) {
268 return m_cache.find( uid ); 284 return m_cache.find( uid );
269 } 285 }
@@ -285,5 +301,5 @@ bool OPimAccessTemplate<T>::add( const T& t ) {
285 301
286template <class T> 302template <class T>
287bool OPimAccessTemplate<T>::add( const OPimRecord& rec) { 303bool OPimAccessTemplate<T>::add( const OPimRecord& rec ) {
288 /* same type */ 304 /* same type */
289 T tempInstance; 305 T tempInstance;
@@ -291,4 +307,6 @@ bool OPimAccessTemplate<T>::add( const OPimRecord& rec) {
291 const T& t = static_cast<const T&>(rec); 307 const T& t = static_cast<const T&>(rec);
292 return add(t); 308 return add(t);
309 } else {
310 owarn << "Adding not possible: Objecttype mismatch" << oendl;
293 } 311 }
294 return false; 312 return false;
@@ -302,4 +320,6 @@ bool OPimAccessTemplate<T>::add( const OPimRecord* rec) {
302 const T* t = static_cast<const T*>(rec); 320 const T* t = static_cast<const T*>(rec);
303 return add( *t ); 321 return add( *t );
322 } else {
323 owarn << "Adding not possible: Objecttype mismatch" << oendl;
304 } 324 }
305 return false; 325 return false;