summaryrefslogtreecommitdiff
path: root/libopie/pim/opimaccesstemplate.h
authorzecke <zecke>2002-12-10 17:01:18 (UTC)
committer zecke <zecke>2002-12-10 17:01:18 (UTC)
commit4ecbf7407c19b59fc136c334f9386c53db453930 (patch) (side-by-side diff)
tree1cba438e2533f7109af169b0b77988cec6664192 /libopie/pim/opimaccesstemplate.h
parent36375df6ff103e52455823f7afd64c4f4ae7fcb8 (diff)
downloadopie-4ecbf7407c19b59fc136c334f9386c53db453930.zip
opie-4ecbf7407c19b59fc136c334f9386c53db453930.tar.gz
opie-4ecbf7407c19b59fc136c334f9386c53db453930.tar.bz2
get in sync with HEAD again
-OPimBase was added to be used as a default struct inside OPimResolver and to work with DSOs -TodoListXML backend now uses mmap and madvise to load data -OContact added/changed rtti -OTodo added changed rtti OPimAccess* added stuff necessary for the Resolver and a 'state'/'hint' on how to load data OPimResolver which resolves uid + services to Records, rtti to QCOPChannels loads arbitary Service backends ( will work with DSOs soon ) -OPimMainWindow added some setDocument scripting possibility and internal marshalling and demarshalling of Records -OPimRecord added loadDataFromm and saveDataTo for marshalling purposes much more :)
Diffstat (limited to 'libopie/pim/opimaccesstemplate.h') (more/less context) (show whitespace changes)
-rw-r--r--libopie/pim/opimaccesstemplate.h25
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
@@ -19,26 +19,32 @@
* the plugins
*/
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.
* This function will load the external database and afterwards
* rejoin the local changes. Therefore the local database will be set consistent.
@@ -46,13 +52,13 @@ public:
virtual bool reload();
/** 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 !
* zecke: Do you implement a signal for otodoaccess ?
*/
@@ -82,13 +88,13 @@ public:
uint current, typename OTemplateBase<T>::CacheDirection dir = OTemplateBase<T>::Forward )const;
/* 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.
* @return <i>true</i> if added successfully.
*/
@@ -105,13 +111,14 @@ 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
* @return <i>true</i> if successful.
*/
@@ -120,12 +127,14 @@ public:
void setReadAhead( uint count );
/**
* @internal
*/
void cache( const T& )const;
void setSaneCacheSize( int );
+
+ QArray<int> records()const;
protected:
/**
* invalidate the cache
*/
void invalidateCache();
@@ -169,12 +178,16 @@ template <class T>
typename OPimAccessTemplate<T>::List OPimAccessTemplate<T>::allRecords()const {
QArray<int> ints = m_backEnd->allRecords();
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 );
List lis(ints, this );
return lis;
@@ -228,12 +241,16 @@ bool OPimAccessTemplate<T>::remove( const T& t ) {
template <class T>
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 );
}
template <class T>
void OPimAccessTemplate<T>::invalidateCache() {