CopperSpice DBUS  1.7.4
QDBusReply< T > Class Template Reference

Contains the reply returned by sending a message to a remote object. More...

Public Methods

 QDBusReply (const QDBusError &error=QDBusError ())
 
 QDBusReply (const QDBusMessage &reply)
 
 QDBusReply (const QDBusPendingCall &pcall)
 
 QDBusReply (const QDBusPendingReply< T > &reply)
 
const QDBusErrorerror ()
 
const QDBusErrorerror () const
 
bool isValid () const
 
 operator Type () const
 
QDBusReply & operator= (const QDBusError &error)
 
QDBusReply & operator= (const QDBusMessage &message)
 
QDBusReply & operator= (const QDBusPendingCall &pcall)
 
QDBusReply & operator= (const QDBusReply &other)
 
Type value () const
 

Detailed Description

template<typename T>
class QDBusReply< T >

The QDBusReply class contains the reply returned by sending a message to a remote object. The reply is either the first return value or an error code. These values can be used by classes which inherit from QDBusInterface.

Example

The folllowing example shows how to use the QDBusReply class.

QDBusReply<QString> reply = interface->call("RemoteMethod");
if (reply.isValid()) {
// use the returned value
useValue(reply.value());
} else {
// call failed, show an error condition
showError(reply.error());
}
See also
QDBusMessage, QDBusInterface, QDBusPendingReply

Constructor & Destructor Documentation

template<typename T >
QDBusReply< T >::QDBusReply ( const QDBusMessage reply)
inline

(broom)

Constructs a new QDBusReply object from the given reply, extracting the first return value from it if it is a success reply.

template<typename T >
QDBusReply< T >::QDBusReply ( const QDBusPendingCall pcall)
inline

(broom)

Constructs a new QDBusReply object from the asynchronous pending pcall. If the call is not finished yet, QDBusReply will call QDBusPendingCall::waitForFinished(), which is a blocking operation.

If the return types patch, QDBusReply will extract the first return argument from the reply.

template<typename T >
QDBusReply< T >::QDBusReply ( const QDBusPendingReply< T > &  reply)
inline

Constructs a new QDBusReply object from the pending reply message.

template<typename T >
QDBusReply< T >::QDBusReply ( const QDBusError error = QDBusError())
inline

Constructs an error reply from the D-Bus error code given by error.

Method Documentation

template<typename T >
const QDBusError & QDBusReply< T >::error ( )
inline

(broom)

template<typename T >
const QDBusError & QDBusReply< T >::error ( ) const
inline

(broom)

Returns the error code returned from the call to the remote object.

If the remote call did not return an error then the QDBusError object that is returned will not be a valid error code (QDBusError::isValid() will return false).

See also
isValid()
template<typename T >
bool QDBusReply< T >::isValid ( ) const
inline

Returns true if no error occurred otherwise, returns false.

See also
error()
template<typename T >
QDBusReply< T >::operator Type ( ) const
inline

Returns the same as value(). This method is not available if the remote call returns "void".

template<typename T >
QDBusReply & QDBusReply< T >::operator= ( const QDBusError error)
inline

(broom)

Sets this object to contain the error code given by error. You can later access it with error().

template<typename T >
QDBusReply & QDBusReply< T >::operator= ( const QDBusMessage message)
inline

(broom)

Makes this object contain the reply specified by the given message. If message is an error message, this function will copy the error code and message into this object

If message is a standard reply message and contains at least one parameter, it will be copied into this object, as long as it is of the correct type. If it is not of the same type as this QDBusError object, this function will instead set an error code indicating a type mismatch.

template<typename T >
QDBusReply & QDBusReply< T >::operator= ( const QDBusPendingCall pcall)
inline

(broom)

Makes this object contain the reply specified by the pending asynchronous call pcall. If the call is not finished yet, this function will call QDBusPendingCall::waitForFinished() to block until the reply arrives.

If pcall finishes with an error message, this function will copy the error code and message into this object

If pcall finished with a standard reply message and contains at least one parameter, it will be copied into this object, as long as it is of the correct type. If it's not of the same type as this QDBusError object, this function will instead set an error code indicating a type mismatch.

template<typename T >
QDBusReply & QDBusReply< T >::operator= ( const QDBusReply< T > &  other)
inline

Copy assigns from other and returns a reference to this object.

template<typename T >
Type QDBusReply< T >::value ( ) const
inline

Returns the remote function's calls return value. If the remote call returned with an error, the return value of this function is undefined and may be undistinguishable from a valid return value.

This method is not available if the remote call returns "void".