summaryrefslogtreecommitdiffabout
path: root/kabc/formatfactory.h
Unidiff
Diffstat (limited to 'kabc/formatfactory.h') (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/formatfactory.h104
1 files changed, 104 insertions, 0 deletions
diff --git a/kabc/formatfactory.h b/kabc/formatfactory.h
new file mode 100644
index 0000000..9612374
--- a/dev/null
+++ b/kabc/formatfactory.h
@@ -0,0 +1,104 @@
1/*
2 This file is part of libkabc.
3 Copyright (c) 2002 Tobias Koenig <tokoe@kde.org>
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
14
15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
19*/
20
21#ifndef KABC_FORMATFACTORY_H
22#define KABC_FORMATFACTORY_H
23
24#include <qdict.h>
25#include <qstring.h>
26
27#include <kconfig.h>
28#ifndef DESKTOP_VERSION
29#include <klibloader.h>
30#endif
31
32#include "formatplugin.h"
33
34namespace KABC {
35
36struct FormatInfo
37{
38 QString library;
39 QString nameLabel;
40 QString descriptionLabel;
41};
42
43/**
44 * Class for loading format plugins.
45 *
46 * Example:
47 *
48 * <pre>
49 * KABC::FormatFactory *factory = KABC::FormatFactory::self();
50 *
51 * QStringList list = factory->formats();
52 * QStringList::Iterator it;
53 * for ( it = list.begin(); it != list.end(); ++it ) {
54 * KABC::FormatPlugin *format = factory->format( (*it) );
55 * // do something with format
56 * }
57 * </pre>
58 */
59class FormatFactory
60{
61 public:
62
63 /**
64 Destructor.
65 */
66 ~FormatFactory();
67
68 /**
69 * Returns the global format factory.
70 */
71 static FormatFactory *self();
72
73 /**
74 * Returns a pointer to a format object or a null pointer
75 * if format type doesn't exist.
76 *
77 * @param type The type of the format, returned by @ref formats()
78 */
79 FormatPlugin *format( const QString &type );
80
81 /**
82 * Returns a list of all available format types.
83 */
84 QStringList formats();
85
86 /**
87 * Returns the info structure for a special type.
88 */
89 FormatInfo *info( const QString &type );
90
91 protected:
92 FormatFactory();
93
94 private:
95#ifndef DESKTOP_VERSION
96 KLibrary *openLibrary( const QString& libName );
97#endif
98 static FormatFactory *mSelf;
99
100 QDict<FormatInfo> mFormatList;
101};
102
103}
104#endif