• Skip to content
  • Skip to link menu
KDE 4.3 API Reference
  • KDE API Reference
  • kdelibs
  • Sitemap
  • Contact Us
 

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.

Classes

struct  KPluginFactory::InheritanceChecker< impl >
 This is used to detect the arguments need for the constructor of plugin classes. More...
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...

Namespaces

namespace  KParts

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.

Example:

 #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();
     ...
 };
See also:
K_PLUGIN_FACTORY_DECLARATION
K_PLUGIN_FACTORY_DEFINITION

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
See also:
K_PLUGIN_FACTORY
K_PLUGIN_FACTORY_DEFINITION

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.
See also:
K_PLUGIN_FACTORY
K_PLUGIN_FACTORY_DECLARATION

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.

KDECore

Skip menu "KDECore"
  • Main Page
  • Modules
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

kdelibs

Skip menu "kdelibs"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • Kate
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.6.1
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal