Diffstat (limited to 'libopie2/opiepim/backend/opimaccessbackend.h') (more/less context) (show whitespace changes)
-rw-r--r-- | libopie2/opiepim/backend/opimaccessbackend.h | 20 |
1 files changed, 20 insertions, 0 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 | |||
@@ -119,27 +119,35 @@ public: | |||
119 | 119 | ||
120 | /* | 120 | /* |
121 | * setTheFrontEnd!!! | 121 | * setTheFrontEnd!!! |
122 | */ | 122 | */ |
123 | void setFrontend( Frontend* front ); | 123 | void setFrontend( Frontend* front ); |
124 | 124 | ||
125 | /** | 125 | /** |
126 | * set the read ahead count | 126 | * set the read ahead count |
127 | */ | 127 | */ |
128 | void setReadAhead( uint count ); | 128 | void setReadAhead( uint count ); |
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 | ||
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 | |||
141 | /** | ||
134 | * use a prime number here! | 142 | * use a prime number here! |
135 | */ | 143 | */ |
136 | void setSaneCacheSize( int ); | 144 | void setSaneCacheSize( int ); |
137 | 145 | ||
138 | uint readAhead()const; | 146 | uint readAhead()const; |
139 | 147 | ||
140 | private: | 148 | private: |
141 | OPimAccessBackendPrivate *d; | 149 | OPimAccessBackendPrivate *d; |
142 | Frontend* m_front; | 150 | Frontend* m_front; |
143 | uint m_read; | 151 | uint m_read; |
144 | int m_acc; | 152 | int m_acc; |
145 | 153 | ||
@@ -155,32 +163,44 @@ template <class T> | |||
155 | OPimAccessBackend<T>::~OPimAccessBackend() { | 163 | OPimAccessBackend<T>::~OPimAccessBackend() { |
156 | 164 | ||
157 | } | 165 | } |
158 | template <class T> | 166 | template <class T> |
159 | void OPimAccessBackend<T>::setFrontend( Frontend* fr ) { | 167 | void OPimAccessBackend<T>::setFrontend( Frontend* fr ) { |
160 | m_front = fr; | 168 | m_front = fr; |
161 | } | 169 | } |
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 | } |
177 | template <class T> | 197 | template <class T> |
178 | void OPimAccessBackend<T>::setReadAhead( uint count ) { | 198 | void OPimAccessBackend<T>::setReadAhead( uint count ) { |
179 | m_read = count; | 199 | m_read = count; |
180 | } | 200 | } |
181 | template <class T> | 201 | template <class T> |
182 | uint OPimAccessBackend<T>::readAhead()const { | 202 | uint OPimAccessBackend<T>::readAhead()const { |
183 | return m_read; | 203 | return m_read; |
184 | } | 204 | } |
185 | template <class T> | 205 | template <class T> |
186 | int OPimAccessBackend<T>::access()const { | 206 | int OPimAccessBackend<T>::access()const { |