author | zecke <zecke> | 2002-12-10 17:01:18 (UTC) |
---|---|---|
committer | zecke <zecke> | 2002-12-10 17:01:18 (UTC) |
commit | 4ecbf7407c19b59fc136c334f9386c53db453930 (patch) (unidiff) | |
tree | 1cba438e2533f7109af169b0b77988cec6664192 /libopie/pim/opimaccesstemplate.h | |
parent | 36375df6ff103e52455823f7afd64c4f4ae7fcb8 (diff) | |
download | opie-4ecbf7407c19b59fc136c334f9386c53db453930.zip opie-4ecbf7407c19b59fc136c334f9386c53db453930.tar.gz opie-4ecbf7407c19b59fc136c334f9386c53db453930.tar.bz2 |
get in sync with HEAD again
-OPimBase was added to be used as a default struct inside OPimResolver
and to work with DSOs
-TodoListXML backend now uses mmap and madvise to load data
-OContact added/changed rtti
-OTodo added changed rtti
OPimAccess* added stuff necessary for the Resolver and a 'state'/'hint'
on how to load data
OPimResolver which resolves uid + services to Records, rtti to QCOPChannels
loads arbitary Service backends ( will work with DSOs soon )
-OPimMainWindow added some setDocument scripting possibility and
internal marshalling and demarshalling of Records
-OPimRecord added loadDataFromm and saveDataTo for marshalling purposes
much more :)
Diffstat (limited to 'libopie/pim/opimaccesstemplate.h') (more/less context) (show whitespace changes)
-rw-r--r-- | libopie/pim/opimaccesstemplate.h | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/libopie/pim/opimaccesstemplate.h b/libopie/pim/opimaccesstemplate.h index 8cf81c8..259e2c1 100644 --- a/libopie/pim/opimaccesstemplate.h +++ b/libopie/pim/opimaccesstemplate.h | |||
@@ -19,26 +19,32 @@ | |||
19 | * the plugins | 19 | * the plugins |
20 | */ | 20 | */ |
21 | 21 | ||
22 | template <class T = OPimRecord > | 22 | template <class T = OPimRecord > |
23 | class OPimAccessTemplate : public OTemplateBase<T> { | 23 | class OPimAccessTemplate : public OTemplateBase<T> { |
24 | public: | 24 | public: |
25 | enum Access { | ||
26 | Random = 0, | ||
27 | SortedAccess | ||
28 | }; | ||
25 | typedef ORecordList<T> List; | 29 | typedef ORecordList<T> List; |
26 | typedef OPimAccessBackend<T> BackEnd; | 30 | typedef OPimAccessBackend<T> BackEnd; |
27 | typedef OPimCache<T> Cache; | 31 | typedef OPimCache<T> Cache; |
28 | 32 | ||
29 | /** | 33 | /** |
30 | * c'tor BackEnd | 34 | * c'tor BackEnd |
35 | * enum Access a small hint on how to handle the backend | ||
31 | */ | 36 | */ |
32 | OPimAccessTemplate( BackEnd* end); | 37 | OPimAccessTemplate( BackEnd* end); |
38 | |||
33 | virtual ~OPimAccessTemplate(); | 39 | virtual ~OPimAccessTemplate(); |
34 | 40 | ||
35 | /** | 41 | /** |
36 | * load from the backend | 42 | * load from the backend |
37 | */ | 43 | */ |
38 | virtual bool load(); | 44 | bool load(); |
39 | 45 | ||
40 | /** Reload database. | 46 | /** Reload database. |
41 | * You should execute this function if the external database | 47 | * You should execute this function if the external database |
42 | * was changed. | 48 | * was changed. |
43 | * This function will load the external database and afterwards | 49 | * This function will load the external database and afterwards |
44 | * rejoin the local changes. Therefore the local database will be set consistent. | 50 | * rejoin the local changes. Therefore the local database will be set consistent. |
@@ -46,13 +52,13 @@ public: | |||
46 | virtual bool reload(); | 52 | virtual bool reload(); |
47 | 53 | ||
48 | /** Save contacts database. | 54 | /** Save contacts database. |
49 | * Save is more a "commit". After calling this function, all changes are public available. | 55 | * Save is more a "commit". After calling this function, all changes are public available. |
50 | * @return true if successful | 56 | * @return true if successful |
51 | */ | 57 | */ |
52 | virtual bool save(); | 58 | bool save(); |
53 | 59 | ||
54 | /** | 60 | /** |
55 | * if the resource was changed externally | 61 | * if the resource was changed externally |
56 | * You should use the signal handling instead of polling possible changes ! | 62 | * You should use the signal handling instead of polling possible changes ! |
57 | * zecke: Do you implement a signal for otodoaccess ? | 63 | * zecke: Do you implement a signal for otodoaccess ? |
58 | */ | 64 | */ |
@@ -82,13 +88,13 @@ public: | |||
82 | uint current, typename OTemplateBase<T>::CacheDirection dir = OTemplateBase<T>::Forward )const; | 88 | uint current, typename OTemplateBase<T>::CacheDirection dir = OTemplateBase<T>::Forward )const; |
83 | 89 | ||
84 | /* invalidate cache here */ | 90 | /* invalidate cache here */ |
85 | /** | 91 | /** |
86 | * clears the backend and invalidates the backend | 92 | * clears the backend and invalidates the backend |
87 | */ | 93 | */ |
88 | virtual void clear() ; | 94 | void clear() ; |
89 | 95 | ||
90 | /** | 96 | /** |
91 | * add T to the backend | 97 | * add T to the backend |
92 | * @param t The item to add. | 98 | * @param t The item to add. |
93 | * @return <i>true</i> if added successfully. | 99 | * @return <i>true</i> if added successfully. |
94 | */ | 100 | */ |
@@ -105,13 +111,14 @@ public: | |||
105 | 111 | ||
106 | /** | 112 | /** |
107 | * remove the OPimRecord with uid | 113 | * remove the OPimRecord with uid |
108 | * @param uid The ID of the item to remove | 114 | * @param uid The ID of the item to remove |
109 | * @return <i>true</i> if successful. | 115 | * @return <i>true</i> if successful. |
110 | */ | 116 | */ |
111 | virtual bool remove( int uid ); | 117 | bool remove( int uid ); |
118 | bool remove( const OPimRecord& ); | ||
112 | 119 | ||
113 | /** | 120 | /** |
114 | * replace T from backend | 121 | * replace T from backend |
115 | * @param t The item to replace | 122 | * @param t The item to replace |
116 | * @return <i>true</i> if successful. | 123 | * @return <i>true</i> if successful. |
117 | */ | 124 | */ |
@@ -120,12 +127,14 @@ public: | |||
120 | void setReadAhead( uint count ); | 127 | void setReadAhead( uint count ); |
121 | /** | 128 | /** |
122 | * @internal | 129 | * @internal |
123 | */ | 130 | */ |
124 | void cache( const T& )const; | 131 | void cache( const T& )const; |
125 | void setSaneCacheSize( int ); | 132 | void setSaneCacheSize( int ); |
133 | |||
134 | QArray<int> records()const; | ||
126 | protected: | 135 | protected: |
127 | /** | 136 | /** |
128 | * invalidate the cache | 137 | * invalidate the cache |
129 | */ | 138 | */ |
130 | void invalidateCache(); | 139 | void invalidateCache(); |
131 | 140 | ||
@@ -169,12 +178,16 @@ template <class T> | |||
169 | typename OPimAccessTemplate<T>::List OPimAccessTemplate<T>::allRecords()const { | 178 | typename OPimAccessTemplate<T>::List OPimAccessTemplate<T>::allRecords()const { |
170 | QArray<int> ints = m_backEnd->allRecords(); | 179 | QArray<int> ints = m_backEnd->allRecords(); |
171 | List lis(ints, this ); | 180 | List lis(ints, this ); |
172 | return lis; | 181 | return lis; |
173 | } | 182 | } |
174 | template <class T> | 183 | template <class T> |
184 | QArray<int> OPimAccessTemplate<T>::records()const { | ||
185 | return m_backEnd->allRecords(); | ||
186 | } | ||
187 | template <class T> | ||
175 | typename OPimAccessTemplate<T>::List | 188 | typename OPimAccessTemplate<T>::List |
176 | OPimAccessTemplate<T>::queryByExample( const T& t, int sortOrder ) { | 189 | OPimAccessTemplate<T>::queryByExample( const T& t, int sortOrder ) { |
177 | QArray<int> ints = m_backEnd->queryByExample( t, sortOrder ); | 190 | QArray<int> ints = m_backEnd->queryByExample( t, sortOrder ); |
178 | 191 | ||
179 | List lis(ints, this ); | 192 | List lis(ints, this ); |
180 | return lis; | 193 | return lis; |
@@ -228,12 +241,16 @@ bool OPimAccessTemplate<T>::remove( const T& t ) { | |||
228 | template <class T> | 241 | template <class T> |
229 | bool OPimAccessTemplate<T>::remove( int uid ) { | 242 | bool OPimAccessTemplate<T>::remove( int uid ) { |
230 | m_cache.remove( uid ); | 243 | m_cache.remove( uid ); |
231 | return m_backEnd->remove( uid ); | 244 | return m_backEnd->remove( uid ); |
232 | } | 245 | } |
233 | template <class T> | 246 | template <class T> |
247 | bool OPimAccessTemplate<T>::remove( const OPimRecord& rec) { | ||
248 | return remove( rec.uid() ); | ||
249 | } | ||
250 | template <class T> | ||
234 | bool OPimAccessTemplate<T>::replace( const T& t ) { | 251 | bool OPimAccessTemplate<T>::replace( const T& t ) { |
235 | m_cache.replace( t ); | 252 | m_cache.replace( t ); |
236 | return m_backEnd->replace( t ); | 253 | return m_backEnd->replace( t ); |
237 | } | 254 | } |
238 | template <class T> | 255 | template <class T> |
239 | void OPimAccessTemplate<T>::invalidateCache() { | 256 | void OPimAccessTemplate<T>::invalidateCache() { |