author | eilers <eilers> | 2004-08-29 12:50:18 (UTC) |
---|---|---|
committer | eilers <eilers> | 2004-08-29 12:50:18 (UTC) |
commit | 679d9fef2673eea18fe5d9c85df2b10b09a8a250 (patch) (unidiff) | |
tree | 8b3d6dbef45568be6f5daac31094d6e599fdefdf /libopie2/opiepim/backend/opimaccessbackend.h | |
parent | 45327ef3c0f093fc227682f79158632afc09e6d1 (diff) | |
download | opie-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.h | 28 |
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 | |||
@@ -97,5 +97,5 @@ public: | |||
97 | 97 | ||
98 | virtual T find(int uid, const QArray<int>& items, | 98 | virtual T find(int uid, const QArray<int>& items, |
99 | uint current, typename Frontend::CacheDirection )const ; | 99 | uint current, typename Frontend::CacheDirection ) const; |
100 | /** | 100 | /** |
101 | * clear the back end | 101 | * clear the back end |
@@ -129,6 +129,14 @@ public: | |||
129 | protected: | 129 | protected: |
130 | int access()const; | 130 | int access()const; |
131 | |||
131 | void cache( const T& t )const; | 132 | void cache( const T& t )const; |
132 | 133 | ||
134 | /** | ||
135 | * Returns the element with given uid out of the cache. | ||
136 | * Returns empty element if nothing was found. | ||
137 | * <b>Attention:</b> This just works if we have a frontend which contains the cache ! | ||
138 | */ | ||
139 | T cacheFind( int uid ) const; | ||
140 | |||
133 | /** | 141 | /** |
134 | * use a prime number here! | 142 | * use a prime number here! |
@@ -162,15 +170,27 @@ void OPimAccessBackend<T>::setFrontend( Frontend* fr ) { | |||
162 | template <class T> | 170 | template <class T> |
163 | void OPimAccessBackend<T>::cache( const T& t )const { | 171 | void OPimAccessBackend<T>::cache( const T& t )const { |
164 | if (m_front ) | 172 | if ( m_front ) |
165 | m_front->cache( t ); | 173 | m_front->cache( t ); |
166 | } | 174 | } |
175 | |||
176 | template <class T> | ||
177 | T OPimAccessBackend<T>::cacheFind( int uid )const { | ||
178 | if ( ! m_front ){ | ||
179 | qWarning ( "No frontend assigned ! Therefore we cannot access the cache to return the right element!" ); | ||
180 | return T(); | ||
181 | } | ||
182 | |||
183 | return m_front->cacheFind( uid ); | ||
184 | } | ||
185 | |||
167 | template <class T> | 186 | template <class T> |
168 | void OPimAccessBackend<T>::setSaneCacheSize( int size) { | 187 | void OPimAccessBackend<T>::setSaneCacheSize( int size) { |
169 | if (m_front ) | 188 | if ( m_front ) |
170 | m_front->setSaneCacheSize( size ); | 189 | m_front->setSaneCacheSize( size ); |
171 | } | 190 | } |
172 | template <class T> | 191 | template <class T> |
173 | T OPimAccessBackend<T>::find( int uid, const QArray<int>&, | 192 | T OPimAccessBackend<T>::find( int uid, const QArray<int>&, |
174 | uint, typename Frontend::CacheDirection )const { | 193 | uint, typename Frontend::CacheDirection ) const{ |
194 | qDebug( "*** Lookahead feature not supported. Fallback to default find!" ); | ||
175 | return find( uid ); | 195 | return find( uid ); |
176 | } | 196 | } |