From ea3945a9bd8f9830f70b1efa133f9df13b19362f Mon Sep 17 00:00:00 2001 From: mickeyl Date: Tue, 16 Nov 2004 19:14:18 +0000 Subject: libopie1 goes into unsupported --- (limited to 'noncore/unsupported/libopie/pim/opimaccessbackend.h') diff --git a/noncore/unsupported/libopie/pim/opimaccessbackend.h b/noncore/unsupported/libopie/pim/opimaccessbackend.h new file mode 100644 index 0000000..fd264fc --- a/dev/null +++ b/noncore/unsupported/libopie/pim/opimaccessbackend.h @@ -0,0 +1,160 @@ +#ifndef OPIE_PIM_ACCESS_BACKEND +#define OPIE_PIM_ACCESS_BACKEND + +#include +#include + +#include +#include + + +class OPimAccessBackendPrivate; +/** + * OPimAccessBackend is the base class + * for all private backends + * it operates on OPimRecord as the base class + * and it's responsible for fast manipulating + * the resource the implementation takes care + * of + */ +template +class OPimAccessBackend { +public: + typedef OTemplateBase Frontend; + + /** The access hint from the frontend */ + OPimAccessBackend(int access = 0); + virtual ~OPimAccessBackend(); + + /** + * load the resource + */ + virtual bool load() = 0; + + /** + * reload the resource + */ + virtual bool reload() = 0; + + /** + * save the resource and + * all it's changes + */ + virtual bool save() = 0; + + /** + * return an array of + * all available uids + */ + virtual QArray allRecords()const = 0; + + /** + * return a List of records + * that match the regex + */ + virtual QArray matchRegexp(const QRegExp &r) const = 0; + + /** + * queryByExample for T with the given Settings + * + */ + virtual QArray queryByExample( const T& t, int settings, const QDateTime& d = QDateTime() ) = 0; + + /** + * find the OPimRecord with uid @param uid + * returns T and T.isEmpty() if nothing was found + */ + virtual T find(int uid )const = 0; + + virtual T find(int uid, const QArray& items, + uint current, typename Frontend::CacheDirection )const ; + /** + * clear the back end + */ + virtual void clear() = 0; + + /** + * add T + */ + virtual bool add( const T& t ) = 0; + + /** + * remove + */ + virtual bool remove( int uid ) = 0; + + /** + * replace a record with T.uid() + */ + virtual bool replace( const T& t ) = 0; + + /* + * setTheFrontEnd!!! + */ + void setFrontend( Frontend* front ); + + /** + * set the read ahead count + */ + void setReadAhead( uint count ); +protected: + int access()const; + void cache( const T& t )const; + + /** + * use a prime number here! + */ + void setSaneCacheSize( int ); + + uint readAhead()const; + +private: + OPimAccessBackendPrivate *d; + Frontend* m_front; + uint m_read; + int m_acc; + +}; + +template +OPimAccessBackend::OPimAccessBackend(int acc) + : m_acc( acc ) +{ + m_front = 0l; +} +template +OPimAccessBackend::~OPimAccessBackend() { + +} +template +void OPimAccessBackend::setFrontend( Frontend* fr ) { + m_front = fr; +} +template +void OPimAccessBackend::cache( const T& t )const { + if (m_front ) + m_front->cache( t ); +} +template +void OPimAccessBackend::setSaneCacheSize( int size) { + if (m_front ) + m_front->setSaneCacheSize( size ); +} +template +T OPimAccessBackend::find( int uid, const QArray&, + uint, typename Frontend::CacheDirection )const { + return find( uid ); +} +template +void OPimAccessBackend::setReadAhead( uint count ) { + m_read = count; +} +template +uint OPimAccessBackend::readAhead()const { + return m_read; +} +template +int OPimAccessBackend::access()const { + return m_acc; +} +#endif -- cgit v0.9.0.2