summaryrefslogtreecommitdiff
path: root/libopie2/opiepim/backend/opimaccessbackend.h
authoreilers <eilers>2004-08-29 12:50:18 (UTC)
committer eilers <eilers>2004-08-29 12:50:18 (UTC)
commit679d9fef2673eea18fe5d9c85df2b10b09a8a250 (patch) (side-by-side diff)
tree8b3d6dbef45568be6f5daac31094d6e599fdefdf /libopie2/opiepim/backend/opimaccessbackend.h
parent45327ef3c0f093fc227682f79158632afc09e6d1 (diff)
downloadopie-679d9fef2673eea18fe5d9c85df2b10b09a8a250.zip
opie-679d9fef2673eea18fe5d9c85df2b10b09a8a250.tar.gz
opie-679d9fef2673eea18fe5d9c85df2b10b09a8a250.tar.bz2
Added lookahead caching for addressbook (SQL-only) for speed improvement.
Diffstat (limited to 'libopie2/opiepim/backend/opimaccessbackend.h') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiepim/backend/opimaccessbackend.h28
1 files changed, 24 insertions, 4 deletions
diff --git a/libopie2/opiepim/backend/opimaccessbackend.h b/libopie2/opiepim/backend/opimaccessbackend.h
index 0682063..15a7b7f 100644
--- a/libopie2/opiepim/backend/opimaccessbackend.h
+++ b/libopie2/opiepim/backend/opimaccessbackend.h
@@ -96,7 +96,7 @@ public:
virtual T find(int uid )const = 0;
virtual T find(int uid, const QArray<int>& items,
- uint current, typename Frontend::CacheDirection )const ;
+ uint current, typename Frontend::CacheDirection ) const;
/**
* clear the back end
*/
@@ -128,8 +128,16 @@ public:
void setReadAhead( uint count );
protected:
int access()const;
+
void cache( const T& t )const;
+ /**
+ * Returns the element with given uid out of the cache.
+ * Returns empty element if nothing was found.
+ * <b>Attention:</b> This just works if we have a frontend which contains the cache !
+ */
+ T cacheFind( int uid ) const;
+
/**
* use a prime number here!
*/
@@ -161,17 +169,29 @@ void OPimAccessBackend<T>::setFrontend( Frontend* fr ) {
}
template <class T>
void OPimAccessBackend<T>::cache( const T& t )const {
- if (m_front )
+ if ( m_front )
m_front->cache( t );
}
+
+template <class T>
+T OPimAccessBackend<T>::cacheFind( int uid )const {
+ if ( ! m_front ){
+ qWarning ( "No frontend assigned ! Therefore we cannot access the cache to return the right element!" );
+ return T();
+ }
+
+ return m_front->cacheFind( uid );
+}
+
template <class T>
void OPimAccessBackend<T>::setSaneCacheSize( int size) {
- if (m_front )
+ if ( m_front )
m_front->setSaneCacheSize( size );
}
template <class T>
T OPimAccessBackend<T>::find( int uid, const QArray<int>&,
- uint, typename Frontend::CacheDirection )const {
+ uint, typename Frontend::CacheDirection ) const{
+ qDebug( "*** Lookahead feature not supported. Fallback to default find!" );
return find( uid );
}
template <class T>