summaryrefslogtreecommitdiff
path: root/libopie/pim/opimaccessbackend.h
Unidiff
Diffstat (limited to 'libopie/pim/opimaccessbackend.h') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/pim/opimaccessbackend.h16
1 files changed, 14 insertions, 2 deletions
diff --git a/libopie/pim/opimaccessbackend.h b/libopie/pim/opimaccessbackend.h
index 4f00bc9..e268f4f 100644
--- a/libopie/pim/opimaccessbackend.h
+++ b/libopie/pim/opimaccessbackend.h
@@ -10,25 +10,27 @@
10/** 10/**
11 * OPimAccessBackend is the base class 11 * OPimAccessBackend is the base class
12 * for all private backends 12 * for all private backends
13 * it operates on OPimRecord as the base class 13 * it operates on OPimRecord as the base class
14 * and it's responsible for fast manipulating 14 * and it's responsible for fast manipulating
15 * the resource the implementation takes care 15 * the resource the implementation takes care
16 * of 16 * of
17 */ 17 */
18template <class T = OPimRecord> 18template <class T = OPimRecord>
19class OPimAccessBackend { 19class OPimAccessBackend {
20public: 20public:
21 typedef OTemplateBase<T> Frontend; 21 typedef OTemplateBase<T> Frontend;
22 OPimAccessBackend(); 22
23 /** The access hint from the frontend */
24 OPimAccessBackend(int access = 0);
23 virtual ~OPimAccessBackend(); 25 virtual ~OPimAccessBackend();
24 26
25 /** 27 /**
26 * load the resource 28 * load the resource
27 */ 29 */
28 virtual bool load() = 0; 30 virtual bool load() = 0;
29 31
30 /** 32 /**
31 * reload the resource 33 * reload the resource
32 */ 34 */
33 virtual bool reload() = 0; 35 virtual bool reload() = 0;
34 36
@@ -79,41 +81,47 @@ public:
79 virtual bool replace( const T& t ) = 0; 81 virtual bool replace( const T& t ) = 0;
80 82
81 /* 83 /*
82 * setTheFrontEnd!!! 84 * setTheFrontEnd!!!
83 */ 85 */
84 void setFrontend( Frontend* front ); 86 void setFrontend( Frontend* front );
85 87
86 /** 88 /**
87 * set the read ahead count 89 * set the read ahead count
88 */ 90 */
89 void setReadAhead( uint count ); 91 void setReadAhead( uint count );
90protected: 92protected:
93 int access()const;
91 void cache( const T& t )const; 94 void cache( const T& t )const;
92 95
93 /** 96 /**
94 * use a prime number here! 97 * use a prime number here!
95 */ 98 */
96 void setSaneCacheSize( int ); 99 void setSaneCacheSize( int );
97 100
98 uint readAhead()const; 101 uint readAhead()const;
99 102
100private: 103private:
104 class Private;
105 Private* d;
101 Frontend* m_front; 106 Frontend* m_front;
102 uint m_read; 107 uint m_read;
108 int m_acc;
103 109
104}; 110};
105 111
106template <class T> 112template <class T>
107OPimAccessBackend<T>::OPimAccessBackend() { 113OPimAccessBackend<T>::OPimAccessBackend(int acc)
114 : m_acc( acc )
115{
108 m_front = 0l; 116 m_front = 0l;
109} 117}
110template <class T> 118template <class T>
111OPimAccessBackend<T>::~OPimAccessBackend() { 119OPimAccessBackend<T>::~OPimAccessBackend() {
112 120
113} 121}
114template <class T> 122template <class T>
115void OPimAccessBackend<T>::setFrontend( Frontend* fr ) { 123void OPimAccessBackend<T>::setFrontend( Frontend* fr ) {
116 m_front = fr; 124 m_front = fr;
117} 125}
118template <class T> 126template <class T>
119void OPimAccessBackend<T>::cache( const T& t )const { 127void OPimAccessBackend<T>::cache( const T& t )const {
@@ -129,13 +137,17 @@ template <class T>
129T OPimAccessBackend<T>::find( int uid, const QArray<int>&, 137T OPimAccessBackend<T>::find( int uid, const QArray<int>&,
130 uint, typename Frontend::CacheDirection )const { 138 uint, typename Frontend::CacheDirection )const {
131 return find( uid ); 139 return find( uid );
132} 140}
133template <class T> 141template <class T>
134void OPimAccessBackend<T>::setReadAhead( uint count ) { 142void OPimAccessBackend<T>::setReadAhead( uint count ) {
135 m_read = count; 143 m_read = count;
136} 144}
137template <class T> 145template <class T>
138uint OPimAccessBackend<T>::readAhead()const { 146uint OPimAccessBackend<T>::readAhead()const {
139 return m_read; 147 return m_read;
140} 148}
149template <class T>
150int OPimAccessBackend<T>::access()const {
151 return m_acc;
152}
141#endif 153#endif