Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
Loading...
Searching...
No Matches
qfactoryloader_p.h
Go to the documentation of this file.
1
// Copyright (C) 2017 The Qt Company Ltd.
2
// Copyright (C) 2022 Intel Corporation.
3
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
4
// Qt-Security score:significant reason:default
5
6
#
ifndef
QFACTORYLOADER_P_H
7
#
define
QFACTORYLOADER_P_H
8
9
//
10
// W A R N I N G
11
// -------------
12
//
13
// This file is not part of the Qt API. It exists purely as an
14
// implementation detail. This header file may change from version to
15
// version without notice, or even be removed.
16
//
17
// We mean it.
18
//
19
20
#
include
"QtCore/qglobal.h"
21
#
ifndef
QT_NO_QOBJECT
22
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"
30
31
#
if
QT_CONFIG
(
library
)
32
#
include
"QtCore/private/qlibrary_p.h"
33
#
endif
34
35
#
include
<
optional
>
36
37
QT_BEGIN_NAMESPACE
38
39
class
QJsonObject;
40
class
QLibraryPrivate
;
41
42
class
Q_CORE_EXPORT
QFactoryLoader
43
{
44
Q_DECLARE_TR_FUNCTIONS(QFactoryLoader);
45
46
public
:
47
explicit
QFactoryLoader(
const
char
*iid,
48
const
QString &suffix = QString(),
49
Qt::CaseSensitivity = Qt::CaseSensitive);
50
51
#
if
QT_CONFIG
(
library
)
52
~QFactoryLoader();
53
54
void
update();
55
static
void
refreshAll();
56
#
endif
// QT_CONFIG(library)
57
58
void
setExtraSearchPath
(
const
QString &path);
59
QMultiMap
<
int
,
QString
>
keyMap
()
const
;
60
int
indexOf
(
const
QString &needle)
const
;
61
62
using
MetaDataList = QList<QPluginParsedMetaData>;
63
64
MetaDataList
metaData
()
const
;
65
QList
<
QCborArray
>
metaDataKeys
()
const
;
66
QObject
*
instance
(
int
index)
const
;
67
68
private
:
69
struct
Private {
70
Private(
const
char
*iid, Qt::CaseSensitivity cs)
71
: iid(iid), cs(cs)
72
{}
73
QByteArray iid;
74
mutable
QMutex mutex;
75
mutable
QList<QtPluginInstanceFunction> usedStaticInstances;
76
#
if
QT_CONFIG
(
library
)
77
std::vector<QLibraryPrivate::UniquePtr> libraries;
78
mutable
QList<
bool
> loadedLibraries;
79
std::map<QString, QLibraryPrivate*> keyMap;
80
QString suffix;
81
QString extraSearchPath;
82
void
updateSinglePath(
const
QString &pluginDir);
83
#
endif
84
Qt::CaseSensitivity cs;
85
86
// for compat when we d was a pointer
87
auto
operator->() {
return
this
; }
88
auto
operator->()
const
{
return
this
; }
89
} d;
90
91
inline
QObject *instanceHelper_locked(
int
index)
const
;
92
};
93
94
template
<
class
PluginInterface,
class
FactoryInterface,
typename
...Args>
95
PluginInterface *
qLoadPlugin
(
const
QFactoryLoader *loader,
const
QString &key, Args &&...args)
96
{
97
const
int
index = loader->indexOf(key);
98
if
(index != -1) {
99
QObject *factoryObject = loader->instance(index);
100
if
(FactoryInterface *factory = qobject_cast<FactoryInterface *>(factoryObject))
101
if
(PluginInterface *result = factory->create(key,
std
::forward<Args>(args)...))
102
return
result;
103
}
104
return
nullptr
;
105
}
106
107
template
<
class
PluginInterface,
class
FactoryInterface,
typename
Arg>
108
Q_DECL_DEPRECATED PluginInterface *qLoadPlugin1(
const
QFactoryLoader *loader,
const
QString &key, Arg &&arg)
109
{
return
qLoadPlugin<PluginInterface, FactoryInterface>(loader, key, std::forward<Arg>(arg)); }
110
111
QT_END_NAMESPACE
112
113
#
endif
// QT_NO_QOBJECT
114
115
#
endif
// QFACTORYLOADER_P_H
QFactoryLoader
Definition
qfactoryloader_p.h:43
QFactoryLoader::setExtraSearchPath
void setExtraSearchPath(const QString &path)
Definition
qfactoryloader.cpp:439
QFactoryLoader::indexOf
int indexOf(const QString &needle) const
Definition
qfactoryloader.cpp:580
QFactoryLoader::keyMap
QMultiMap< int, QString > keyMap() const
Definition
qfactoryloader.cpp:568
QFactoryLoader::metaData
MetaDataList metaData() const
Definition
qfactoryloader.cpp:468
QFactoryLoader::metaDataKeys
QList< QCborArray > metaDataKeys() const
Definition
qfactoryloader.cpp:494
QFactoryLoader::instance
QObject * instance(int index) const
Definition
qfactoryloader.cpp:523
QLibraryPrivate
Definition
qlibrary_p.h:51
QT_BEGIN_NAMESPACE
Combined button and popup list for selecting options.
Definition
qsequentialanimationgroup.cpp:47
std
[33]
Definition
src_corelib_tools_qhash.cpp:421
Q_TRACE_POINT
Q_TRACE_POINT(qtcore, QFactoryLoader_update, const QString &fileName)
isIidMatch
static bool isIidMatch(QByteArrayView raw, QLatin1StringView iid)
Definition
qfactoryloader.cpp:166
iterateInPluginMetaData
static IterationResult iterateInPluginMetaData(QByteArrayView raw, F &&f)
Definition
qfactoryloader.cpp:117
qLoadPlugin
PluginInterface * qLoadPlugin(const QFactoryLoader *loader, const QString &key, Args &&...args)
Definition
qfactoryloader_p.h:95
QPluginMetaData::Header
Definition
qplugin.h:70
QPluginMetaData
Definition
qplugin.h:39
qtbase
src
corelib
plugin
qfactoryloader_p.h
Generated on
for Qt by
1.18.0