summaryrefslogtreecommitdiff
path: root/libopie2/opiepim/core
Unidiff
Diffstat (limited to 'libopie2/opiepim/core') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiepim/core/opimaccesstemplate.h40
-rw-r--r--libopie2/opiepim/core/opimtemplatebase.h16
2 files changed, 45 insertions, 11 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
@@ -37,3 +37,2 @@
37 37
38#include <opie2/opimcache.h>
39#include <opie2/opimtemplatebase.h> 38#include <opie2/opimtemplatebase.h>
@@ -130,2 +129,3 @@ public:
130 129
130
131 /* invalidate cache here */ 131 /* invalidate cache here */
@@ -141,9 +141,11 @@ public:
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* );
@@ -178,2 +180,3 @@ public:
178 */ 180 */
181 virtual T cacheFind( int uid )const;
179 void cache( const T& )const; 182 void cache( const T& )const;
@@ -194,2 +197,3 @@ protected:
194 BackEnd* m_backEnd; 197 BackEnd* m_backEnd;
198
195 Cache m_cache; 199 Cache m_cache;
@@ -220,3 +224,3 @@ template <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();
@@ -253,6 +257,18 @@ template <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>
@@ -266,3 +282,3 @@ T OPimAccessTemplate<T>::find( int uid, const QArray<int>& ar,
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 );
@@ -286,3 +302,3 @@ bool OPimAccessTemplate<T>::add( const T& t ) {
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 */
@@ -292,2 +308,4 @@ bool OPimAccessTemplate<T>::add( const OPimRecord& rec) {
292 return add(t); 308 return add(t);
309 } else {
310 owarn << "Adding not possible: Objecttype mismatch" << oendl;
293 } 311 }
@@ -303,2 +321,4 @@ bool OPimAccessTemplate<T>::add( const OPimRecord* rec) {
303 return add( *t ); 321 return add( *t );
322 } else {
323 owarn << "Adding not possible: Objecttype mismatch" << oendl;
304 } 324 }
diff --git a/libopie2/opiepim/core/opimtemplatebase.h b/libopie2/opiepim/core/opimtemplatebase.h
index b48dfed..ec9a94e 100644
--- a/libopie2/opiepim/core/opimtemplatebase.h
+++ b/libopie2/opiepim/core/opimtemplatebase.h
@@ -33,2 +33,3 @@
33#include <opie2/opimrecord.h> 33#include <opie2/opimrecord.h>
34#include <opie2/opimcache.h>
34 35
@@ -72,3 +73,3 @@ private:
72 * internal template base 73 * internal template base
73 * T needs to implement the copy c'tor!!! 74 * Attention: T needs to implement the copy c'tor!!!
74 */ 75 */
@@ -78,3 +79,5 @@ class OTemplateBase : public OPimBase {
78public: 79public:
80 /** Look ahead direction of cache */
79 enum CacheDirection { Forward=0, Reverse }; 81 enum CacheDirection { Forward=0, Reverse };
82
80 OTemplateBase() { 83 OTemplateBase() {
@@ -90,2 +93,12 @@ public:
90 uint current, CacheDirection dir = Forward )const = 0; 93 uint current, CacheDirection dir = Forward )const = 0;
94
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
103 */
91 virtual void cache( const T& )const = 0; 104 virtual void cache( const T& )const = 0;
@@ -96,2 +109,3 @@ public:
96 static T* rec(); 109 static T* rec();
110
97 111