summaryrefslogtreecommitdiff
path: root/libopie2/opiepim/backend/obackendfactory.h
Unidiff
Diffstat (limited to 'libopie2/opiepim/backend/obackendfactory.h') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiepim/backend/obackendfactory.h6
1 files changed, 4 insertions, 2 deletions
diff --git a/libopie2/opiepim/backend/obackendfactory.h b/libopie2/opiepim/backend/obackendfactory.h
index c8a4627..6f46652 100644
--- a/libopie2/opiepim/backend/obackendfactory.h
+++ b/libopie2/opiepim/backend/obackendfactory.h
@@ -58,43 +58,44 @@ using namespace Opie::Pim;
58namespace Opie { 58namespace Opie {
59 59
60class OBackendPrivate; 60class OBackendPrivate;
61 61
62/** 62/**
63 * This class is our factory. It will give us the default implementations 63 * This class is our factory. It will give us the default implementations
64 * of at least Todolist, Contacts and Datebook. In the future this class will 64 * of at least Todolist, Contacts and Datebook. In the future this class will
65 * allow users to switch the backend with ( XML->SQLite ) without the need 65 * allow users to switch the backend with ( XML->SQLite ) without the need
66 * to recompile.# 66 * to recompile.#
67 * This class - as the whole PIM Api - is making use of templates 67 * This class - as the whole PIM Api - is making use of templates
68 * 68 *
69 * <pre> 69 * <pre>
70 * OPimTodoAccessBackend* backend = OBackEndFactory<OPimTodoAccessBackend>::Default("todo", QString::null ); 70 * OPimTodoAccessBackend* backend = OBackEndFactory<OPimTodoAccessBackend>::Default( OPimGlobal::TODOLIST, QString::null );
71 * backend->load(); 71 * backend->load();
72 * </pre> 72 * </pre>
73 * 73 *
74 * @author Stefan Eilers 74 * @author Stefan Eilers
75 * @version 0.1 75 * @version 0.1
76 */ 76 */
77template<class T> 77template<class T>
78class OBackendFactory 78class OBackendFactory
79{ 79{
80 public: 80 public:
81 OBackendFactory() {}; 81 OBackendFactory() {};
82 82
83 /** 83 /**
84 * Returns a selected backend implementation 84 * Returns a selected backend implementation
85 * @param type the type of the backend 85 * @param type the type of the backend
86 * @param database the type of the used database 86 * @param database the type of the used database
87 * @param appName The name of your application. It will be passed on to the backend. 87 * @param appName The name of your application. It will be passed on to the backend.
88 * @param filename Filename of the database file if you don't want to access the default 88 * @param filename Filename of the database file if you don't want to access the default
89 * @see OPimGlobal()
89 */ 90 */
90 static T* create( OPimGlobal::PimType type, OPimGlobal::DatabaseStyle database, 91 static T* create( OPimGlobal::PimType type, OPimGlobal::DatabaseStyle database,
91 const QString& appName, const QString& filename = QString::null ){ 92 const QString& appName, const QString& filename = QString::null ){
92 qWarning("Selected backend for %d is: %d", type, database ); 93 qWarning("Selected backend for %d is: %d", type, database );
93 // If we should use the dafult database style, we have to request it 94 // If we should use the dafult database style, we have to request it
94 OPimGlobal::DatabaseStyle use_database = database; 95 OPimGlobal::DatabaseStyle use_database = database;
95 if ( use_database == OPimGlobal::DEFAULT ){ 96 if ( use_database == OPimGlobal::DEFAULT ){
96 use_database = defaultDB( type ); 97 use_database = defaultDB( type );
97 } 98 }
98 99
99 switch ( type ){ 100 switch ( type ){
100 case OPimGlobal::TODOLIST: 101 case OPimGlobal::TODOLIST:
@@ -156,25 +157,25 @@ class OBackendFactory
156 return (T*) NULL; 157 return (T*) NULL;
157 break; 158 break;
158 } 159 }
159 default: 160 default:
160 return (T*) NULL; 161 return (T*) NULL;
161 } 162 }
162 163
163 } 164 }
164 165
165 /** 166 /**
166 * Returns the style of the default database which is used to contact PIM data. 167 * Returns the style of the default database which is used to contact PIM data.
167 * @param type the type of the backend 168 * @param type the type of the backend
168 * @see OPimGlobal 169 * @see OPimGlobal()
169 */ 170 */
170 static OPimGlobal::DatabaseStyle defaultDB( OPimGlobal::PimType type ){ 171 static OPimGlobal::DatabaseStyle defaultDB( OPimGlobal::PimType type ){
171 QString group_name; 172 QString group_name;
172 switch ( type ){ 173 switch ( type ){
173 case OPimGlobal::TODOLIST: 174 case OPimGlobal::TODOLIST:
174 group_name = "todo"; 175 group_name = "todo";
175 break; 176 break;
176 case OPimGlobal::CONTACTLIST: 177 case OPimGlobal::CONTACTLIST:
177 group_name = "contact"; 178 group_name = "contact";
178 break; 179 break;
179 case OPimGlobal::DATEBOOK: 180 case OPimGlobal::DATEBOOK:
180 group_name = "datebook"; 181 group_name = "datebook";
@@ -199,24 +200,25 @@ class OBackendFactory
199 if ( !db_find ) 200 if ( !db_find )
200 return OPimGlobal::UNKNOWN; 201 return OPimGlobal::UNKNOWN;
201 202
202 return (OPimGlobal::DatabaseStyle) *db_find; 203 return (OPimGlobal::DatabaseStyle) *db_find;
203 } 204 }
204 205
205 206
206 /** 207 /**
207 * Returns the default backend implementation for backendName. Which one is used, is defined 208 * Returns the default backend implementation for backendName. Which one is used, is defined
208 * by the configfile "pimaccess.conf". 209 * by the configfile "pimaccess.conf".
209 * @param type The type of the backend (@see OPimGlobal()) 210 * @param type The type of the backend (@see OPimGlobal())
210 * @param appName The name of your application. It will be passed on to the backend 211 * @param appName The name of your application. It will be passed on to the backend
212 * @see OPimGlobal()
211 */ 213 */
212 static T* defaultBackend( OPimGlobal::PimType type, const QString& appName ){ 214 static T* defaultBackend( OPimGlobal::PimType type, const QString& appName ){
213 return create( type, OPimGlobal::DEFAULT, appName ); 215 return create( type, OPimGlobal::DEFAULT, appName );
214 } 216 }
215 private: 217 private:
216 OBackendPrivate* d; 218 OBackendPrivate* d;
217 219
218}; 220};
219 221
220} 222}
221 223
222#endif 224#endif