Better wording
[kdepim.git] / messageviewer / pluginloaderbase.h
blob79c31fbc731a612ea8768f06af93b03385f3276e
1 /* -*- c++ -*-
2 This file is part of libkdepim.
4 Copyright (c) 2002,2004 Marc Mutz <mutz@kde.org>
6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public
8 License as published by the Free Software Foundation; either
9 version 2 of the License, or (at your option) any later version.
11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details.
16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 Boston, MA 02110-1301, USA.
22 #ifndef PLUGINLOADERBASE_H
23 #define PLUGINLOADERBASE_H
25 #include <QString>
26 #include <QMap>
27 #include <KLibrary>
29 class QStringList;
31 class PluginMetaData
33 public:
34 PluginMetaData() {}
35 PluginMetaData( const QString & lib, const QString & name,
36 const QString & comment )
37 : library( lib ), nameLabel( name ),
38 descriptionLabel( comment ), loaded( false ) {}
39 QString library;
40 QString nameLabel;
41 QString descriptionLabel;
42 bool loaded;
45 class PluginLoaderBase
47 protected:
48 PluginLoaderBase();
49 virtual ~PluginLoaderBase();
51 public:
52 /** Returns a list of all available plugin objects (of kind @p T) */
53 QStringList types() const;
55 /** Returns the @ref PluginMetaData structure for a given type */
56 const PluginMetaData * infoForName( const QString & type ) const;
58 /** Overload this method in subclasses to call @ref doScan with
59 the right @p path argument */
60 virtual void scan() = 0;
62 protected:
63 /** Rescans the plugin directory to find any newly installed
64 plugins. Extend this method in subclasses to add any
65 builtins. Subclasses must call this explicitly. It's not
66 called for them in the constructor.
67 **/
68 void doScan( const char * path );
70 /** Returns a pointer to symbol @p main_func in the library that
71 implements the plugin of type @p type */
72 KLibrary::void_function_ptr mainFunc( const QString & type, const char * main_func ) const;
74 private:
75 const KLibrary * openLibrary( const QString & libName ) const;
76 mutable QMap< QString, PluginMetaData > mPluginMap;
78 class Private;
79 Private * d;
82 #endif // PLUGINLOADERBASE_H