Diffstat (limited to 'libopie/pim/opimaccesstemplate.h') (more/less context) (ignore whitespace changes)
-rw-r--r-- | libopie/pim/opimaccesstemplate.h | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/libopie/pim/opimaccesstemplate.h b/libopie/pim/opimaccesstemplate.h index 8cf81c8..259e2c1 100644 --- a/libopie/pim/opimaccesstemplate.h +++ b/libopie/pim/opimaccesstemplate.h @@ -21,22 +21,28 @@ template <class T = OPimRecord > class OPimAccessTemplate : public OTemplateBase<T> { public: + enum Access { + Random = 0, + SortedAccess + }; typedef ORecordList<T> List; typedef OPimAccessBackend<T> BackEnd; typedef OPimCache<T> Cache; /** * c'tor BackEnd + * enum Access a small hint on how to handle the backend */ OPimAccessTemplate( BackEnd* end); + virtual ~OPimAccessTemplate(); /** * load from the backend */ - virtual bool load(); + bool load(); /** Reload database. * You should execute this function if the external database * was changed. @@ -48,9 +54,9 @@ public: /** Save contacts database. * Save is more a "commit". After calling this function, all changes are public available. * @return true if successful */ - virtual bool save(); + bool save(); /** * if the resource was changed externally * You should use the signal handling instead of polling possible changes ! @@ -84,9 +90,9 @@ public: /* invalidate cache here */ /** * clears the backend and invalidates the backend */ - virtual void clear() ; + void clear() ; /** * add T to the backend * @param t The item to add. @@ -107,9 +113,10 @@ public: * remove the OPimRecord with uid * @param uid The ID of the item to remove * @return <i>true</i> if successful. */ - virtual bool remove( int uid ); + bool remove( int uid ); + bool remove( const OPimRecord& ); /** * replace T from backend * @param t The item to replace @@ -122,8 +129,10 @@ public: * @internal */ void cache( const T& )const; void setSaneCacheSize( int ); + + QArray<int> records()const; protected: /** * invalidate the cache */ @@ -171,8 +180,12 @@ typename OPimAccessTemplate<T>::List OPimAccessTemplate<T>::allRecords()const { List lis(ints, this ); return lis; } template <class T> +QArray<int> OPimAccessTemplate<T>::records()const { + return m_backEnd->allRecords(); +} +template <class T> typename OPimAccessTemplate<T>::List OPimAccessTemplate<T>::queryByExample( const T& t, int sortOrder ) { QArray<int> ints = m_backEnd->queryByExample( t, sortOrder ); @@ -230,8 +243,12 @@ bool OPimAccessTemplate<T>::remove( int uid ) { m_cache.remove( uid ); return m_backEnd->remove( uid ); } template <class T> +bool OPimAccessTemplate<T>::remove( const OPimRecord& rec) { + return remove( rec.uid() ); +} +template <class T> bool OPimAccessTemplate<T>::replace( const T& t ) { m_cache.replace( t ); return m_backEnd->replace( t ); } |