Qt
6.x
The Qt SDK
Loading...
Searching...
No Matches
qlazilyallocated_p.h
Go to the documentation of this file.
1
// Copyright (C) 2020 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
4
#ifndef QLAZILYALLOCATED_P_H
5
#define QLAZILYALLOCATED_P_H
6
7
//
8
// W A R N I N G
9
// -------------
10
//
11
// This file is not part of the Qt API. It exists purely as an
12
// implementation detail. This header file may change from version to
13
// version without notice, or even be removed.
14
//
15
// We mean it.
16
//
17
18
#include <QtCore/private/qglobal_p.h>
19
#include <QtCore/qtaggedpointer.h>
20
21
QT_BEGIN_NAMESPACE
22
23
template<typename T, typename Tag = typename QtPrivate::TagInfo<T>::TagType>
24
class
QLazilyAllocated
{
25
public
:
26
inline
QLazilyAllocated
();
27
inline
~QLazilyAllocated
();
28
29
inline
bool
isAllocated
()
const
;
30
31
inline
T *
operator->
()
const
;
32
33
inline
T &
value
();
34
inline
const
T &
value
()
const
;
35
36
inline
Tag
tag
()
const
;
37
inline
void
setTag
(
Tag
t
);
38
private
:
39
mutable
QTaggedPointer<T, Tag>
d;
40
};
41
42
template
<
typename
T,
typename
Tag>
43
QLazilyAllocated<T, Tag>::QLazilyAllocated
()
44
{
45
}
46
47
template
<
typename
T,
typename
Tag>
48
QLazilyAllocated<T, Tag>::~QLazilyAllocated
()
49
{
50
delete
d
.data();
51
}
52
53
template
<
typename
T,
typename
Tag>
54
bool
QLazilyAllocated<T, Tag>::isAllocated
()
const
55
{
56
return
!
d
.isNull();
57
}
58
59
template
<
typename
T,
typename
Tag>
60
T &
QLazilyAllocated<T, Tag>::value
()
61
{
62
if
(
d
.isNull())
d
=
new
T;
63
return
*
d
;
64
}
65
66
template
<
typename
T,
typename
Tag>
67
const
T &
QLazilyAllocated<T, Tag>::value
()
const
68
{
69
if
(
d
.isNull())
d
=
new
T;
70
return
*
d
;
71
}
72
73
template
<
typename
T,
typename
Tag>
74
T *
QLazilyAllocated<T, Tag>::operator->
()
const
75
{
76
return
d
.data();
77
}
78
79
template
<
typename
T,
typename
Tag>
80
Tag
QLazilyAllocated<T, Tag>::tag
()
const
81
{
82
return
d
.tag();
83
}
84
85
template
<
typename
T,
typename
Tag>
86
void
QLazilyAllocated<T, Tag>::setTag
(
Tag
t
)
87
{
88
d
.setTag(
t
);
89
}
90
91
QT_END_NAMESPACE
92
93
#endif
// QLAZILYALLOCATED_P_H
QLazilyAllocated
Definition
qlazilyallocated_p.h:24
QLazilyAllocated::setTag
void setTag(Tag t)
Definition
qlazilyallocated_p.h:86
QLazilyAllocated::operator->
T * operator->() const
Definition
qlazilyallocated_p.h:74
QLazilyAllocated::value
T & value()
Definition
qlazilyallocated_p.h:60
QLazilyAllocated::value
const T & value() const
Definition
qlazilyallocated_p.h:67
QLazilyAllocated::QLazilyAllocated
QLazilyAllocated()
Definition
qlazilyallocated_p.h:43
QLazilyAllocated::~QLazilyAllocated
~QLazilyAllocated()
Definition
qlazilyallocated_p.h:48
QLazilyAllocated::isAllocated
bool isAllocated() const
Definition
qlazilyallocated_p.h:54
QLazilyAllocated::tag
Tag tag() const
Definition
qlazilyallocated_p.h:80
QTaggedPointer
Definition
qtaggedpointer.h:38
QT_BEGIN_NAMESPACE
Combined button and popup list for selecting options.
Definition
qstandardpaths_haiku.cpp:21
QT_END_NAMESPACE
Definition
qsharedpointer.cpp:1545
t
GLdouble GLdouble t
Definition
qopenglext.h:243
Tag
Tag
Definition
qtranslator.cpp:42
d
double d
Definition
src_corelib_text_qlocale.cpp:9
qtdeclarative
src
qml
qml
ftw
qlazilyallocated_p.h
Generated by
1.9.7