KDECore
kpluginfactory.h File Reference
#include "kdecore_export.h"
#include <QtCore/QObject>
#include <QtCore/QVariant>
#include <QtCore/QStringList>
#include <kcomponentdata.h>
#include <kexportplugin.h>
#include <kglobal.h>


Go to the source code of this file.
Namespaces | |
namespace | KParts |
Classes | |
class | KPluginFactory |
If you develop a library that is to be loaded dynamically at runtime, then you should return a pointer to a KPluginFactory. More... | |
struct | KPluginFactory::InheritanceChecker< impl > |
This is used to detect the arguments need for the constructor of plugin classes. More... | |
Defines | |
#define | K_PLUGIN_FACTORY(name, pluginRegistrations) K_PLUGIN_FACTORY_WITH_BASEFACTORY(name, KPluginFactory, pluginRegistrations) |
#define | K_PLUGIN_FACTORY_DECLARATION(name) K_PLUGIN_FACTORY_DECLARATION_WITH_BASEFACTORY(name, KPluginFactory) |
#define | K_PLUGIN_FACTORY_DECLARATION_WITH_BASEFACTORY(name, baseFactory) |
#define | K_PLUGIN_FACTORY_DEFINITION(name, pluginRegistrations) K_PLUGIN_FACTORY_DEFINITION_WITH_BASEFACTORY(name, KPluginFactory, pluginRegistrations) |
#define | K_PLUGIN_FACTORY_DEFINITION_WITH_BASEFACTORY(name, baseFactory, pluginRegistrations) |
#define | K_PLUGIN_FACTORY_WITH_BASEFACTORY(name, baseFactory, pluginRegistrations) |
Typedefs | |
typedef KPluginFactory | KLibFactory |
Define Documentation
#define K_PLUGIN_FACTORY | ( | name, | |||
pluginRegistrations | ) | K_PLUGIN_FACTORY_WITH_BASEFACTORY(name, KPluginFactory, pluginRegistrations) [related] |
Defines a KPluginFactory subclass with two constructors and a static componentData function.
The first constructor takes the arguments (const char *componentName, const char *catalogName, QObject *parent). The second constructor takes (const KAboutData *aboutData, QObject *parent).
The static componentData method returns the same KComponentData object as the KPluginFactory::componentData function returns. As you normally don't have a pointer to the factory object in the plugin code the static componentData function is a convenient way to access the KComponentData.
- Parameters:
-
name The name of the KPluginFactory derived class. This is the name you'll need for K_EXPORT_PLUGIN pluginRegistrations This is code inserted into the constructors the class. You'll want to call registerPlugin from there.
#include <KPluginFactory> #include <KPluginLoader> #include <plugininterface.h> class MyPlugin; K_PLUGIN_FACTORY(MyPluginFactory, registerPlugin<MyPlugin>(); ) K_EXPORT_PLUGIN(MyPluginFactory("componentName", "catalogName")) // or: static KAboutData createAboutData() { KAboutData aboutData("myplugin", "myplugin", ki18n("MyPlugin"), "0.1", ki18n("a description of the plugin"), KAboutData::License_LGPL, ki18n("Copyright (C) 2007 Your Name")); aboutData.addAuthor(ki18n("Your Name"), ...); return aboutData; } K_EXPORT_PLUGIN(MyPluginFactory(createAboutData())) class MyPlugin : public PluginInterface { ... KComponentData kcd = MyPluginFactory::componentData(); ... };
Definition at line 127 of file kpluginfactory.h.
#define K_PLUGIN_FACTORY_DECLARATION | ( | name | ) | K_PLUGIN_FACTORY_DECLARATION_WITH_BASEFACTORY(name, KPluginFactory) [related] |
K_PLUGIN_FACTORY_DECLARATION declares the KPluginFactory subclass.
This macro can be used in a header file.
- Parameters:
-
name The name of the KPluginFactory derived class. This is the name you'll need for K_EXPORT_PLUGIN
Definition at line 140 of file kpluginfactory.h.
#define K_PLUGIN_FACTORY_DECLARATION_WITH_BASEFACTORY | ( | name, | |||
baseFactory | ) |
Value:
class name : public baseFactory \ { \ public: \ explicit name(const char * = 0, const char * = 0, QObject * = 0); \ explicit name(const KAboutData &, QObject * = 0); \ ~name(); \ static KComponentData componentData(); \ private: \ void init(); \ };
Definition at line 37 of file kpluginfactory.h.
#define K_PLUGIN_FACTORY_DEFINITION | ( | name, | |||
pluginRegistrations | ) | K_PLUGIN_FACTORY_DEFINITION_WITH_BASEFACTORY(name, KPluginFactory, pluginRegistrations) [related] |
K_PLUGIN_FACTORY_DECLARATION defines the KPluginFactory subclass.
This macro can not be used in a header file.
- Parameters:
-
name The name of the KPluginFactory derived class. This is the name you'll need for K_EXPORT_PLUGIN pluginRegistrations This is code inserted into the constructors the class. You'll want to call registerPlugin from there.
Definition at line 156 of file kpluginfactory.h.
#define K_PLUGIN_FACTORY_DEFINITION_WITH_BASEFACTORY | ( | name, | |||
baseFactory, | |||||
pluginRegistrations | ) |
Value:
K_GLOBAL_STATIC(KComponentData, name##factorycomponentdata) \ name::name(const char *componentName, const char *catalogName, QObject *parent) \ : baseFactory(componentName, catalogName, parent) { init(); } \ name::name(const KAboutData &aboutData, QObject *parent) \ : baseFactory(aboutData, parent) { init(); } \ void name::init() \ { \ if (name##factorycomponentdata->isValid()) \ setComponentData(*name##factorycomponentdata); \ else \ *name##factorycomponentdata = KPluginFactory::componentData(); \ pluginRegistrations \ } \ name::~name() {} \ KComponentData name::componentData() \ { \ return *name##factorycomponentdata; \ }
Definition at line 49 of file kpluginfactory.h.
#define K_PLUGIN_FACTORY_WITH_BASEFACTORY | ( | name, | |||
baseFactory, | |||||
pluginRegistrations | ) |
Value:
K_PLUGIN_FACTORY_DECLARATION_WITH_BASEFACTORY(name, baseFactory) \ K_PLUGIN_FACTORY_DEFINITION_WITH_BASEFACTORY(name, baseFactory, pluginRegistrations)
Definition at line 69 of file kpluginfactory.h.
Typedef Documentation
typedef KPluginFactory KLibFactory |
Definition at line 486 of file kpluginfactory.h.