Diffstat (limited to 'libopie/pim/obackendfactory.h') (more/less context) (ignore whitespace changes)
-rw-r--r-- | libopie/pim/obackendfactory.h | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/libopie/pim/obackendfactory.h b/libopie/pim/obackendfactory.h index ad6cf5a..f3c339d 100644 --- a/libopie/pim/obackendfactory.h +++ b/libopie/pim/obackendfactory.h | |||
@@ -1,42 +1,50 @@ | |||
1 | /* | 1 | /* |
2 | * Class to manage Backends. | 2 | * Class to manage Backends. |
3 | * | 3 | * |
4 | * Copyright (c) 2002 by Stefan Eilers (Eilers.Stefan@epost.de) | 4 | * Copyright (c) 2002 by Stefan Eilers (Eilers.Stefan@epost.de) |
5 | * | 5 | * |
6 | * ===================================================================== | 6 | * ===================================================================== |
7 | *This program is free software; you can redistribute it and/or | 7 | *This program is free software; you can redistribute it and/or |
8 | *modify it under the terms of the GNU Library General Public | 8 | *modify it under the terms of the GNU Library General Public |
9 | * License as published by the Free Software Foundation; | 9 | * License as published by the Free Software Foundation; |
10 | * either version 2 of the License, or (at your option) any later | 10 | * either version 2 of the License, or (at your option) any later |
11 | * version. | 11 | * version. |
12 | * ===================================================================== | 12 | * ===================================================================== |
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.7 2003/08/01 12:30:16 eilers | ||
20 | * Merging changes from BRANCH_1_0 to HEAD | ||
21 | * | ||
22 | * Revision 1.6.4.1 2003/06/30 14:34:19 eilers | ||
23 | * Patches from Zecke: | ||
24 | * Fixing and cleaning up extraMap handling | ||
25 | * Adding d_ptr for binary compatibility in the future | ||
26 | * | ||
19 | * Revision 1.6 2003/04/13 18:07:10 zecke | 27 | * Revision 1.6 2003/04/13 18:07:10 zecke |
20 | * More API doc | 28 | * More API doc |
21 | * QString -> const QString& | 29 | * QString -> const QString& |
22 | * QString = 0l -> QString::null | 30 | * QString = 0l -> QString::null |
23 | * | 31 | * |
24 | * Revision 1.5 2003/02/21 23:31:52 zecke | 32 | * Revision 1.5 2003/02/21 23:31:52 zecke |
25 | * Add XML datebookresource | 33 | * Add XML datebookresource |
26 | * -clean up todoaccessxml header | 34 | * -clean up todoaccessxml header |
27 | * -implement some more stuff in the oeven tester | 35 | * -implement some more stuff in the oeven tester |
28 | * -extend DefaultFactory to not crash and to use datebook | 36 | * -extend DefaultFactory to not crash and to use datebook |
29 | * | 37 | * |
30 | * -reading of OEvents is working nicely.. saving will be added | 38 | * -reading of OEvents is working nicely.. saving will be added |
31 | * tomorrow | 39 | * tomorrow |
32 | * -fix spelling in ODateBookAcces | 40 | * -fix spelling in ODateBookAcces |
33 | * | 41 | * |
34 | * Revision 1.4 2002/10/14 15:55:18 eilers | 42 | * Revision 1.4 2002/10/14 15:55:18 eilers |
35 | * Redeactivate SQL.. ;) | 43 | * Redeactivate SQL.. ;) |
36 | * | 44 | * |
37 | * Revision 1.3 2002/10/10 17:08:58 zecke | 45 | * Revision 1.3 2002/10/10 17:08:58 zecke |
38 | * The Cache is finally in place | 46 | * The Cache is finally in place |
39 | * I tested it with my todolist and it 'works' for 10.000 todos the hits are awesome ;) | 47 | * I tested it with my todolist and it 'works' for 10.000 todos the hits are awesome ;) |
40 | * 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.... | 48 | * 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.... |
41 | * I still have to fully implement read ahead | 49 | * I still have to fully implement read ahead |
42 | * This change is bic but sc | 50 | * This change is bic but sc |
@@ -47,48 +55,50 @@ | |||
47 | * compile itself would need to install libsqlite, libopiesql... | 55 | * compile itself would need to install libsqlite, libopiesql... |
48 | * Therefore, the backend currently uses XML only.. | 56 | * Therefore, the backend currently uses XML only.. |
49 | * | 57 | * |
50 | * Revision 1.1 2002/10/07 17:35:01 eilers | 58 | * Revision 1.1 2002/10/07 17:35:01 eilers |
51 | * added OBackendFactory for advanced backend access | 59 | * added OBackendFactory for advanced backend access |
52 | * | 60 | * |
53 | * | 61 | * |
54 | * ===================================================================== | 62 | * ===================================================================== |
55 | */ | 63 | */ |
56 | #ifndef OPIE_BACKENDFACTORY_H_ | 64 | #ifndef OPIE_BACKENDFACTORY_H_ |
57 | #define OPIE_BACKENDFACTORY_H_ | 65 | #define OPIE_BACKENDFACTORY_H_ |
58 | 66 | ||
59 | #include <qstring.h> | 67 | #include <qstring.h> |
60 | #include <qasciidict.h> | 68 | #include <qasciidict.h> |
61 | #include <qpe/config.h> | 69 | #include <qpe/config.h> |
62 | 70 | ||
63 | #include "otodoaccessxml.h" | 71 | #include "otodoaccessxml.h" |
64 | #include "ocontactaccessbackend_xml.h" | 72 | #include "ocontactaccessbackend_xml.h" |
65 | #include "odatebookaccessbackend_xml.h" | 73 | #include "odatebookaccessbackend_xml.h" |
66 | 74 | ||
67 | #ifdef __USE_SQL | 75 | #ifdef __USE_SQL |
68 | #include "otodoaccesssql.h" | 76 | #include "otodoaccesssql.h" |
69 | #endif | 77 | #endif |
70 | 78 | ||
79 | class OBackendPrivate; | ||
80 | |||
71 | /** | 81 | /** |
72 | * This class is our factory. It will give us the default implementations | 82 | * This class is our factory. It will give us the default implementations |
73 | * of at least Todolist, Contacts and Datebook. In the future this class will | 83 | * of at least Todolist, Contacts and Datebook. In the future this class will |
74 | * allow users to switch the backend with ( XML->SQLite ) without the need | 84 | * allow users to switch the backend with ( XML->SQLite ) without the need |
75 | * to recompile.# | 85 | * to recompile.# |
76 | * This class as the whole PIM Api is making use of templates | 86 | * This class as the whole PIM Api is making use of templates |
77 | * | 87 | * |
78 | * <pre> | 88 | * <pre> |
79 | * OTodoAccessBackend* backend = OBackEndFactory<OTodoAccessBackend>::Default("todo", QString::null ); | 89 | * OTodoAccessBackend* backend = OBackEndFactory<OTodoAccessBackend>::Default("todo", QString::null ); |
80 | * backend->load(); | 90 | * backend->load(); |
81 | * </pre> | 91 | * </pre> |
82 | * | 92 | * |
83 | * @author Stefan Eilers | 93 | * @author Stefan Eilers |
84 | * @version 0.1 | 94 | * @version 0.1 |
85 | */ | 95 | */ |
86 | template<class T> | 96 | template<class T> |
87 | class OBackendFactory | 97 | class OBackendFactory |
88 | { | 98 | { |
89 | public: | 99 | public: |
90 | OBackendFactory() {}; | 100 | OBackendFactory() {}; |
91 | 101 | ||
92 | enum BACKENDS { | 102 | enum BACKENDS { |
93 | TODO, | 103 | TODO, |
94 | CONTACT, | 104 | CONTACT, |
@@ -127,28 +137,30 @@ class OBackendFactory | |||
127 | if ( backend == "sql" ) | 137 | if ( backend == "sql" ) |
128 | return (T*) new OTodoAccessBackendSQL(""); | 138 | return (T*) new OTodoAccessBackendSQL(""); |
129 | #else | 139 | #else |
130 | if ( backend == "sql" ) | 140 | if ( backend == "sql" ) |
131 | qWarning ("OBackendFactory:: sql Backend not implemented! Using XML instead!"); | 141 | qWarning ("OBackendFactory:: sql Backend not implemented! Using XML instead!"); |
132 | #endif | 142 | #endif |
133 | 143 | ||
134 | return (T*) new OTodoAccessXML( appName ); | 144 | return (T*) new OTodoAccessXML( appName ); |
135 | case CONTACT: | 145 | case CONTACT: |
136 | if ( backend == "sql" ) | 146 | if ( backend == "sql" ) |
137 | qWarning ("OBackendFactory:: sql Backend not implemented! Using XML instead!"); | 147 | qWarning ("OBackendFactory:: sql Backend not implemented! Using XML instead!"); |
138 | 148 | ||
139 | return (T*) new OContactAccessBackend_XML( appName ); | 149 | return (T*) new OContactAccessBackend_XML( appName ); |
140 | case DATE: | 150 | case DATE: |
141 | if ( backend == "sql" ) | 151 | if ( backend == "sql" ) |
142 | qWarning("OBackendFactory:: sql Backend not implemented! Using XML instead!"); | 152 | qWarning("OBackendFactory:: sql Backend not implemented! Using XML instead!"); |
143 | 153 | ||
144 | return (T*) new ODateBookAccessBackend_XML( appName ); | 154 | return (T*) new ODateBookAccessBackend_XML( appName ); |
145 | default: | 155 | default: |
146 | return NULL; | 156 | return NULL; |
147 | } | 157 | } |
148 | 158 | ||
149 | 159 | ||
150 | } | 160 | } |
161 | private: | ||
162 | OBackendPrivate* d; | ||
151 | }; | 163 | }; |
152 | 164 | ||
153 | 165 | ||
154 | #endif | 166 | #endif |