-rw-r--r-- | libopie2/opiepim/backend/obackendfactory.h | 20 | ||||
-rw-r--r-- | libopie2/opiepim/backend/opimaccessbackend.h | 40 |
2 files changed, 53 insertions, 7 deletions
diff --git a/libopie2/opiepim/backend/obackendfactory.h b/libopie2/opiepim/backend/obackendfactory.h index f11f029..89b8c58 100644 --- a/libopie2/opiepim/backend/obackendfactory.h +++ b/libopie2/opiepim/backend/obackendfactory.h | |||
@@ -13,37 +13,45 @@ | |||
13 | * ToDo: Use plugins | 13 | * ToDo: Use plugins |
14 | * ===================================================================== | 14 | * ===================================================================== |
15 | * Version: $Id$ | 15 | * Version: $Id$ |
16 | * ===================================================================== | 16 | * ===================================================================== |
17 | * History: | 17 | * History: |
18 | * $Log$ | 18 | * $Log$ |
19 | * Revision 1.3 2002/10/10 17:08:58 zecke | ||
20 | * The Cache is finally in place | ||
21 | * I tested it with my todolist and it 'works' for 10.000 todos the hits are awesome ;) | ||
22 | * The read ahead functionality does not make sense for XMLs backends because most of the stuff is already in memory. While using readahead on SQL makes things a lot faster.... | ||
23 | * I still have to fully implement read ahead | ||
24 | * This change is bic but sc | ||
25 | * | ||
19 | * Revision 1.2 2002/10/08 09:27:36 eilers | 26 | * Revision 1.2 2002/10/08 09:27:36 eilers |
20 | * Fixed libopie.pro to include the new pim-API. | 27 | * Fixed libopie.pro to include the new pim-API. |
21 | * The SQL-Stuff is currently deactivated. Otherwise everyone who wants to | 28 | * The SQL-Stuff is currently deactivated. Otherwise everyone who wants to |
22 | * compile itself would need to install libsqlite, libopiesql... | 29 | * compile itself would need to install libsqlite, libopiesql... |
23 | * Therefore, the backend currently uses XML only.. | 30 | * Therefore, the backend currently uses XML only.. |
24 | * | 31 | * |
25 | * Revision 1.1 2002/10/07 17:35:01 eilers | 32 | * Revision 1.1 2002/10/07 17:35:01 eilers |
26 | * added OBackendFactory for advanced backend access | 33 | * added OBackendFactory for advanced backend access |
27 | * | 34 | * |
28 | * | 35 | * |
29 | * ===================================================================== | 36 | * ===================================================================== |
30 | */ | 37 | */ |
31 | #ifndef __OPIE_BACKENDFACTORY_H_ | 38 | #ifndef OPIE_BACKENDFACTORY_H_ |
32 | #define __OPIE_BACKENDFACTORY_H_ | 39 | #define OPIE_BACKENDFACTORY_H_ |
33 | 40 | ||
34 | #include <qstring.h> | 41 | #include <qstring.h> |
35 | #include <qasciidict.h> | 42 | #include <qasciidict.h> |
36 | #include <qpe/config.h> | 43 | #include <qpe/config.h> |
37 | 44 | ||
38 | #include "otodoaccessxml.h" | 45 | #include "otodoaccessxml.h" |
39 | #include "ocontactaccessbackend_xml.h" | 46 | #include "ocontactaccessbackend_xml.h" |
40 | 47 | ||
41 | #ifdef __USE_SQL | 48 | /*#ifdef __USE_SQL |
42 | #include "otodoaccesssql.h" | 49 | #include "otodoaccesssql.h" |
43 | #endif | 50 | #endif |
51 | */ | ||
44 | 52 | ||
45 | template<class T> | 53 | template<class T> |
46 | class OBackendFactory | 54 | class OBackendFactory |
47 | { | 55 | { |
48 | public: | 56 | public: |
49 | OBackendFactory() {}; | 57 | OBackendFactory() {}; |
@@ -69,19 +77,19 @@ class OBackendFactory | |||
69 | 77 | ||
70 | qWarning ("TODO is: %d", TODO); | 78 | qWarning ("TODO is: %d", TODO); |
71 | qWarning ("CONTACT is: %d", CONTACT); | 79 | qWarning ("CONTACT is: %d", CONTACT); |
72 | 80 | ||
73 | switch ( *dict.take( backendName ) ){ | 81 | switch ( *dict.take( backendName ) ){ |
74 | case TODO: | 82 | case TODO: |
75 | #ifdef __USE_SQL | 83 | /*#ifdef __USE_SQL |
76 | if ( backend == "sql" ) | 84 | if ( backend == "sql" ) |
77 | return (T*) new OTodoAccessBackendSQL(""); | 85 | return (T*) new OTodoAccessBackendSQL(""); |
78 | #else | 86 | #else*/ |
79 | if ( backend == "sql" ) | 87 | if ( backend == "sql" ) |
80 | qWarning ("OBackendFactory:: sql Backend not implemented! Using XML instead!"); | 88 | qWarning ("OBackendFactory:: sql Backend not implemented! Using XML instead!"); |
81 | #endif | 89 | //#endif |
82 | 90 | ||
83 | return (T*) new OTodoAccessXML( appName ); | 91 | return (T*) new OTodoAccessXML( appName ); |
84 | case CONTACT: | 92 | case CONTACT: |
85 | if ( backend == "sql" ) | 93 | if ( backend == "sql" ) |
86 | qWarning ("OBackendFactory:: sql Backend not implemented! Using XML instead!"); | 94 | qWarning ("OBackendFactory:: sql Backend not implemented! Using XML instead!"); |
87 | 95 | ||
diff --git a/libopie2/opiepim/backend/opimaccessbackend.h b/libopie2/opiepim/backend/opimaccessbackend.h index c27acbb..27d3cb8 100644 --- a/libopie2/opiepim/backend/opimaccessbackend.h +++ b/libopie2/opiepim/backend/opimaccessbackend.h | |||
@@ -1,11 +1,12 @@ | |||
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 | 5 | ||
6 | #include <opie/otemplatebase.h> | ||
6 | #include <opie/opimrecord.h> | 7 | #include <opie/opimrecord.h> |
7 | 8 | ||
8 | 9 | ||
9 | /** | 10 | /** |
10 | * OPimAccessBackend is the base class | 11 | * OPimAccessBackend is the base class |
11 | * for all private backends | 12 | * for all private backends |
@@ -14,12 +15,13 @@ | |||
14 | * the resource the implementation takes care | 15 | * the resource the implementation takes care |
15 | * of | 16 | * of |
16 | */ | 17 | */ |
17 | template <class T = OPimRecord> | 18 | template <class T = OPimRecord> |
18 | class OPimAccessBackend { | 19 | class OPimAccessBackend { |
19 | public: | 20 | public: |
21 | typedef OTemplateBase<T> Frontend; | ||
20 | OPimAccessBackend(); | 22 | OPimAccessBackend(); |
21 | virtual ~OPimAccessBackend(); | 23 | virtual ~OPimAccessBackend(); |
22 | 24 | ||
23 | /** | 25 | /** |
24 | * load the resource | 26 | * load the resource |
25 | */ | 27 | */ |
@@ -51,12 +53,14 @@ public: | |||
51 | /** | 53 | /** |
52 | * find the OPimRecord with uid @param uid | 54 | * find the OPimRecord with uid @param uid |
53 | * returns T and T.isEmpty() if nothing was found | 55 | * returns T and T.isEmpty() if nothing was found |
54 | */ | 56 | */ |
55 | virtual T find(int uid )const = 0; | 57 | virtual T find(int uid )const = 0; |
56 | 58 | ||
59 | virtual T find(int uid, const QArray<int>& items, | ||
60 | uint current, Frontend::CacheDirection )const ; | ||
57 | /** | 61 | /** |
58 | * clear the back end | 62 | * clear the back end |
59 | */ | 63 | */ |
60 | virtual void clear() = 0; | 64 | virtual void clear() = 0; |
61 | 65 | ||
62 | /** | 66 | /** |
@@ -71,19 +75,53 @@ public: | |||
71 | 75 | ||
72 | /** | 76 | /** |
73 | * replace a record with T.uid() | 77 | * replace a record with T.uid() |
74 | */ | 78 | */ |
75 | virtual bool replace( const T& t ) = 0; | 79 | virtual bool replace( const T& t ) = 0; |
76 | 80 | ||
81 | /* | ||
82 | * setTheFrontEnd!!! | ||
83 | */ | ||
84 | void setFrontend( Frontend* front ); | ||
85 | |||
86 | protected: | ||
87 | void cache( const T& t )const; | ||
88 | |||
89 | /** | ||
90 | * use a prime number here! | ||
91 | */ | ||
92 | void setSaneCacheSize( int ); | ||
93 | |||
94 | private: | ||
95 | Frontend* m_front; | ||
77 | 96 | ||
78 | }; | 97 | }; |
79 | 98 | ||
80 | template <class T> | 99 | template <class T> |
81 | OPimAccessBackend<T>::OPimAccessBackend() { | 100 | OPimAccessBackend<T>::OPimAccessBackend() { |
82 | 101 | m_front = 0l; | |
83 | } | 102 | } |
84 | template <class T> | 103 | template <class T> |
85 | OPimAccessBackend<T>::~OPimAccessBackend() { | 104 | OPimAccessBackend<T>::~OPimAccessBackend() { |
86 | 105 | ||
87 | } | 106 | } |
107 | template <class T> | ||
108 | void OPimAccessBackend<T>::setFrontend( Frontend* fr ) { | ||
109 | m_front = fr; | ||
110 | } | ||
111 | template <class T> | ||
112 | void OPimAccessBackend<T>::cache( const T& t )const { | ||
113 | if (m_front ) | ||
114 | m_front->cache( t ); | ||
115 | } | ||
116 | template <class T> | ||
117 | void OPimAccessBackend<T>::setSaneCacheSize( int size) { | ||
118 | if (m_front ) | ||
119 | m_front->setSaneCacheSize( size ); | ||
120 | } | ||
121 | template <class T> | ||
122 | T OPimAccessBackend<T>::find( int uid, const QArray<int>&, | ||
123 | uint, Frontend::CacheDirection )const { | ||
124 | return find( uid ); | ||
125 | } | ||
88 | 126 | ||
89 | #endif | 127 | #endif |