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
setLoadHints(QLibrary::LoadHints hints);
55
void
update();
56
static
void
refreshAll();
57
58
#
if
defined
(
Q_OS_UNIX
)
&&
!
defined
(
Q_OS_DARWIN
)
59
QLibraryPrivate *library(
const
QString &key)
const
;
60
#
endif
// Q_OS_UNIX && !Q_OS_DARWIN
61
#
endif
// QT_CONFIG(library)
62
63
void
setExtraSearchPath
(
const
QString &path);
64
QMultiMap
<
int
,
QString
>
keyMap
()
const
;
65
int
indexOf
(
const
QString &needle)
const
;
66
67
using
MetaDataList = QList<QPluginParsedMetaData>;
68
69
MetaDataList
metaData
()
const
;
70
QList
<
QCborArray
>
metaDataKeys
()
const
;
71
QObject
*
instance
(
int
index)
const
;
72
73
private
:
74
struct
Private {
75
QByteArray iid;
76
mutable
QMutex mutex;
77
mutable
QList<QtPluginInstanceFunction> usedStaticInstances;
78
#
if
QT_CONFIG
(
library
)
79
std::vector<QLibraryPrivate::UniquePtr> libraries;
80
mutable
QList<
bool
> loadedLibraries;
81
std::map<QString, QLibraryPrivate*> keyMap;
82
QString suffix;
83
QString extraSearchPath;
84
Qt::CaseSensitivity cs;
85
QLibrary::LoadHints loadHints;
86
void
updateSinglePath(
const
QString &pluginDir);
87
#
endif
88
89
// for compat when we d was a pointer
90
auto
operator->() {
return
this
; }
91
auto
operator->()
const
{
return
this
; }
92
} d;
93
94
inline
QObject *instanceHelper_locked(
int
index)
const
;
95
};
96
97
template
<
class
PluginInterface,
class
FactoryInterface,
typename
...Args>
98
PluginInterface *
qLoadPlugin
(
const
QFactoryLoader *loader,
const
QString &key, Args &&...args)
99
{
100
const
int
index = loader->indexOf(key);
101
if
(index != -1) {
102
QObject *factoryObject = loader->instance(index);
103
if
(FactoryInterface *factory = qobject_cast<FactoryInterface *>(factoryObject))
104
if
(PluginInterface *result = factory->create(key,
std
::forward<Args>(args)...))
105
return
result;
106
}
107
return
nullptr
;
108
}
109
110
template
<
class
PluginInterface,
class
FactoryInterface,
typename
Arg>
111
Q_DECL_DEPRECATED PluginInterface *qLoadPlugin1(
const
QFactoryLoader *loader,
const
QString &key, Arg &&arg)
112
{
return
qLoadPlugin<PluginInterface, FactoryInterface>(loader, key, std::forward<Arg>(arg)); }
113
114
QT_END_NAMESPACE
115
116
#
endif
// QT_NO_QOBJECT
117
118
#
endif
// QFACTORYLOADER_P_H
QFactoryLoader
Definition
qfactoryloader_p.h:43
QFactoryLoader::setExtraSearchPath
void setExtraSearchPath(const QString &path)
Definition
qfactoryloader.cpp:456
QFactoryLoader::indexOf
int indexOf(const QString &needle) const
Definition
qfactoryloader.cpp:598
QFactoryLoader::keyMap
QMultiMap< int, QString > keyMap() const
Definition
qfactoryloader.cpp:586
QFactoryLoader::metaData
MetaDataList metaData() const
Definition
qfactoryloader.cpp:485
QFactoryLoader::metaDataKeys
QList< QCborArray > metaDataKeys() const
Definition
qfactoryloader.cpp:511
QFactoryLoader::instance
QObject * instance(int index) const
Definition
qfactoryloader.cpp:540
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:98
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