6#ifndef QFACTORYLOADER_P_H
7#define QFACTORYLOADER_P_H
20#include "QtCore/qglobal.h"
23#include "QtCore/private/qplugin_p.h"
24#include "QtCore/private/qduplicatetracker_p.h"
25#include "QtCore/qcoreapplication.h"
26#include "QtCore/qmap.h"
27#include "QtCore/qmutex.h"
28#include "QtCore/qobject.h"
29#include "QtCore/qplugin.h"
32# include "QtCore/private/qlibrary_p.h"
42 Q_DECLARE_TR_FUNCTIONS(QFactoryLoader);
45 explicit QFactoryLoader(
const char *iid,
46 const QString &suffix = QString(),
47 Qt::CaseSensitivity = Qt::CaseSensitive);
52 void setLoadHints(QLibrary::LoadHints hints);
54 static void refreshAll();
56#if defined(Q_OS_UNIX) && !defined (Q_OS_DARWIN)
57 QLibraryPrivate *library(
const QString &key)
const;
63 int indexOf(
const QString &needle)
const;
65 using MetaDataList = QList<QPluginParsedMetaData>;
75 mutable QList<QtPluginInstanceFunction> usedStaticInstances;
77 QDuplicateTracker<QString> loadedPaths;
78 std::vector<QLibraryPrivate::UniquePtr> libraries;
79 mutable QList<
bool> loadedLibraries;
80 std::map<QString, QLibraryPrivate*> keyMap;
82 QString extraSearchPath;
83 Qt::CaseSensitivity cs;
84 QLibrary::LoadHints loadHints;
85 void updateSinglePath(
const QString &pluginDir);
89 auto operator->() {
return this; }
90 auto operator->()
const {
return this; }
93 inline QObject *instanceHelper_locked(
int index)
const;
96template <
class PluginInterface,
class FactoryInterface,
typename ...Args>
97PluginInterface *
qLoadPlugin(
const QFactoryLoader *loader,
const QString &key, Args &&...args)
99 const int index = loader->indexOf(key);
101 QObject *factoryObject = loader->instance(index);
102 if (FactoryInterface *factory = qobject_cast<FactoryInterface *>(factoryObject))
103 if (PluginInterface *result = factory->create(key, std::forward<Args>(args)...))
109template <
class PluginInterface,
class FactoryInterface,
typename Arg>
110Q_DECL_DEPRECATED PluginInterface *qLoadPlugin1(
const QFactoryLoader *loader,
const QString &key, Arg &&arg)
111{
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)