opimaccessbackend.h
Go to the documentation of this file.00001 #ifndef OPIE_PIM_ACCESS_BACKEND 00002 #define OPIE_PIM_ACCESS_BACKEND 00003 00004 #include <qarray.h> 00005 #include <qdatetime.h> 00006 00007 #include <opie/otemplatebase.h> 00008 #include <opie/opimrecord.h> 00009 00010 00011 class OPimAccessBackendPrivate; 00020 template <class T = OPimRecord> 00021 class OPimAccessBackend { 00022 public: 00023 typedef OTemplateBase<T> Frontend; 00024 00026 OPimAccessBackend(int access = 0); 00027 virtual ~OPimAccessBackend(); 00028 00032 virtual bool load() = 0; 00033 00037 virtual bool reload() = 0; 00038 00043 virtual bool save() = 0; 00044 00049 virtual QArray<int> allRecords()const = 0; 00050 00055 virtual QArray<int> matchRegexp(const QRegExp &r) const = 0; 00056 00061 virtual QArray<int> queryByExample( const T& t, int settings, const QDateTime& d = QDateTime() ) = 0; 00062 00067 virtual T find(int uid )const = 0; 00068 00069 virtual T find(int uid, const QArray<int>& items, 00070 uint current, typename Frontend::CacheDirection )const ; 00074 virtual void clear() = 0; 00075 00079 virtual bool add( const T& t ) = 0; 00080 00084 virtual bool remove( int uid ) = 0; 00085 00089 virtual bool replace( const T& t ) = 0; 00090 00091 /* 00092 * setTheFrontEnd!!! 00093 */ 00094 void setFrontend( Frontend* front ); 00095 00099 void setReadAhead( uint count ); 00100 protected: 00101 int access()const; 00102 void cache( const T& t )const; 00103 00107 void setSaneCacheSize( int ); 00108 00109 uint readAhead()const; 00110 00111 private: 00112 OPimAccessBackendPrivate *d; 00113 Frontend* m_front; 00114 uint m_read; 00115 int m_acc; 00116 00117 }; 00118 00119 template <class T> 00120 OPimAccessBackend<T>::OPimAccessBackend(int acc) 00121 : m_acc( acc ) 00122 { 00123 m_front = 0l; 00124 } 00125 template <class T> 00126 OPimAccessBackend<T>::~OPimAccessBackend() { 00127 00128 } 00129 template <class T> 00130 void OPimAccessBackend<T>::setFrontend( Frontend* fr ) { 00131 m_front = fr; 00132 } 00133 template <class T> 00134 void OPimAccessBackend<T>::cache( const T& t )const { 00135 if (m_front ) 00136 m_front->cache( t ); 00137 } 00138 template <class T> 00139 void OPimAccessBackend<T>::setSaneCacheSize( int size) { 00140 if (m_front ) 00141 m_front->setSaneCacheSize( size ); 00142 } 00143 template <class T> 00144 T OPimAccessBackend<T>::find( int uid, const QArray<int>&, 00145 uint, typename Frontend::CacheDirection )const { 00146 return find( uid ); 00147 } 00148 template <class T> 00149 void OPimAccessBackend<T>::setReadAhead( uint count ) { 00150 m_read = count; 00151 } 00152 template <class T> 00153 uint OPimAccessBackend<T>::readAhead()const { 00154 return m_read; 00155 } 00156 template <class T> 00157 int OPimAccessBackend<T>::access()const { 00158 return m_acc; 00159 } 00160 #endif
