Diffstat (limited to 'libopie2/opiepim/core/opimtemplatebase.h') (more/less context) (show whitespace changes)
-rw-r--r-- | libopie2/opiepim/core/opimtemplatebase.h | 16 |
1 files changed, 4 insertions, 12 deletions
diff --git a/libopie2/opiepim/core/opimtemplatebase.h b/libopie2/opiepim/core/opimtemplatebase.h index 58cbfeb..b48dfed 100644 --- a/libopie2/opiepim/core/opimtemplatebase.h +++ b/libopie2/opiepim/core/opimtemplatebase.h | |||
@@ -1,15 +1,15 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | Copyright (C) The Main Author <main-author@whereever.org> | 3 | Copyright (C) Holger Freyther <zecke@handhelds.org> |
4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> | 4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> |
5 | .=l. | 5 | .=l. |
6 | .>+-= | 6 | .>+-= |
7 | _;:, .> :=|. This program is free software; you can | 7 | _;:, .> :=|. This program is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 8 | .> <`_, > . <= redistribute it and/or modify it under |
9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
10 | .="- .-=="i, .._ License as published by the Free Software | 10 | .="- .-=="i, .._ License as published by the Free Software |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 11 | - . .-<_> .<> Foundation; either version 2 of the License, |
12 | ._= =} : or (at your option) any later version. | 12 | ._= =} : or (at your option) any later version. |
13 | .%`+i> _;_. | 13 | .%`+i> _;_. |
14 | .i_,=:_. -<s. This program is distributed in the hope that | 14 | .i_,=:_. -<s. This program is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
@@ -40,28 +40,29 @@ namespace Opie { | |||
40 | * Templates do not have a base class, This is why | 40 | * Templates do not have a base class, This is why |
41 | * we've this class | 41 | * we've this class |
42 | * this is here to give us the possibility | 42 | * this is here to give us the possibility |
43 | * to have a common base class | 43 | * to have a common base class |
44 | * You may not want to use that interface internaly | 44 | * You may not want to use that interface internaly |
45 | * POOR mans interface | 45 | * POOR mans interface |
46 | */ | 46 | */ |
47 | class OPimBasePrivate; | 47 | class OPimBasePrivate; |
48 | struct OPimBase { | 48 | struct OPimBase { |
49 | /** | 49 | /** |
50 | * return the rtti | 50 | * return the rtti |
51 | */ | 51 | */ |
52 | virtual int rtti()= 0; | 52 | virtual int rtti() const = 0; |
53 | virtual OPimRecord* record()const = 0; | 53 | virtual OPimRecord* record()const = 0; |
54 | virtual OPimRecord* record(int uid)const = 0; | 54 | virtual OPimRecord* record(int uid)const = 0; |
55 | virtual bool add( const OPimRecord& ) = 0; | 55 | virtual bool add( const OPimRecord& ) = 0; |
56 | virtual bool add( const OPimRecord* ) = 0; | ||
56 | virtual bool remove( int uid ) = 0; | 57 | virtual bool remove( int uid ) = 0; |
57 | virtual bool remove( const OPimRecord& ) = 0; | 58 | virtual bool remove( const OPimRecord& ) = 0; |
58 | virtual void clear() = 0; | 59 | virtual void clear() = 0; |
59 | virtual bool load() = 0; | 60 | virtual bool load() = 0; |
60 | virtual bool save() = 0; | 61 | virtual bool save() = 0; |
61 | virtual QArray<int> records()const = 0; | 62 | virtual QArray<int> records()const = 0; |
62 | /* | 63 | /* |
63 | * ADD editing here? | 64 | * ADD editing here? |
64 | * -zecke | 65 | * -zecke |
65 | */ | 66 | */ |
66 | private: | 67 | private: |
67 | OPimBasePrivate* d; | 68 | OPimBasePrivate* d; |
@@ -81,42 +82,33 @@ public: | |||
81 | virtual ~OTemplateBase() { | 82 | virtual ~OTemplateBase() { |
82 | } | 83 | } |
83 | virtual T find( int uid )const = 0; | 84 | virtual T find( int uid )const = 0; |
84 | 85 | ||
85 | /** | 86 | /** |
86 | * read ahead find | 87 | * read ahead find |
87 | */ | 88 | */ |
88 | virtual T find( int uid, const QArray<int>& items, | 89 | virtual T find( int uid, const QArray<int>& items, |
89 | uint current, CacheDirection dir = Forward )const = 0; | 90 | uint current, CacheDirection dir = Forward )const = 0; |
90 | virtual void cache( const T& )const = 0; | 91 | virtual void cache( const T& )const = 0; |
91 | virtual void setSaneCacheSize( int ) = 0; | 92 | virtual void setSaneCacheSize( int ) = 0; |
92 | 93 | ||
93 | /* reimplement of OPimBase */ | ||
94 | int rtti(); | ||
95 | OPimRecord* record()const; | 94 | OPimRecord* record()const; |
96 | OPimRecord* record(int uid )const; | 95 | OPimRecord* record(int uid )const; |
97 | static T* rec(); | 96 | static T* rec(); |
98 | 97 | ||
99 | private: | 98 | private: |
100 | OTemplateBasePrivate *d; | 99 | OTemplateBasePrivate *d; |
101 | }; | 100 | }; |
102 | 101 | ||
103 | /* | 102 | |
104 | * implementation | ||
105 | */ | ||
106 | template <class T> | ||
107 | int | ||
108 | OTemplateBase<T>::rtti() { | ||
109 | return T::rtti(); | ||
110 | } | ||
111 | template <class T> | 103 | template <class T> |
112 | OPimRecord* OTemplateBase<T>::record()const { | 104 | OPimRecord* OTemplateBase<T>::record()const { |
113 | T* t = new T; | 105 | T* t = new T; |
114 | return t; | 106 | return t; |
115 | } | 107 | } |
116 | template <class T> | 108 | template <class T> |
117 | OPimRecord* OTemplateBase<T>::record(int uid )const { | 109 | OPimRecord* OTemplateBase<T>::record(int uid )const { |
118 | T t2 = find(uid ); | 110 | T t2 = find(uid ); |
119 | T* t1 = new T(t2); | 111 | T* t1 = new T(t2); |
120 | 112 | ||
121 | return t1; | 113 | return t1; |
122 | }; | 114 | }; |