summaryrefslogtreecommitdiff
path: root/libopie2/opiepim/core/opimtemplatebase.h
Unidiff
Diffstat (limited to 'libopie2/opiepim/core/opimtemplatebase.h') (more/less context) (show whitespace changes)
-rw-r--r--libopie2/opiepim/core/opimtemplatebase.h16
1 files changed, 15 insertions, 1 deletions
diff --git a/libopie2/opiepim/core/opimtemplatebase.h b/libopie2/opiepim/core/opimtemplatebase.h
index b48dfed..ec9a94e 100644
--- a/libopie2/opiepim/core/opimtemplatebase.h
+++ b/libopie2/opiepim/core/opimtemplatebase.h
@@ -22,24 +22,25 @@
22 -. .:....=;==+<; You should have received a copy of the GNU 22 -. .:....=;==+<; You should have received a copy of the GNU
23 -_. . . )=. = Library General Public License along with 23 -_. . . )=. = Library General Public License along with
24 -- :-=` this library; see the file COPYING.LIB. 24 -- :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28*/ 28*/
29#ifndef OTEMPLATEBASE_H 29#ifndef OTEMPLATEBASE_H
30#define OTEMPLATEBASE_H 30#define OTEMPLATEBASE_H
31 31
32/* OPIE */ 32/* OPIE */
33#include <opie2/opimrecord.h> 33#include <opie2/opimrecord.h>
34#include <opie2/opimcache.h>
34 35
35/* QT */ 36/* QT */
36#include <qarray.h> 37#include <qarray.h>
37 38
38namespace Opie { 39namespace Opie {
39/** 40/**
40 * Templates do not have a base class, This is why 41 * Templates do not have a base class, This is why
41 * we've this class 42 * we've this class
42 * this is here to give us the possibility 43 * this is here to give us the possibility
43 * to have a common base class 44 * to have a common base class
44 * You may not want to use that interface internaly 45 * You may not want to use that interface internaly
45 * POOR mans interface 46 * POOR mans interface
@@ -61,49 +62,62 @@ struct OPimBase {
61 virtual bool save() = 0; 62 virtual bool save() = 0;
62 virtual QArray<int> records()const = 0; 63 virtual QArray<int> records()const = 0;
63 /* 64 /*
64 * ADD editing here? 65 * ADD editing here?
65 * -zecke 66 * -zecke
66 */ 67 */
67private: 68private:
68 OPimBasePrivate* d; 69 OPimBasePrivate* d;
69 70
70}; 71};
71/** 72/**
72 * internal template base 73 * internal template base
73 * T needs to implement the copy c'tor!!! 74 * Attention: T needs to implement the copy c'tor!!!
74 */ 75 */
75class OTemplateBasePrivate; 76class OTemplateBasePrivate;
76template <class T = OPimRecord> 77template <class T = OPimRecord>
77class OTemplateBase : public OPimBase { 78class OTemplateBase : public OPimBase {
78public: 79public:
80 /** Look ahead direction of cache */
79 enum CacheDirection { Forward=0, Reverse }; 81 enum CacheDirection { Forward=0, Reverse };
82
80 OTemplateBase() { 83 OTemplateBase() {
81 }; 84 };
82 virtual ~OTemplateBase() { 85 virtual ~OTemplateBase() {
83 } 86 }
84 virtual T find( int uid )const = 0; 87 virtual T find( int uid )const = 0;
85 88
86 /** 89 /**
87 * read ahead find 90 * read ahead find
88 */ 91 */
89 virtual T find( int uid, const QArray<int>& items, 92 virtual T find( int uid, const QArray<int>& items,
90 uint current, CacheDirection dir = Forward )const = 0; 93 uint current, CacheDirection dir = Forward )const = 0;
94
95 /**
96 * Find in Cache..
97 * Returns empty object if nothing found.
98 */
99 virtual T cacheFind( int uid )const = 0;
100
101 /**
102 * Put element into Cache
103 */
91 virtual void cache( const T& )const = 0; 104 virtual void cache( const T& )const = 0;
92 virtual void setSaneCacheSize( int ) = 0; 105 virtual void setSaneCacheSize( int ) = 0;
93 106
94 OPimRecord* record()const; 107 OPimRecord* record()const;
95 OPimRecord* record(int uid )const; 108 OPimRecord* record(int uid )const;
96 static T* rec(); 109 static T* rec();
97 110
111
98private: 112private:
99 OTemplateBasePrivate *d; 113 OTemplateBasePrivate *d;
100}; 114};
101 115
102 116
103template <class T> 117template <class T>
104OPimRecord* OTemplateBase<T>::record()const { 118OPimRecord* OTemplateBase<T>::record()const {
105 T* t = new T; 119 T* t = new T;
106 return t; 120 return t;
107} 121}
108template <class T> 122template <class T>
109OPimRecord* OTemplateBase<T>::record(int uid )const { 123OPimRecord* OTemplateBase<T>::record(int uid )const {