author | mickeyl <mickeyl> | 2004-11-16 19:14:18 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2004-11-16 19:14:18 (UTC) |
commit | ea3945a9bd8f9830f70b1efa133f9df13b19362f (patch) (unidiff) | |
tree | f2ea22cc50e9aa8aa73ee7dea148f41c563c9666 /noncore/unsupported/libopie/pim/opimaccessbackend.h | |
parent | 1c6f490e8541626f68422e0a3a7c7281d7f5b7d3 (diff) | |
download | opie-ea3945a9bd8f9830f70b1efa133f9df13b19362f.zip opie-ea3945a9bd8f9830f70b1efa133f9df13b19362f.tar.gz opie-ea3945a9bd8f9830f70b1efa133f9df13b19362f.tar.bz2 |
libopie1 goes into unsupported
Diffstat (limited to 'noncore/unsupported/libopie/pim/opimaccessbackend.h') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/unsupported/libopie/pim/opimaccessbackend.h | 160 |
1 files changed, 160 insertions, 0 deletions
diff --git a/noncore/unsupported/libopie/pim/opimaccessbackend.h b/noncore/unsupported/libopie/pim/opimaccessbackend.h new file mode 100644 index 0000000..fd264fc --- a/dev/null +++ b/noncore/unsupported/libopie/pim/opimaccessbackend.h | |||
@@ -0,0 +1,160 @@ | |||
1 | #ifndef OPIE_PIM_ACCESS_BACKEND | ||
2 | #define OPIE_PIM_ACCESS_BACKEND | ||
3 | |||
4 | #include <qarray.h> | ||
5 | #include <qdatetime.h> | ||
6 | |||
7 | #include <opie/otemplatebase.h> | ||
8 | #include <opie/opimrecord.h> | ||
9 | |||
10 | |||
11 | class OPimAccessBackendPrivate; | ||
12 | /** | ||
13 | * OPimAccessBackend is the base class | ||
14 | * for all private backends | ||
15 | * it operates on OPimRecord as the base class | ||
16 | * and it's responsible for fast manipulating | ||
17 | * the resource the implementation takes care | ||
18 | * of | ||
19 | */ | ||
20 | template <class T = OPimRecord> | ||
21 | class OPimAccessBackend { | ||
22 | public: | ||
23 | typedef OTemplateBase<T> Frontend; | ||
24 | |||
25 | /** The access hint from the frontend */ | ||
26 | OPimAccessBackend(int access = 0); | ||
27 | virtual ~OPimAccessBackend(); | ||
28 | |||
29 | /** | ||
30 | * load the resource | ||
31 | */ | ||
32 | virtual bool load() = 0; | ||
33 | |||
34 | /** | ||
35 | * reload the resource | ||
36 | */ | ||
37 | virtual bool reload() = 0; | ||
38 | |||
39 | /** | ||
40 | * save the resource and | ||
41 | * all it's changes | ||
42 | */ | ||
43 | virtual bool save() = 0; | ||
44 | |||
45 | /** | ||
46 | * return an array of | ||
47 | * all available uids | ||
48 | */ | ||
49 | virtual QArray<int> allRecords()const = 0; | ||
50 | |||
51 | /** | ||
52 | * return a List of records | ||
53 | * that match the regex | ||
54 | */ | ||
55 | virtual QArray<int> matchRegexp(const QRegExp &r) const = 0; | ||
56 | |||
57 | /** | ||
58 | * queryByExample for T with the given Settings | ||
59 | * | ||
60 | */ | ||
61 | virtual QArray<int> queryByExample( const T& t, int settings, const QDateTime& d = QDateTime() ) = 0; | ||
62 | |||
63 | /** | ||
64 | * find the OPimRecord with uid @param uid | ||
65 | * returns T and T.isEmpty() if nothing was found | ||
66 | */ | ||
67 | virtual T find(int uid )const = 0; | ||
68 | |||
69 | virtual T find(int uid, const QArray<int>& items, | ||
70 | uint current, typename Frontend::CacheDirection )const ; | ||
71 | /** | ||
72 | * clear the back end | ||
73 | */ | ||
74 | virtual void clear() = 0; | ||
75 | |||
76 | /** | ||
77 | * add T | ||
78 | */ | ||
79 | virtual bool add( const T& t ) = 0; | ||
80 | |||
81 | /** | ||
82 | * remove | ||
83 | */ | ||
84 | virtual bool remove( int uid ) = 0; | ||
85 | |||
86 | /** | ||
87 | * replace a record with T.uid() | ||
88 | */ | ||
89 | virtual bool replace( const T& t ) = 0; | ||
90 | |||
91 | /* | ||
92 | * setTheFrontEnd!!! | ||
93 | */ | ||
94 | void setFrontend( Frontend* front ); | ||
95 | |||
96 | /** | ||
97 | * set the read ahead count | ||
98 | */ | ||
99 | void setReadAhead( uint count ); | ||
100 | protected: | ||
101 | int access()const; | ||
102 | void cache( const T& t )const; | ||
103 | |||
104 | /** | ||
105 | * use a prime number here! | ||
106 | */ | ||
107 | void setSaneCacheSize( int ); | ||
108 | |||
109 | uint readAhead()const; | ||
110 | |||
111 | private: | ||
112 | OPimAccessBackendPrivate *d; | ||
113 | Frontend* m_front; | ||
114 | uint m_read; | ||
115 | int m_acc; | ||
116 | |||
117 | }; | ||
118 | |||
119 | template <class T> | ||
120 | OPimAccessBackend<T>::OPimAccessBackend(int acc) | ||
121 | : m_acc( acc ) | ||
122 | { | ||
123 | m_front = 0l; | ||
124 | } | ||
125 | template <class T> | ||
126 | OPimAccessBackend<T>::~OPimAccessBackend() { | ||
127 | |||
128 | } | ||
129 | template <class T> | ||
130 | void OPimAccessBackend<T>::setFrontend( Frontend* fr ) { | ||
131 | m_front = fr; | ||
132 | } | ||
133 | template <class T> | ||
134 | void OPimAccessBackend<T>::cache( const T& t )const { | ||
135 | if (m_front ) | ||
136 | m_front->cache( t ); | ||
137 | } | ||
138 | template <class T> | ||
139 | void OPimAccessBackend<T>::setSaneCacheSize( int size) { | ||
140 | if (m_front ) | ||
141 | m_front->setSaneCacheSize( size ); | ||
142 | } | ||
143 | template <class T> | ||
144 | T OPimAccessBackend<T>::find( int uid, const QArray<int>&, | ||
145 | uint, typename Frontend::CacheDirection )const { | ||
146 | return find( uid ); | ||
147 | } | ||
148 | template <class T> | ||
149 | void OPimAccessBackend<T>::setReadAhead( uint count ) { | ||
150 | m_read = count; | ||
151 | } | ||
152 | template <class T> | ||
153 | uint OPimAccessBackend<T>::readAhead()const { | ||
154 | return m_read; | ||
155 | } | ||
156 | template <class T> | ||
157 | int OPimAccessBackend<T>::access()const { | ||
158 | return m_acc; | ||
159 | } | ||
160 | #endif | ||