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
qqmltypemodule_p.h
Go to the documentation of this file.
1
// Copyright (C) 2019 The Qt Company Ltd.
2
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
// Qt-Security score:significant
4
5
#
ifndef
QQMLTYPEMODULE_P_H
6
#
define
QQMLTYPEMODULE_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 purely as an
13
// implementation detail. This header file may change from version to
14
// version without notice, or even be removed.
15
//
16
// We mean it.
17
//
18
19
#
include
<
QtQml
/
qtqmlglobal
.
h
>
20
#
include
<
QtQml
/
private
/
qstringhash_p
.
h
>
21
#
include
<
QtQml
/
private
/
qqmltype_p
.
h
>
22
#
include
<
QtCore
/
qmutex
.
h
>
23
#
include
<
QtCore
/
qstring
.
h
>
24
#
include
<
QtCore
/
qtyperevision
.
h
>
25
26
#
include
<
functional
>
27
28
QT_BEGIN_NAMESPACE
29
30
class
QQmlType;
31
class
QQmlTypePrivate;
32
struct
QQmlMetaTypeData
;
33
34
namespace
QV4
{
35
struct
String;
36
}
37
38
class
QQmlTypeModule
39
{
40
public
:
41
enum
class
LockLevel
{
42
Open
= 0,
43
Weak
= 1,
44
Strong
= 2
45
};
46
47
QQmlTypeModule
() =
default
;
48
QQmlTypeModule
(
const
QString &uri, quint8 majorVersion)
49
:
m_module
(
uri
),
m_majorVersion
(
majorVersion
)
50
{}
51
52
void
add
(QQmlTypePrivate *);
53
void
remove
(
const
QQmlTypePrivate *type);
54
55
LockLevel
lockLevel
()
const
{
return
LockLevel(m_lockLevel.loadRelaxed()); }
56
bool
setLockLevel
(
LockLevel
mode)
57
{
58
while
(
true
) {
59
const
int
currentLock = m_lockLevel.loadAcquire();
60
if
(currentLock >
int
(mode))
61
return
false
;
62
if
(currentLock ==
int
(mode) || m_lockLevel.testAndSetRelease(currentLock,
int
(mode)))
63
return
true
;
64
}
65
}
66
67
QString
module
()
const
68
{
69
// No need to lock. m_module is const
70
return
m_module;
71
}
72
73
quint8
majorVersion
()
const
74
{
75
// No need to lock. d->majorVersion is const
76
return
m_majorVersion;
77
}
78
79
void
addMinorVersion
(quint8 minorVersion);
80
quint8
minimumMinorVersion
()
const
{
return
m_minMinorVersion.loadRelaxed(); }
81
quint8
maximumMinorVersion
()
const
{
return
m_maxMinorVersion.loadRelaxed(); }
82
83
QQmlType
type
(
const
QHashedStringRef &name, QTypeRevision version)
const
84
{
85
QMutexLocker lock(&m_mutex);
86
return
findType(m_typeHash.value(name), version);
87
}
88
89
QQmlType
type
(
const
QV4
::String *name, QTypeRevision version)
const
90
{
91
QMutexLocker lock(&m_mutex);
92
return
findType(m_typeHash.value(name), version);
93
}
94
95
void
walkCompositeSingletons
(
const
std
::function<
void
(
const
QQmlType &)> &callback)
const
;
96
97
private
:
98
static
Q_QML_EXPORT QQmlType
findType
(
99
const
QList
<
QQmlTypePrivate
*> *
types
,
QTypeRevision
version
);
100
101
const
QString m_module;
102
const
quint8 m_majorVersion = 0;
103
104
// Can only ever decrease
105
QAtomicInt m_minMinorVersion =
std
::
numeric_limits
<
quint8
>::
max
();
106
107
// Can only ever increase
108
QAtomicInt m_maxMinorVersion = 0;
109
110
// LockLevel. Can only be increased.
111
QAtomicInt m_lockLevel =
int
(
LockLevel
::
Open
);
112
113
using
TypeHash
=
QStringHash
<
QList
<
QQmlTypePrivate
*>>;
114
TypeHash m_typeHash;
115
116
mutable
QMutex m_mutex;
117
};
118
119
QT_END_NAMESPACE
120
121
#
endif
// QQMLTYPEMODULE_P_H
QQmlTypeModule
Definition
qqmltypemodule_p.h:39
QQmlTypeModule::setLockLevel
bool setLockLevel(LockLevel mode)
Definition
qqmltypemodule_p.h:56
QQmlTypeModule::LockLevel
LockLevel
Definition
qqmltypemodule_p.h:41
QQmlTypeModule::LockLevel::Weak
@ Weak
Definition
qqmltypemodule_p.h:43
QQmlTypeModule::LockLevel::Open
@ Open
Definition
qqmltypemodule_p.h:42
QQmlTypeModule::LockLevel::Strong
@ Strong
Definition
qqmltypemodule_p.h:44
QQmlTypeModule::lockLevel
LockLevel lockLevel() const
Definition
qqmltypemodule_p.h:55
QQmlTypeModule::majorVersion
quint8 majorVersion() const
Definition
qqmltypemodule_p.h:73
QQmlTypeModule::type
QQmlType type(const QV4::String *name, QTypeRevision version) const
Definition
qqmltypemodule_p.h:89
QQmlTypeModule::walkCompositeSingletons
void walkCompositeSingletons(const std::function< void(const QQmlType &)> &callback) const
Definition
qqmltypemodule.cpp:66
QQmlTypeModule::QQmlTypeModule
QQmlTypeModule()=default
QQmlTypeModule::remove
void remove(const QQmlTypePrivate *type)
Definition
qqmltypemodule.cpp:48
QQmlTypeModule::module
QString module() const
Definition
qqmltypemodule_p.h:67
QQmlTypeModule::QQmlTypeModule
QQmlTypeModule(const QString &uri, quint8 majorVersion)
Definition
qqmltypemodule_p.h:48
QQmlTypeModule::minimumMinorVersion
quint8 minimumMinorVersion() const
Definition
qqmltypemodule_p.h:80
QQmlTypeModule::maximumMinorVersion
quint8 maximumMinorVersion() const
Definition
qqmltypemodule_p.h:81
QQmlTypeModule::type
QQmlType type(const QHashedStringRef &name, QTypeRevision version) const
Definition
qqmltypemodule_p.h:83
QQmlTypeModule::addMinorVersion
void addMinorVersion(quint8 minorVersion)
Definition
qqmltypemodule.cpp:13
QQmlTypeModule::add
void add(QQmlTypePrivate *)
Definition
qqmltypemodule.cpp:26
QT_BEGIN_NAMESPACE
Combined button and popup list for selecting options.
Definition
qsequentialanimationgroup.cpp:47
QV4
Definition
qjsvalue.h:24
std
[33]
Definition
src_corelib_tools_qhash.cpp:421
QQmlMetaTypeData
Definition
qqmlmetatypedata_p.h:33
qtdeclarative
src
qml
qml
qqmltypemodule_p.h
Generated on
for Qt by
1.18.0