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