summaryrefslogtreecommitdiff
path: root/libopie2/opiepim/backend/opimaccessbackend.h
Unidiff
Diffstat (limited to 'libopie2/opiepim/backend/opimaccessbackend.h') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiepim/backend/opimaccessbackend.h22
1 files changed, 3 insertions, 19 deletions
diff --git a/libopie2/opiepim/backend/opimaccessbackend.h b/libopie2/opiepim/backend/opimaccessbackend.h
index 15a7b7f..26af762 100644
--- a/libopie2/opiepim/backend/opimaccessbackend.h
+++ b/libopie2/opiepim/backend/opimaccessbackend.h
@@ -84,27 +84,27 @@ public:
84 virtual QArray<int> matchRegexp(const QRegExp &r) const = 0; 84 virtual QArray<int> matchRegexp(const QRegExp &r) const = 0;
85 85
86 /** 86 /**
87 * queryByExample for T with the given Settings 87 * queryByExample for T with the given Settings
88 * 88 *
89 */ 89 */
90 virtual QArray<int> queryByExample( const T& t, int settings, const QDateTime& d = QDateTime() ) = 0; 90 virtual QArray<int> queryByExample( const T& t, int settings, const QDateTime& d = QDateTime() ) = 0;
91 91
92 /** 92 /**
93 * find the OPimRecord with uid @param uid 93 * find the OPimRecord with uid @param uid
94 * returns T and T.isEmpty() if nothing was found 94 * returns T and T.isEmpty() if nothing was found
95 */ 95 */
96 virtual T find(int uid )const = 0; 96 virtual T find( int uid )const = 0;
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
102 */ 102 */
103 virtual void clear() = 0; 103 virtual void clear() = 0;
104 104
105 /** 105 /**
106 * add T 106 * add T
107 */ 107 */
108 virtual bool add( const T& t ) = 0; 108 virtual bool add( const T& t ) = 0;
109 109
110 /** 110 /**
@@ -122,31 +122,24 @@ public:
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 );
129protected: 129protected:
130 int access()const; 130 int access()const;
131 131
132 void cache( const T& t )const; 132 void cache( const T& t )const;
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 /**
142 * use a prime number here! 135 * use a prime number here!
143 */ 136 */
144 void setSaneCacheSize( int ); 137 void setSaneCacheSize( int );
145 138
146 uint readAhead()const; 139 uint readAhead()const;
147 140
148private: 141private:
149 OPimAccessBackendPrivate *d; 142 OPimAccessBackendPrivate *d;
150 Frontend* m_front; 143 Frontend* m_front;
151 uint m_read; 144 uint m_read;
152 int m_acc; 145 int m_acc;
@@ -164,43 +157,34 @@ OPimAccessBackend<T>::~OPimAccessBackend() {
164 157
165} 158}
166template <class T> 159template <class T>
167void OPimAccessBackend<T>::setFrontend( Frontend* fr ) { 160void OPimAccessBackend<T>::setFrontend( Frontend* fr ) {
168 m_front = fr; 161 m_front = fr;
169} 162}
170template <class T> 163template <class T>
171void OPimAccessBackend<T>::cache( const T& t )const { 164void OPimAccessBackend<T>::cache( const T& t )const {
172 if ( m_front ) 165 if ( m_front )
173 m_front->cache( t ); 166 m_front->cache( t );
174} 167}
175 168
176template <class T>
177T 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 169
186template <class T> 170template <class T>
187void OPimAccessBackend<T>::setSaneCacheSize( int size) { 171void OPimAccessBackend<T>::setSaneCacheSize( int size) {
188 if ( m_front ) 172 if ( m_front )
189 m_front->setSaneCacheSize( size ); 173 m_front->setSaneCacheSize( size );
190} 174}
191template <class T> 175template <class T>
192T OPimAccessBackend<T>::find( int uid, const QArray<int>&, 176T OPimAccessBackend<T>::find( int uid, const QArray<int>&,
193 uint, typename Frontend::CacheDirection ) const{ 177 uint, typename Frontend::CacheDirection ) const{
194 qDebug( "*** Lookahead feature not supported. Fallback to default find!" ); 178 qDebug( "*** Lookahead feature not supported. Fallback to default find!!" );
195 return find( uid ); 179 return find( uid );
196} 180}
197template <class T> 181template <class T>
198void OPimAccessBackend<T>::setReadAhead( uint count ) { 182void OPimAccessBackend<T>::setReadAhead( uint count ) {
199 m_read = count; 183 m_read = count;
200} 184}
201template <class T> 185template <class T>
202uint OPimAccessBackend<T>::readAhead()const { 186uint OPimAccessBackend<T>::readAhead()const {
203 return m_read; 187 return m_read;
204} 188}
205template <class T> 189template <class T>
206int OPimAccessBackend<T>::access()const { 190int OPimAccessBackend<T>::access()const {