Diffstat (limited to 'libopie2/opiepim/backend/opimaccessbackend.h') (more/less context) (ignore whitespace changes)
-rw-r--r-- | libopie2/opiepim/backend/opimaccessbackend.h | 36 |
1 files changed, 34 insertions, 2 deletions
diff --git a/libopie2/opiepim/backend/opimaccessbackend.h b/libopie2/opiepim/backend/opimaccessbackend.h index fd264fc..505358e 100644 --- a/libopie2/opiepim/backend/opimaccessbackend.h +++ b/libopie2/opiepim/backend/opimaccessbackend.h | |||
@@ -1,58 +1,87 @@ | |||
1 | /* | ||
2 | This file is part of the Opie Project | ||
3 | Copyright (C) The Main Author <main-author@whereever.org> | ||
4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> | ||
5 | .=l. | ||
6 | .>+-= | ||
7 | _;:, .> :=|. This program is free software; you can | ||
8 | .> <`_, > . <= redistribute it and/or modify it under | ||
9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | ||
10 | .="- .-=="i, .._ License as published by the Free Software | ||
11 | - . .-<_> .<> Foundation; either version 2 of the License, | ||
12 | ._= =} : or (at your option) any later version. | ||
13 | .%`+i> _;_. | ||
14 | .i_,=:_. -<s. This program is distributed in the hope that | ||
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | ||
16 | : .. .:, . . . without even the implied warranty of | ||
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | ||
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | ||
19 | ..}^=.= = ; Library General Public License for more | ||
20 | ++= -. .` .: details. | ||
21 | : = ...= . :.=- | ||
22 | -. .:....=;==+<; You should have received a copy of the GNU | ||
23 | -_. . . )=. = Library General Public License along with | ||
24 | -- :-=` this library; see the file COPYING.LIB. | ||
25 | If not, write to the Free Software Foundation, | ||
26 | Inc., 59 Temple Place - Suite 330, | ||
27 | Boston, MA 02111-1307, USA. | ||
28 | */ | ||
1 | #ifndef OPIE_PIM_ACCESS_BACKEND | 29 | #ifndef OPIE_PIM_ACCESS_BACKEND |
2 | #define OPIE_PIM_ACCESS_BACKEND | 30 | #define OPIE_PIM_ACCESS_BACKEND |
3 | 31 | ||
4 | #include <qarray.h> | 32 | #include <qarray.h> |
5 | #include <qdatetime.h> | 33 | #include <qdatetime.h> |
6 | 34 | ||
7 | #include <opie/otemplatebase.h> | 35 | #include <opie2/otemplatebase.h> |
8 | #include <opie/opimrecord.h> | 36 | #include <opie2/opimrecord.h> |
9 | 37 | ||
10 | 38 | ||
39 | namespace Opie { | ||
11 | class OPimAccessBackendPrivate; | 40 | class OPimAccessBackendPrivate; |
12 | /** | 41 | /** |
13 | * OPimAccessBackend is the base class | 42 | * OPimAccessBackend is the base class |
14 | * for all private backends | 43 | * for all private backends |
15 | * it operates on OPimRecord as the base class | 44 | * it operates on OPimRecord as the base class |
16 | * and it's responsible for fast manipulating | 45 | * and it's responsible for fast manipulating |
17 | * the resource the implementation takes care | 46 | * the resource the implementation takes care |
18 | * of | 47 | * of |
19 | */ | 48 | */ |
20 | template <class T = OPimRecord> | 49 | template <class T = OPimRecord> |
21 | class OPimAccessBackend { | 50 | class OPimAccessBackend { |
22 | public: | 51 | public: |
23 | typedef OTemplateBase<T> Frontend; | 52 | typedef OTemplateBase<T> Frontend; |
24 | 53 | ||
25 | /** The access hint from the frontend */ | 54 | /** The access hint from the frontend */ |
26 | OPimAccessBackend(int access = 0); | 55 | OPimAccessBackend(int access = 0); |
27 | virtual ~OPimAccessBackend(); | 56 | virtual ~OPimAccessBackend(); |
28 | 57 | ||
29 | /** | 58 | /** |
30 | * load the resource | 59 | * load the resource |
31 | */ | 60 | */ |
32 | virtual bool load() = 0; | 61 | virtual bool load() = 0; |
33 | 62 | ||
34 | /** | 63 | /** |
35 | * reload the resource | 64 | * reload the resource |
36 | */ | 65 | */ |
37 | virtual bool reload() = 0; | 66 | virtual bool reload() = 0; |
38 | 67 | ||
39 | /** | 68 | /** |
40 | * save the resource and | 69 | * save the resource and |
41 | * all it's changes | 70 | * all it's changes |
42 | */ | 71 | */ |
43 | virtual bool save() = 0; | 72 | virtual bool save() = 0; |
44 | 73 | ||
45 | /** | 74 | /** |
46 | * return an array of | 75 | * return an array of |
47 | * all available uids | 76 | * all available uids |
48 | */ | 77 | */ |
49 | virtual QArray<int> allRecords()const = 0; | 78 | virtual QArray<int> allRecords()const = 0; |
50 | 79 | ||
51 | /** | 80 | /** |
52 | * return a List of records | 81 | * return a List of records |
53 | * that match the regex | 82 | * that match the regex |
54 | */ | 83 | */ |
55 | virtual QArray<int> matchRegexp(const QRegExp &r) const = 0; | 84 | virtual QArray<int> matchRegexp(const QRegExp &r) const = 0; |
56 | 85 | ||
57 | /** | 86 | /** |
58 | * queryByExample for T with the given Settings | 87 | * queryByExample for T with the given Settings |
@@ -112,49 +141,52 @@ private: | |||
112 | OPimAccessBackendPrivate *d; | 141 | OPimAccessBackendPrivate *d; |
113 | Frontend* m_front; | 142 | Frontend* m_front; |
114 | uint m_read; | 143 | uint m_read; |
115 | int m_acc; | 144 | int m_acc; |
116 | 145 | ||
117 | }; | 146 | }; |
118 | 147 | ||
119 | template <class T> | 148 | template <class T> |
120 | OPimAccessBackend<T>::OPimAccessBackend(int acc) | 149 | OPimAccessBackend<T>::OPimAccessBackend(int acc) |
121 | : m_acc( acc ) | 150 | : m_acc( acc ) |
122 | { | 151 | { |
123 | m_front = 0l; | 152 | m_front = 0l; |
124 | } | 153 | } |
125 | template <class T> | 154 | template <class T> |
126 | OPimAccessBackend<T>::~OPimAccessBackend() { | 155 | OPimAccessBackend<T>::~OPimAccessBackend() { |
127 | 156 | ||
128 | } | 157 | } |
129 | template <class T> | 158 | template <class T> |
130 | void OPimAccessBackend<T>::setFrontend( Frontend* fr ) { | 159 | void OPimAccessBackend<T>::setFrontend( Frontend* fr ) { |
131 | m_front = fr; | 160 | m_front = fr; |
132 | } | 161 | } |
133 | template <class T> | 162 | template <class T> |
134 | void OPimAccessBackend<T>::cache( const T& t )const { | 163 | void OPimAccessBackend<T>::cache( const T& t )const { |
135 | if (m_front ) | 164 | if (m_front ) |
136 | m_front->cache( t ); | 165 | m_front->cache( t ); |
137 | } | 166 | } |
138 | template <class T> | 167 | template <class T> |
139 | void OPimAccessBackend<T>::setSaneCacheSize( int size) { | 168 | void OPimAccessBackend<T>::setSaneCacheSize( int size) { |
140 | if (m_front ) | 169 | if (m_front ) |
141 | m_front->setSaneCacheSize( size ); | 170 | m_front->setSaneCacheSize( size ); |
142 | } | 171 | } |
143 | template <class T> | 172 | template <class T> |
144 | T OPimAccessBackend<T>::find( int uid, const QArray<int>&, | 173 | T OPimAccessBackend<T>::find( int uid, const QArray<int>&, |
145 | uint, typename Frontend::CacheDirection )const { | 174 | uint, typename Frontend::CacheDirection )const { |
146 | return find( uid ); | 175 | return find( uid ); |
147 | } | 176 | } |
148 | template <class T> | 177 | template <class T> |
149 | void OPimAccessBackend<T>::setReadAhead( uint count ) { | 178 | void OPimAccessBackend<T>::setReadAhead( uint count ) { |
150 | m_read = count; | 179 | m_read = count; |
151 | } | 180 | } |
152 | template <class T> | 181 | template <class T> |
153 | uint OPimAccessBackend<T>::readAhead()const { | 182 | uint OPimAccessBackend<T>::readAhead()const { |
154 | return m_read; | 183 | return m_read; |
155 | } | 184 | } |
156 | template <class T> | 185 | template <class T> |
157 | int OPimAccessBackend<T>::access()const { | 186 | int OPimAccessBackend<T>::access()const { |
158 | return m_acc; | 187 | return m_acc; |
159 | } | 188 | } |
189 | |||
190 | } | ||
191 | |||
160 | #endif | 192 | #endif |