libkdepim
KPIM::PluginLoader< T, T_config > Class Template Reference
#include <pluginloader.h>
Inheritance diagram for KPIM::PluginLoader< T, T_config >:

Detailed Description
template<typename T, typename T_config>
class KPIM::PluginLoader< T, T_config >
A generic plugin loader for when KPart::Plugin is overkill.
This is a generic plugin loader / factory for small plugins that don't want to be QObjects.
Usage
A PluginLoader takes two template arguments,T
and T_config
:
- T
- The type of object to return
- T_config::mainfunc
- The suffix of the factory function to call in the library to obtain a new object of type
T
. The string passed toKLibrary::symbol()
islibName_mainfunc
. - T_config::path
- The search pattern for
.desktop
files containing the plugin descriptions. This is the string passed as thefilter
argument toKStandardDirs::findAllResources
.
The last two parameters being strings, they are passed via an encapsulating class, of which mainfunc
and path
are public static members:
struct MyObjectPluginLoaderConfig { static const char * const mainfunc; static const char * const path; }; const char * const MyObjectPluginLoaderConfig::mainfunc = "myapp_create_myobject"; const char * const MyObjectPluginLoaderConfig::path = "myapp/plugins/ *.desktop";
You would then use a typedef
to create a less unwieldy name for your plugin loader:
typedef KPIM::PluginLoader< MyObject, MyObjectPluginLoaderConfig > MyObjectPluginLoader;
All of this is what the KPIM_DEFINE_PLUGIN_LOADER(pluginloadername,type,mainfunc,path)
macro achieves.
Definition at line 79 of file pluginloader.h.
Public Member Functions | |
virtual | ~PluginLoader () |
virtual void | scan () |
virtual T * | createForName (const QString &type) const |
Static Public Member Functions | |
static PluginLoader< T, T_config > * | instance () |
Protected Member Functions | |
PluginLoader () |
Member Function Documentation
static PluginLoader<T,T_config>* KPIM::PluginLoader< T, T_config >::instance | ( | ) | [inline, static] |
virtual void KPIM::PluginLoader< T, T_config >::scan | ( | ) | [inline, virtual] |
Rescans the plugin directory to find any newly installed plugins.
Implements KPIM::PluginLoaderBase.
Definition at line 101 of file pluginloader.h.
virtual T* KPIM::PluginLoader< T, T_config >::createForName | ( | const QString & | type | ) | const [inline, virtual] |
Returns a pointer to a plugin object (of type T
) or a null pointer if the type wasn't found.
You can extend this method for when you want to handle builtin types
Definition at line 108 of file pluginloader.h.
The documentation for this class was generated from the following file: