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
qdbuspendingreply.h
Go to the documentation of this file.
1
// Copyright (C) 2016 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 reason:default
4
5
#
ifndef
QDBUSPENDINGREPLY_H
6
#
define
QDBUSPENDINGREPLY_H
7
8
#
include
<
QtDBus
/
qtdbusglobal
.
h
>
9
#
include
<
QtDBus
/
qdbusargument
.
h
>
10
#
include
<
QtDBus
/
qdbuspendingcall
.
h
>
11
12
#
ifndef
QT_NO_DBUS
13
14
class
tst_QDBusPendingReply;
15
16
QT_BEGIN_NAMESPACE
17
18
19
class
Q_DBUS_EXPORT
QDBusPendingReplyBase
:
public
QDBusPendingCall
20
{
21
protected
:
22
QDBusPendingReplyBase();
23
#
if
QT_VERSION
<
QT_VERSION_CHECK
(
7
,
0
,
0
)
24
~QDBusPendingReplyBase();
25
QDBusPendingReplyBase(
const
QDBusPendingReplyBase &) =
default
;
26
QDBusPendingReplyBase &operator=(
const
QDBusPendingReplyBase &) =
default
;
27
QDBusPendingReplyBase(QDBusPendingReplyBase &&)
noexcept
=
default
;
28
QDBusPendingReplyBase &operator=(QDBusPendingReplyBase &&)
noexcept
=
default
;
29
#
endif
30
31
void
assign(
const
QDBusPendingCall &call);
32
void
assign(
const
QDBusMessage &message);
33
34
QVariant argumentAt(
int
index)
const
;
35
void
setMetaTypes(
int
count,
const
QMetaType *metaTypes);
36
};
37
38
namespace
QDBusPendingReplyTypes
{
39
template
<
int
Index,
typename
T,
typename
... Types>
40
struct
Select
41
{
42
typedef
Select
<Index - 1, Types...>
Next
;
43
typedef
typename
Next
::
Type
Type
;
44
};
45
template
<
typename
T,
typename
... Types>
46
struct
Select
<0, T, Types...>
47
{
48
typedef
T
Type
;
49
};
50
51
template
<
typename
T>
inline
QMetaType
metaTypeFor
()
52
{
return
QMetaType::fromType<T>(); }
53
// specialize for QVariant, allowing it to be used in place of QDBusVariant
54
template
<>
inline
QMetaType
metaTypeFor
<
QVariant
>()
55
{
return
QMetaType
::
fromType
<
QDBusVariant
>(); }
56
}
57
58
59
template
<
typename
... Types>
60
class
QDBusPendingReply
:
public
QDBusPendingReplyBase
61
{
62
friend
class
::tst_QDBusPendingReply;
63
template
<
int
Index>
using
Select =
QDBusPendingReplyTypes
::
Select
<Index, Types...>;
64
public
:
65
enum
{
Count
= std::is_same_v<
typename
Select<0>::Type,
void
> ? 0 :
sizeof
...(Types) };
66
67
inline
constexpr
int
count
()
const
{
return
Count
; }
68
69
inline
QDBusPendingReply
() =
default
;
70
// Rule Of Zero applies!
71
72
inline
Q_IMPLICIT
QDBusPendingReply
(
const
QDBusPendingCall
&
call
)
// required by qdbusxml2cpp-generated code
73
{ *
this
=
call
; }
74
inline
Q_IMPLICIT
QDBusPendingReply
(
const
QDBusMessage
&
message
)
75
{ *
this
=
message
; }
76
77
inline
QDBusPendingReply
&
operator
=(
const
QDBusPendingCall &call)
78
{ assign(call);
return
*
this
; }
79
inline
QDBusPendingReply
&
operator
=(
const
QDBusMessage &message)
80
{ assign(message);
return
*
this
; }
81
82
using
QDBusPendingReplyBase
::argumentAt;
83
template
<
int
Index>
inline
84
typename
Select
<
Index
>::
Type
argumentAt
()
const
85
{
86
static_assert
(Index >= 0 && Index <
Count
,
"Index out of bounds"
);
87
typedef
typename
Select<Index>::Type ResultType;
88
return
qdbus_cast<ResultType>(argumentAt(Index));
89
}
90
91
#
if
defined
(
Q_QDOC
)
92
bool
isFinished
()
const
;
93
void
waitForFinished
();
94
QVariant
argumentAt
(
int
index
)
const
;
95
96
bool
isValid
()
const
;
97
bool
isError
()
const
;
98
QDBusError
error
()
const
;
99
QDBusMessage
reply
()
const
;
100
#
endif
101
102
inline
typename
Select
<0>::
Type
value
()
const
103
{
104
return
argumentAt<0>();
105
}
106
107
inline
operator
typename
Select
<0>::
Type
()
const
108
{
109
return
argumentAt
<0>();
110
}
111
112
private
:
113
inline
void
calculateMetaTypes
()
114
{
115
if
(!
d
)
return
;
116
if
constexpr
(
Count
== 0) {
117
setMetaTypes
(0,
nullptr
);
118
}
else
{
119
std
::
array
<
QMetaType
,
Count
>
typeIds
= {
QDBusPendingReplyTypes
::
metaTypeFor
<
Types
>()... };
120
setMetaTypes
(
Count
,
typeIds
.
data
());
121
}
122
}
123
124
inline
void
assign
(
const
QDBusPendingCall
&
call
)
125
{
126
QDBusPendingReplyBase
::
assign
(
call
);
127
calculateMetaTypes
();
128
}
129
130
inline
void
assign
(
const
QDBusMessage
&
message
)
131
{
132
QDBusPendingReplyBase
::
assign
(
message
);
133
calculateMetaTypes
();
134
}
135
};
136
137
template
<>
138
class
QDBusPendingReply
<> :
public
QDBusPendingReplyBase
139
{
140
friend
class
::tst_QDBusPendingReply;
141
public
:
142
enum
{
Count
= 0 };
143
inline
int
count
()
const
{
return
Count
; }
144
145
inline
QDBusPendingReply
() =
default
;
146
// Rule Of Zero applies!
147
148
inline
Q_IMPLICIT
QDBusPendingReply
(
const
QDBusPendingCall
&
call
)
// required by qdbusxml2cpp-generated code
149
{ *
this
=
call
; }
150
inline
Q_IMPLICIT
QDBusPendingReply
(
const
QDBusMessage
&
message
)
151
{ *
this
=
message
; }
152
153
inline
QDBusPendingReply
&
operator
=(
const
QDBusPendingCall &call)
154
{ assign(call);
return
*
this
; }
155
inline
QDBusPendingReply
&
operator
=(
const
QDBusMessage &message)
156
{ assign(message);
return
*
this
; }
157
158
private
:
159
inline
void
assign(
const
QDBusPendingCall &call)
160
{
161
QDBusPendingReplyBase::assign(call);
162
if
(d)
163
setMetaTypes(0,
nullptr
);
164
}
165
166
inline
void
assign(
const
QDBusMessage &message)
167
{
168
QDBusPendingReplyBase::assign(message);
169
if
(d)
170
setMetaTypes(0,
nullptr
);
171
}
172
173
};
174
175
QT_END_NAMESPACE
176
177
#
endif
// QT_NO_DBUS
178
#
endif
QDBusPendingReplyBase
Definition
qdbuspendingreply.h:20
QDBusPendingReply<>
Definition
qdbuspendingreply.h:139
QDBusPendingReply<>::QDBusPendingReply
QDBusPendingReply()=default
QDBusPendingReply<>::count
int count() const
Definition
qdbuspendingreply.h:143
QDBusPendingReply<>::Count
@ Count
Definition
qdbuspendingreply.h:142
QDBusPendingReply<>::operator=
QDBusPendingReply & operator=(const QDBusPendingCall &call)
Definition
qdbuspendingreply.h:153
QDBusPendingReply
\inmodule QtDBus
Definition
qdbuspendingreply.h:61
QDBusPendingReply::argumentAt
Select< Index >::Type argumentAt() const
Returns the argument at position index in the reply's contents.
Definition
qdbuspendingreply.h:84
QDBusPendingReply::count
constexpr int count() const
Return the number of arguments the reply is supposed to have.
Definition
qdbuspendingreply.h:67
QDBusPendingReply::QDBusPendingReply
QDBusPendingReply()=default
Creates an empty QDBusPendingReply object.
QDBusPendingReply::Count
@ Count
Definition
qdbuspendingreply.h:65
QDBusPendingReply::value
Select< 0 >::Type value() const
Returns the first argument in this reply, cast to type Types[0] (the first template parameter of this...
Definition
qdbuspendingreply.h:102
QDBusPendingReply::operator=
QDBusPendingReply & operator=(const QDBusPendingCall &call)
Makes this object take its contents from the call pending call and drops the reference to the current...
Definition
qdbuspendingreply.h:77
QDBusPendingReplyTypes
Definition
qdbuspendingreply.h:38
QDBusPendingReplyTypes::metaTypeFor
QMetaType metaTypeFor()
Definition
qdbuspendingreply.h:51
QDBusPendingReplyTypes::Select< 0, T, Types... >
Definition
qdbuspendingreply.h:47
QDBusPendingReplyTypes::Select< 0, T, Types... >::Type
T Type
Definition
qdbuspendingreply.h:48
QDBusPendingReplyTypes::Select
Definition
qdbuspendingreply.h:41
QDBusPendingReplyTypes::Select::Type
Next::Type Type
Definition
qdbuspendingreply.h:43
QDBusPendingReplyTypes::Select::Next
Select< Index - 1, Types... > Next
Definition
qdbuspendingreply.h:42
qtbase
src
dbus
qdbuspendingreply.h
Generated on
for Qt by
1.18.0