-rw-r--r-- | libopie/pim/otemplatebase.h | 98 |
1 files changed, 0 insertions, 98 deletions
diff --git a/libopie/pim/otemplatebase.h b/libopie/pim/otemplatebase.h deleted file mode 100644 index cadac74..0000000 --- a/libopie/pim/otemplatebase.h +++ b/dev/null | |||
@@ -1,98 +0,0 @@ | |||
1 | #ifndef OPIE_TEMPLATE_BASE_H | ||
2 | #define OPIE_TEMPLATE_BASE_H | ||
3 | |||
4 | #include <qarray.h> | ||
5 | |||
6 | #include <opie/opimrecord.h> | ||
7 | |||
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 | */ | ||
17 | class OPimBasePrivate; | ||
18 | struct OPimBase { | ||
19 | /** | ||
20 | * return the rtti | ||
21 | */ | ||
22 | virtual int rtti()= 0; | ||
23 | virtual OPimRecord* record()const = 0; | ||
24 | virtual OPimRecord* record(int uid)const = 0; | ||
25 | virtual bool add( const OPimRecord& ) = 0; | ||
26 | virtual bool remove( int uid ) = 0; | ||
27 | virtual bool remove( const OPimRecord& ) = 0; | ||
28 | virtual void clear() = 0; | ||
29 | virtual bool load() = 0; | ||
30 | virtual bool save() = 0; | ||
31 | virtual QArray<int> records()const = 0; | ||
32 | /* | ||
33 | * ADD editing here? | ||
34 | * -zecke | ||
35 | */ | ||
36 | private: | ||
37 | OPimBasePrivate* d; | ||
38 | |||
39 | }; | ||
40 | /** | ||
41 | * internal template base | ||
42 | * T needs to implement the copy c'tor!!! | ||
43 | */ | ||
44 | class OTemplateBasePrivate; | ||
45 | template <class T = OPimRecord> | ||
46 | class OTemplateBase : public OPimBase { | ||
47 | public: | ||
48 | enum CacheDirection { Forward=0, Reverse }; | ||
49 | OTemplateBase() { | ||
50 | }; | ||
51 | virtual ~OTemplateBase() { | ||
52 | } | ||
53 | virtual T find( int uid )const = 0; | ||
54 | |||
55 | /** | ||
56 | * read ahead find | ||
57 | */ | ||
58 | virtual T find( int uid, const QArray<int>& items, | ||
59 | uint current, CacheDirection dir = Forward )const = 0; | ||
60 | virtual void cache( const T& )const = 0; | ||
61 | virtual void setSaneCacheSize( int ) = 0; | ||
62 | |||
63 | /* reimplement of OPimBase */ | ||
64 | int rtti(); | ||
65 | OPimRecord* record()const; | ||
66 | OPimRecord* record(int uid )const; | ||
67 | static T* rec(); | ||
68 | |||
69 | private: | ||
70 | OTemplateBasePrivate *d; | ||
71 | }; | ||
72 | |||
73 | /* | ||
74 | * implementation | ||
75 | */ | ||
76 | template <class T> | ||
77 | int | ||
78 | OTemplateBase<T>::rtti() { | ||
79 | return T::rtti(); | ||
80 | } | ||
81 | template <class T> | ||
82 | OPimRecord* OTemplateBase<T>::record()const { | ||
83 | T* t = new T; | ||
84 | return t; | ||
85 | } | ||
86 | template <class T> | ||
87 | OPimRecord* OTemplateBase<T>::record(int uid )const { | ||
88 | T t2 = find(uid ); | ||
89 | T* t1 = new T(t2); | ||
90 | |||
91 | return t1; | ||
92 | }; | ||
93 | template <class T> | ||
94 | T* OTemplateBase<T>::rec() { | ||
95 | return new T; | ||
96 | } | ||
97 | |||
98 | #endif | ||