KCoreAddons
kpluginfactory.h
73 K_PLUGIN_FACTORY_DECLARATION_WITH_BASEFACTORY_SKEL(name, baseFactory, Q_PLUGIN_METADATA(IID KPluginFactory_iid FILE json))
76 K_PLUGIN_FACTORY_DECLARATION_WITH_BASEFACTORY_SKEL(name, baseFactory, Q_PLUGIN_METADATA(IID KPluginFactory_iid))
87 #define K_PLUGIN_FACTORY_WITH_BASEFACTORY_JSON(name, baseFactory, jsonFile, pluginRegistrations) \
136 #define K_PLUGIN_FACTORY(name, pluginRegistrations) K_PLUGIN_FACTORY_WITH_BASEFACTORY(name, KPluginFactory, pluginRegistrations)
220 * This macro does the same as K_PLUGIN_FACTORY_WITH_JSON, but you only have to pass the class name and the json file.
268 #define K_PLUGIN_CLASS_WITH_JSON(classname, jsonFile) K_PLUGIN_FACTORY_WITH_JSON(classname##Factory, jsonFile, registerPlugin<classname>();)
281 #define K_PLUGIN_FACTORY_DECLARATION(name) K_PLUGIN_FACTORY_DECLARATION_WITH_BASEFACTORY(name, KPluginFactory)
296 #define K_PLUGIN_FACTORY_DEFINITION(name, pluginRegistrations) K_PLUGIN_FACTORY_DEFINITION_WITH_BASEFACTORY(name, KPluginFactory, pluginRegistrations)
318 * T(QWidget *parentWidget, QObject *parent, const KPluginMetaData &metaData, const QVariantList &args)
361 * create(const char *iface, QWidget *parentWidget, QObject *parent, const QVariantList &args, const QString &keyword)
374 * virtual QObject *create(const char *iface, QWidget *parentWidget, QObject *parent, const QVariantList &args, const QString &keyword)
420 * @p T. If it has multiple choices it's not defined which object will be returned, so be careful
444 T *create(const QString &keyword, QObject *parent = nullptr, const QVariantList &args = QVariantList());
449 * This overload has an additional @p parentWidget argument, which is used by some plugins (e.g. Parts).
460 T *create(QWidget *parentWidget, QObject *parent, const QString &keyword = QString(), const QVariantList &args = QVariantList());
467 KCOREADDONS_DEPRECATED_VERSION(4, 0, "Use KPluginFactory::create<T>(QObject *parent, const QVariantList &args)")
476 KCOREADDONS_DEPRECATED_VERSION(4, 0, "Use KPluginFactory::create<T>(QObject *parent, const QVariantList &args)")
477 QObject *create(QObject *parent = nullptr, const char *classname = "QObject", const QStringList &args = QStringList())
521 * This is used to detect the arguments need for the constructor of metadata-less plugin classes.
527 static constexpr bool enabled = std::is_constructible<impl, QWidget *, QObject *, const QVariantList &>::value
528 || std::is_constructible<impl, QWidget *, const QVariantList &>::value || std::is_constructible<impl, QObject *, const QVariantList &>::value;
545 * Function pointer type to a function that instantiates a plugin, also taking a plugin metadata argument.
548 using CreateInstanceWithMetaDataFunction = QObject *(*)(QWidget *, QObject *, const KPluginMetaData &, const QVariantList &);
551 * This is used to detect the arguments need for the constructor of metadata-taking plugin classes.
557 static constexpr bool enabled = std::is_constructible<impl, QWidget *, QObject *, const KPluginMetaData &, const QVariantList &>::value
559 || std::is_constructible<impl, QObject *, const KPluginMetaData &, const QVariantList &>::value;
582 * Registers a metadata-less plugin with the factory. Call this function from the constructor of the
606 * Overload for registerPlugin<T>(const QString &keyword, CreateInstanceFunction instanceFunction)
628 CreateInstanceFunction instanceFunction = InheritanceChecker<T>().createInstanceFunction(static_cast<T *>(nullptr));
633 * Registers a metadata-taking plugin with the factory. Call this function from the constructor of the
651 void registerPlugin(const QString &keyword, CreateInstanceWithMetaDataFunction instanceFunction)
657 * Overload for registerPlugin<T>(const QString &keyword, CreateInstanceWithMetaDataFunction instanceFunction)
663 * new T(QWidget *parentWidget, QObject *parent, const KPluginMetaData &metaData, const QVariantList &args)
679 CreateInstanceWithMetaDataFunction instanceFunction = InheritanceWithMetaDataChecker<T>().createInstanceFunction(static_cast<T *>(nullptr));
689 KCOREADDONS_DEPRECATED_VERSION(4, 0, "Use KPluginFactory::create<T>(QObject *parent, const QVariantList &args)")
693 * @deprecated since 4.0 use create<T>(QWidget *parentWidget, QObject *parent, const QString &keyword, const QVariantList &args)
697 "Use KPluginFactory::create<T>(QWidget *parentWidget, QObject *parent, const QString &keyword, const QVariantList &args)")
698 virtual KParts::Part *createPartObject(QWidget *parentWidget, QObject *parent, const char *classname, const QStringList &args);
715 virtual QObject *create(const char *iface, QWidget *parentWidget, QObject *parent, const QVariantList &args, const QString &keyword);
718 static QObject *createInstance(QWidget *parentWidget, QObject *parent, const QVariantList &args)
730 static QObject *createPartInstance(QWidget *parentWidget, QObject *parent, const QVariantList &args)
736 static QObject *createWithMetaDataInstance(QWidget *parentWidget, QObject *parent, const KPluginMetaData &metaData, const QVariantList &args)
748 static QObject *createPartWithMetaDataInstance(QWidget *parentWidget, QObject *parent, const KPluginMetaData &metaData, const QVariantList &args)
754 void registerPlugin(const QString &keyword, const QMetaObject *metaObject, CreateInstanceFunction instanceFunction);
755 void registerPlugin(const QString &keyword, const QMetaObject *metaObject, CreateInstanceWithMetaDataFunction instanceFunction);
771 create(T::staticMetaObject.className(), parent && parent->isWidgetType() ? reinterpret_cast<QWidget *>(parent) : nullptr, parent, args, QString());
781 inline T *KPluginFactory::create(const QString &keyword, QObject *parent, const QVariantList &args)
784 create(T::staticMetaObject.className(), parent && parent->isWidgetType() ? reinterpret_cast<QWidget *>(parent) : nullptr, parent, args, keyword);
794 inline T *KPluginFactory::create(QWidget *parentWidget, QObject *parent, const QString &keyword, const QVariantList &args)
void registerPlugin(const QString &keyword, CreateInstanceWithMetaDataFunction instanceFunction)
Registers a metadata-taking plugin with the factory.
Definition: kpluginfactory.h:651
T * create(QObject *parent=nullptr, const QVariantList &args=QVariantList())
Use this method to create an object.
Definition: kpluginfactory.h:768
This is used to detect the arguments need for the constructor of metadata-less plugin classes...
Definition: kpluginfactory.h:525
This is used to detect the arguments need for the constructor of metadata-taking plugin classes...
Definition: kpluginfactory.h:555
QObject *(*)(QWidget *, QObject *, const KPluginMetaData &, const QVariantList &) CreateInstanceWithMetaDataFunction
Function pointer type to a function that instantiates a plugin, also taking a plugin metadata argumen...
Definition: kpluginfactory.h:548
void registerPlugin(const QString &keyword=QString())
Overload for registerPlugin<T>(const QString &keyword, CreateInstanceFunction instanceFunction) ...
Definition: kpluginfactory.h:626
void registerPlugin(const QString &keyword, CreateInstanceFunction instanceFunction)
Registers a metadata-less plugin with the factory.
Definition: kpluginfactory.h:600
This class allows easily accessing some standardized values from the JSON metadata that can be embedd...
Definition: kpluginmetadata.h:85
bool isWidgetType() const const
KPluginFactory provides a convenient way to provide factory-style plugins.
Definition: kpluginfactory.h:403
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Wed Mar 3 2021 00:00:15 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006
Documentation copyright © 1996-2021 The KDE developers.
Generated on Wed Mar 3 2021 00:00:15 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.