5#ifndef QFACTORYLOADER_P_H
6#define QFACTORYLOADER_P_H
19#include "QtCore/qglobal.h"
22#include "QtCore/private/qplugin_p.h"
23#include "QtCore/private/qduplicatetracker_p.h"
24#include "QtCore/qcoreapplication.h"
25#include "QtCore/qmap.h"
26#include "QtCore/qmutex.h"
27#include "QtCore/qobject.h"
28#include "QtCore/qplugin.h"
31# include "QtCore/private/qlibrary_p.h"
41 Q_DECLARE_TR_FUNCTIONS(QFactoryLoader);
44 explicit QFactoryLoader(
const char *iid,
45 const QString &suffix = QString(),
46 Qt::CaseSensitivity = Qt::CaseSensitive);
51 void setLoadHints(QLibrary::LoadHints hints);
53 static void refreshAll();
55#if defined(Q_OS_UNIX) && !defined (Q_OS_DARWIN)
56 QLibraryPrivate *library(
const QString &key)
const;
62 int indexOf(
const QString &needle)
const;
64 using MetaDataList = QList<QPluginParsedMetaData>;
74 mutable QList<QtPluginInstanceFunction> usedStaticInstances;
76 QDuplicateTracker<QString> loadedPaths;
77 std::vector<QLibraryPrivate::UniquePtr> libraries;
78 mutable QList<
bool> loadedLibraries;
79 std::map<QString, QLibraryPrivate*> keyMap;
81 QString extraSearchPath;
82 Qt::CaseSensitivity cs;
83 QLibrary::LoadHints loadHints;
84 void updateSinglePath(
const QString &pluginDir);
88 auto operator->() {
return this; }
89 auto operator->()
const {
return this; }
92 inline QObject *instanceHelper_locked(
int index)
const;
95template <
class PluginInterface,
class FactoryInterface,
typename ...Args>
96PluginInterface *
qLoadPlugin(
const QFactoryLoader *loader,
const QString &key, Args &&...args)
98 const int index = loader->indexOf(key);
100 QObject *factoryObject = loader->instance(index);
101 if (FactoryInterface *factory = qobject_cast<FactoryInterface *>(factoryObject))
102 if (PluginInterface *result = factory->create(key, std::forward<Args>(args)...))
108template <
class PluginInterface,
class FactoryInterface,
typename Arg>
109Q_DECL_DEPRECATED PluginInterface *qLoadPlugin1(
const QFactoryLoader *loader,
const QString &key, Arg &&arg)
110{
return qLoadPlugin<PluginInterface, FactoryInterface>(loader, key, std::forward<Arg>(arg)); }
void setExtraSearchPath(const QString &path)
int indexOf(const QString &needle) const
QMultiMap< int, QString > keyMap() const
MetaDataList metaData() const
QList< QCborArray > metaDataKeys() const
QObject * instance(int index) const
Combined button and popup list for selecting options.
Q_TRACE_POINT(qtcore, QFactoryLoader_update, const QString &fileName)
static bool isIidMatch(QByteArrayView raw, QLatin1StringView iid)
static IterationResult iterateInPluginMetaData(QByteArrayView raw, F &&f)
PluginInterface * qLoadPlugin(const QFactoryLoader *loader, const QString &key, Args &&...args)