Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
qlibrary_p.h
Go to the documentation of this file.
1// Copyright (C) 2020 The Qt Company Ltd.
2// Copyright (C) 2021 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
5#ifndef QLIBRARY_P_H
6#define QLIBRARY_P_H
7
8//
9// W A R N I N G
10// -------------
11//
12// This file is not part of the Qt API. It exists for the convenience
13// of the QLibrary class. This header file may change from
14// version to version without notice, or even be removed.
15//
16// We mean it.
17//
18
19#include "QtCore/qlibrary.h"
20
21#include "QtCore/private/qfactoryloader_p.h"
22#include "QtCore/qloggingcategory.h"
23#include "QtCore/qmutex.h"
24#include "QtCore/qplugin.h"
25#include "QtCore/qpointer.h"
26#include "QtCore/qstringlist.h"
27#ifdef Q_OS_WIN
28# include "QtCore/qt_windows.h"
29#endif
30
32
34
35Q_DECLARE_LOGGING_CATEGORY(qt_lcDebugPlugins)
36
38{
41#if defined(Q_OF_MACH_O)
42 bool isEncrypted = false;
43#endif
44};
45
46class QLibraryStore;
48{
49public:
50#ifdef Q_OS_WIN
51 using Handle = HINSTANCE;
52#else
53 using Handle = void *;
54#endif
56
59
60 bool load();
61 QtPluginInstanceFunction loadPlugin(); // loads and resolves instance
62 bool unload(UnloadFlag flag = UnloadSys);
63 void release();
64 QFunctionPointer resolve(const char *);
65
66 QLibrary::LoadHints loadHints() const
67 { return QLibrary::LoadHints(loadHintsInt.loadRelaxed()); }
68 void setLoadHints(QLibrary::LoadHints lh);
70
71 static QLibraryPrivate *findOrCreate(const QString &fileName, const QString &version = QString(),
72 QLibrary::LoadHints loadHints = { });
75
78
79 // the mutex protects the fields below
81 QPointer<QObject> inst; // used by QFactoryLoader
85
86 void updatePluginState();
87 bool isPlugin();
88
89private:
90 explicit QLibraryPrivate(const QString &canonicalFileName, const QString &version, QLibrary::LoadHints loadHints);
92 void mergeLoadHints(QLibrary::LoadHints loadHints);
93
94 bool load_sys();
95 bool unload_sys();
96 QFunctionPointer resolve_sys(const char *);
97
98 QAtomicInt loadHintsInt;
99
101 QAtomicInt libraryRefCount;
103 QAtomicInt libraryUnloadCount;
104
105 enum { IsAPlugin, IsNotAPlugin, MightBeAPlugin } pluginState;
106 friend class QLibraryStore;
107};
108
110
111#endif // QLIBRARY_P_H
\inmodule QtCore
Definition qatomic.h:112
\macro Q_ATOMIC_INTnn_IS_SUPPORTED
Definition qatomic.h:123
T loadRelaxed() const noexcept
QString errorString
Definition qlibrary_p.h:83
bool unload(UnloadFlag flag=UnloadSys)
Definition qlibrary.cpp:547
QString qualifiedFileName
Definition qlibrary_p.h:84
QtPluginInstanceFunction loadPlugin()
Definition qlibrary.cpp:574
QAtomicPointer< std::remove_pointer< Handle >::type > pHnd
Definition qlibrary_p.h:77
static QStringList suffixes_sys(const QString &fullVersion)
void setLoadHints(QLibrary::LoadHints lh)
Definition qlibrary.cpp:478
const QString fileName
Definition qlibrary_p.h:57
const QString fullVersion
Definition qlibrary_p.h:58
void updatePluginState()
Definition qlibrary.cpp:713
QAtomicPointer< std::remove_pointer< QtPluginInstanceFunction >::type > instanceFactory
Definition qlibrary_p.h:76
static QStringList prefixes_sys()
QPluginParsedMetaData metaData
Definition qlibrary_p.h:82
QFunctionPointer resolve(const char *)
Definition qlibrary.cpp:471
QPointer< QObject > inst
Definition qlibrary_p.h:81
QObject * pluginInstance()
Definition qlibrary.cpp:492
static QLibraryPrivate * findOrCreate(const QString &fileName, const QString &version=QString(), QLibrary::LoadHints loadHints={ })
Definition qlibrary.cpp:452
QLibrary::LoadHints loadHints() const
Definition qlibrary_p.h:66
\inmodule QtCore
Definition qmutex.h:285
\inmodule QtCore
Definition qobject.h:90
\inmodule QtCore
Definition qpointer.h:18
\inmodule QtCore
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:127
Combined button and popup list for selecting options.
#define Q_DECLARE_LOGGING_CATEGORY(name)
static bool isEncrypted(const my_mach_header *header)
QObject *(* QtPluginInstanceFunction)()
Definition qplugin.h:36
#define QT_REQUIRE_CONFIG(feature)
ptrdiff_t qsizetype
Definition qtypes.h:70