![]() |
Qt 6.x
The Qt SDK
|
\inmodule QtDBus More...
#include <qdbuspendingreply.h>
Public Types | |
enum | { Count = std::is_same_v<typename Select<0>::Type, void> ? 0 : sizeof...(Types) } |
Public Member Functions | |
constexpr int | count () const |
Return the number of arguments the reply is supposed to have. | |
QDBusPendingReply ()=default | |
Creates an empty QDBusPendingReply object. | |
QDBusPendingReply (const QDBusPendingReply &other) | |
Creates a copy of the other QDBusPendingReply object. | |
Q_IMPLICIT | QDBusPendingReply (const QDBusPendingCall &call) |
Creates a QDBusPendingReply object that will take its contents from the call pending asynchronous call. | |
Q_IMPLICIT | QDBusPendingReply (const QDBusMessage &message) |
Creates a QDBusPendingReply object that will take its contents from the message message. | |
QDBusPendingReply & | operator= (const QDBusPendingReply &other) |
Makes a copy of other and drops the reference to the current pending call. | |
QDBusPendingReply & | operator= (const QDBusPendingCall &call) |
Makes this object take its contents from the call pending call and drops the reference to the current pending call. | |
QDBusPendingReply & | operator= (const QDBusMessage &message) |
Makes this object take its contents from the message message and drops the reference to the current pending call. | |
template<int Index> | |
Select< Index >::Type | argumentAt () const |
Returns the argument at position index in the reply's contents. | |
Select< 0 >::Type | value () const |
Returns the first argument in this reply, cast to type Types [0] (the first template parameter of this class). | |
operator typename Select< 0 >::Type () const | |
Returns the first argument in this reply, cast to type Types [0] (the first template parameter of this class). | |
QVariant | argumentAt (int index) const |
![]() | |
QDBusPendingCall (const QDBusPendingCall &other) | |
Creates a copy of the other pending asynchronous call. | |
~QDBusPendingCall () | |
Destroys this copy of the QDBusPendingCall object. | |
QDBusPendingCall & | operator= (QDBusPendingCall &&other) noexcept |
QDBusPendingCall & | operator= (const QDBusPendingCall &other) |
Creates a copy of the other pending asynchronous call and drops the reference to the previously-referenced call. | |
void | swap (QDBusPendingCall &other) noexcept |
bool | isFinished () const |
void | waitForFinished () |
bool | isError () const |
bool | isValid () const |
QDBusError | error () const |
QDBusMessage | reply () const |
Additional Inherited Members | |
![]() | |
static QDBusPendingCall | fromError (const QDBusError &error) |
static QDBusPendingCall | fromCompletedCall (const QDBusMessage &message) |
![]() | |
QDBusPendingReplyBase () | |
~QDBusPendingReplyBase () | |
void | assign (const QDBusPendingCall &call) |
void | assign (const QDBusMessage &message) |
QVariant | argumentAt (int index) const |
void | setMetaTypes (int count, const QMetaType *metaTypes) |
![]() | |
QDBusPendingCall (QDBusPendingCallPrivate *dd) | |
![]() | |
QExplicitlySharedDataPointer< QDBusPendingCallPrivate > | d |
\inmodule QtDBus
The QDBusPendingReply class contains the reply to an asynchronous method call.
The QDBusPendingReply is a variadic template class. The template parameters are the types that will be used to extract the contents of the reply's data.
This class is similar in functionality to QDBusReply, but with two important differences:
\list
Where with QDBusReply you would write:
with QDBusPendingReply, the equivalent code (including the blocking wait for the reply) would be:
For method calls that have more than one output argument, with QDBusReply, you would write:
whereas with QDBusPendingReply, all of the output arguments should be template parameters:
QDBusPendingReply objects can be associated with QDBusPendingCallWatcher objects, which emit signals when the reply arrives.
Definition at line 50 of file qdbuspendingreply.h.
anonymous enum |
Enumerator | |
---|---|
Count |
Definition at line 54 of file qdbuspendingreply.h.
|
inlinedefault |
Creates an empty QDBusPendingReply object.
Without assigning a QDBusPendingCall object to this reply, QDBusPendingReply cannot do anything. All functions return their failure values.
|
inline |
Creates a copy of the other QDBusPendingReply object.
Just like QDBusPendingCall and QDBusPendingCallWatcher, this QDBusPendingReply object will share the same pending call reference. All copies share the same return values.
Definition at line 60 of file qdbuspendingreply.h.
|
inline |
Creates a QDBusPendingReply object that will take its contents from the call pending asynchronous call.
This QDBusPendingReply object will share the same pending call reference as call.
Definition at line 63 of file qdbuspendingreply.h.
|
inline |
Creates a QDBusPendingReply object that will take its contents from the message message.
In this case, this object will be already in its finished state and the reply's contents will be accessible.
Definition at line 65 of file qdbuspendingreply.h.
|
inline |
Returns the argument at position index in the reply's contents.
If the reply doesn't have that many elements, this function's return value is undefined (will probably cause an assertion failure), so it is important to verify that the processing is finished and the reply is valid.
If the reply does not contain an argument at position index or if the reply was an error, this function returns an invalid QVariant. Since D-Bus messages can never contain invalid QVariants, this return can be used to detect an error condition.
Definition at line 77 of file qdbuspendingreply.h.
References QDBusPendingReply< Types >::argumentAt(), and QDBusPendingReply< Types >::Count.
Referenced by QDBusPendingReply< Types >::argumentAt().
QVariant QDBusPendingReplyBase::argumentAt | ( | int | index | ) | const |
Definition at line 24 of file qdbuspendingreply.cpp.
|
inlineconstexpr |
Return the number of arguments the reply is supposed to have.
This number matches the number of non-void template parameters in this class.
If the reply arrives with a different number of arguments (or with different types), it will be transformed into an error reply indicating a bad signature.
Definition at line 56 of file qdbuspendingreply.h.
References QDBusPendingReply< Types >::Count.
|
inline |
Returns the first argument in this reply, cast to type Types
[0] (the first template parameter of this class).
This is equivalent to calling argumentAt<0>().
This function is provided as a convenience, matching the QDBusReply::value() function.
Note that, if the reply hasn't arrived, this function causes the calling thread to block until the reply is processed.
If the reply is an error reply, this function returns a default-constructed Types
[0] object, which may be indistinguishable from a valid value. To reliably determine whether the message was an error, use isError().
Definition at line 100 of file qdbuspendingreply.h.
|
inline |
Makes this object take its contents from the message message and drops the reference to the current pending call.
If the current reference is to an unfinished pending call and this is the last reference, the pending call will be canceled and there will be no way of retrieving the reply's contents, when they arrive.
After this function is finished, the QDBusPendingReply object will be in its "finished" state and the message contents will be accessible.
Definition at line 72 of file qdbuspendingreply.h.
|
inline |
Makes this object take its contents from the call pending call and drops the reference to the current pending call.
If the current reference is to an unfinished pending call and this is the last reference, the pending call will be canceled and there will be no way of retrieving the reply's contents, when they arrive.
Definition at line 70 of file qdbuspendingreply.h.
|
inline |
Makes a copy of other and drops the reference to the current pending call.
If the current reference is to an unfinished pending call and this is the last reference, the pending call will be canceled and there will be no way of retrieving the reply's contents, when they arrive.
Definition at line 68 of file qdbuspendingreply.h.
References other().
|
inline |
Returns the first argument in this reply, cast to type Types
[0] (the first template parameter of this class).
This is equivalent to calling argumentAt<0>().
This function is provided as a convenience, matching the QDBusReply::value() function.
Note that, if the reply hasn't arrived, this function causes the calling thread to block until the reply is processed.
If the reply is an error reply, this function returns a default-constructed Types
[0] object, which may be indistinguishable from a valid value. To reliably determine whether the message was an error, use isError().
Definition at line 95 of file qdbuspendingreply.h.
Referenced by QNetworkManagerInterface::QNetworkManagerInterface().