summaryrefslogtreecommitdiff
path: root/libopie2/opiepim/core/opimaccessfactory.h
Unidiff
Diffstat (limited to 'libopie2/opiepim/core/opimaccessfactory.h') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiepim/core/opimaccessfactory.h100
1 files changed, 100 insertions, 0 deletions
diff --git a/libopie2/opiepim/core/opimaccessfactory.h b/libopie2/opiepim/core/opimaccessfactory.h
new file mode 100644
index 0000000..ba99a15
--- a/dev/null
+++ b/libopie2/opiepim/core/opimaccessfactory.h
@@ -0,0 +1,100 @@
1/*
2 This file is part of the Opie Project
3 Copyright (C) Stefan Eilers <eilers.stefan@epost.de>
4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org>
5 .=l.
6 .>+-=
7 _;:, .> :=|. This program is free software; you can
8.> <`_, > . <= redistribute it and/or modify it under
9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
10.="- .-=="i, .._ License as published by the Free Software
11 - . .-<_> .<> Foundation; either version 2 of the License,
12 ._= =} : or (at your option) any later version.
13 .%`+i> _;_.
14 .i_,=:_. -<s. This program is distributed in the hope that
15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
16 : .. .:, . . . without even the implied warranty of
17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.= = ; Library General Public License for more
20++= -. .` .: details.
21 : = ...= . :.=-
22 -. .:....=;==+<; You should have received a copy of the GNU
23 -_. . . )=. = Library General Public License along with
24 -- :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA.
28*/
29
30#ifndef __OPIE_OPIMACCESSFACTORY_H_
31#define __OPIE_OPIMACCESSFACTORY_H_
32
33#include <opie2/opimglobal.h>
34#include <opie2/obackendfactory.h>
35#include <opie2/ocontactaccess.h>
36#include <opie2/otodoaccess.h>
37#include <opie2/odatebookaccess.h>
38
39using namespace Opie::Pim;
40
41namespace Opie {
42
43
44/**
45 * This class is our factory for creating PIM access objects. You should use these objects to load, store and search
46 * information in our PIM databases. Currently we support objects for accessing the datebook, the contact- and the
47 * todolist.
48 * @see OPimGlobal for more information of used values.
49 *
50 * This class - as the whole PIM Api - is making use of templates
51 *
52 * Example for getting an access object for the XML database of todolist:
53 * <pre>
54 * OPimTodoAccess* access = OPimAccessFactory<OPimTodoAccess>::create( OPimGlobal::TODOLIST, OPimGlobal::XML, "example" );
55 * </pre>
56 *
57 * @author Stefan Eilers
58 * @version 0.1
59 */
60 */
61
62template<class T>
63class OPimAccessFactory
64{
65 public:
66
67 // Maybe we should introduce a global class for storing such global enums
68 // (something like opimglobal.h) ? (eilers)
69
70 OPimAccessFactory() {};
71
72 /**
73 * Returns the selected PIM access-object.
74 * @param type Type of the selected database (addressbook, todolist or datebook)
75 * @param dbStyle Which database style should be used (xml, sql, vcard)
76 * @param appName "Name" of your application. This should be any constant string which is used
77 * by some backends for creating special files (i.e.journal files). Please keep the
78 * string unique for your application !
79 * @see OPimGlobal
80 */
81 static T* create( OPimGlobal::PimType type, OPimGlobal::DatabaseStyle dbStyle, const QString& appName ){
82
83 switch ( type ){
84 case OPimGlobal::TODOLIST:
85 return dynamic_cast<T*>( new OPimTodoAccess( OBackendFactory<OPimTodoAccessBackend>::create( type, dbStyle, appName ) ) );
86 case OPimGlobal::CONTACTLIST:
87 return dynamic_cast<T*>( new OPimContactAccess( QString::null, QString::null, OBackendFactory<OPimContactAccessBackend>::create( type, dbStyle, appName ) ) );
88 case OPimGlobal::DATEBOOK:
89 return dynamic_cast<T*>( new ODateBookAccess( OBackendFactory<ODateBookAccessBackend>::create( type, dbStyle, appName ) ) );
90 default:
91 return 0l;
92
93 }
94 }
95};
96
97}
98
99
100#endif