summaryrefslogtreecommitdiff
path: root/libopie2/opiepim/core/otemplatebase.h
authorzecke <zecke>2002-12-10 17:01:18 (UTC)
committer zecke <zecke>2002-12-10 17:01:18 (UTC)
commit4ecbf7407c19b59fc136c334f9386c53db453930 (patch) (unidiff)
tree1cba438e2533f7109af169b0b77988cec6664192 /libopie2/opiepim/core/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 'libopie2/opiepim/core/otemplatebase.h') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiepim/core/otemplatebase.h63
1 files changed, 61 insertions, 2 deletions
diff --git a/libopie2/opiepim/core/otemplatebase.h b/libopie2/opiepim/core/otemplatebase.h
index b855919..29fb6ec 100644
--- a/libopie2/opiepim/core/otemplatebase.h
+++ b/libopie2/opiepim/core/otemplatebase.h
@@ -3,13 +3,43 @@
3 3
4#include <qarray.h> 4#include <qarray.h>
5 5
6#include "opimrecord.h" 6#include <opie/opimrecord.h>
7
7 8
8/** 9/**
10 * Templates do not have a base class, This is why
11 * we've this class
12 * this is here to give us the possibility
13 * to have a common base class
14 * You may not want to use that interface internaly
15 * POOR mans interface
16 */
17struct OPimBase {
18 /**
19 * return the rtti
20 */
21 virtual int rtti()= 0;
22 virtual OPimRecord* record()const = 0;
23 virtual OPimRecord* record(int uid)const = 0;
24 virtual bool add( const OPimRecord& ) = 0;
25 virtual bool remove( int uid ) = 0;
26 virtual bool remove( const OPimRecord& ) = 0;
27 virtual void clear() = 0;
28 virtual bool load() = 0;
29 virtual bool save() = 0;
30 virtual QArray<int> records()const = 0;
31 /*
32 * ADD editing here?
33 * -zecke
34 */
35
36};
37/**
9 * internal template base 38 * internal template base
39 * T needs to implement the copy c'tor!!!
10 */ 40 */
11template <class T = OPimRecord> 41template <class T = OPimRecord>
12class OTemplateBase { 42class OTemplateBase : public OPimBase {
13public: 43public:
14 enum CacheDirection { Forward=0, Reverse }; 44 enum CacheDirection { Forward=0, Reverse };
15 OTemplateBase() { 45 OTemplateBase() {
@@ -26,7 +56,36 @@ public:
26 virtual void cache( const T& )const = 0; 56 virtual void cache( const T& )const = 0;
27 virtual void setSaneCacheSize( int ) = 0; 57 virtual void setSaneCacheSize( int ) = 0;
28 58
59 /* reimplement of OPimBase */
60 int rtti();
61 OPimRecord* record()const;
62 OPimRecord* record(int uid )const;
63 static T* rec();
29}; 64};
30 65
66/*
67 * implementation
68 */
69template <class T>
70int
71OTemplateBase<T>::rtti() {
72 return T::rtti();
73}
74template <class T>
75OPimRecord* OTemplateBase<T>::record()const {
76 T* t = new T;
77 return t;
78}
79template <class T>
80OPimRecord* OTemplateBase<T>::record(int uid )const {
81 T t2 = find(uid );
82 T* t1 = new T(t2);
83
84 return t1;
85};
86template <class T>
87T* OTemplateBase<T>::rec() {
88 return new T;
89}
31 90
32#endif 91#endif