summaryrefslogtreecommitdiff
path: root/libopie/pim/otemplatebase.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/otemplatebase.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/otemplatebase.h') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/pim/otemplatebase.h63
1 files changed, 61 insertions, 2 deletions
diff --git a/libopie/pim/otemplatebase.h b/libopie/pim/otemplatebase.h
index b855919..29fb6ec 100644
--- a/libopie/pim/otemplatebase.h
+++ b/libopie/pim/otemplatebase.h
@@ -4,11 +4,41 @@
#include <qarray.h>
-#include "opimrecord.h"
+#include <opie/opimrecord.h>
+
/**
+ * Templates do not have a base class, This is why
+ * we've this class
+ * this is here to give us the possibility
+ * to have a common base class
+ * You may not want to use that interface internaly
+ * POOR mans interface
+ */
+struct OPimBase {
+ /**
+ * return the rtti
+ */
+ virtual int rtti()= 0;
+ virtual OPimRecord* record()const = 0;
+ virtual OPimRecord* record(int uid)const = 0;
+ virtual bool add( const OPimRecord& ) = 0;
+ virtual bool remove( int uid ) = 0;
+ virtual bool remove( const OPimRecord& ) = 0;
+ virtual void clear() = 0;
+ virtual bool load() = 0;
+ virtual bool save() = 0;
+ virtual QArray<int> records()const = 0;
+ /*
+ * ADD editing here?
+ * -zecke
+ */
+
+};
+/**
* internal template base
+ * T needs to implement the copy c'tor!!!
*/
template <class T = OPimRecord>
-class OTemplateBase {
+class OTemplateBase : public OPimBase {
public:
enum CacheDirection { Forward=0, Reverse };
@@ -27,6 +57,35 @@ public:
virtual void setSaneCacheSize( int ) = 0;
+ /* reimplement of OPimBase */
+ int rtti();
+ OPimRecord* record()const;
+ OPimRecord* record(int uid )const;
+ static T* rec();
};
+/*
+ * implementation
+ */
+template <class T>
+int
+OTemplateBase<T>::rtti() {
+ return T::rtti();
+}
+template <class T>
+OPimRecord* OTemplateBase<T>::record()const {
+ T* t = new T;
+ return t;
+}
+template <class T>
+OPimRecord* OTemplateBase<T>::record(int uid )const {
+ T t2 = find(uid );
+ T* t1 = new T(t2);
+
+ return t1;
+};
+template <class T>
+T* OTemplateBase<T>::rec() {
+ return new T;
+}
#endif