Herqq
Public Member Functions | Protected Member Functions

HAsyncOp Class Reference

This abstract class is used as a base for identifying an asynchronous operation and detail information of it. More...

#include <HAsyncOp>

Inheritance diagram for HAsyncOp:
HClientActionOp

List of all members.

Public Member Functions

virtual ~HAsyncOp ()=0
QString errorDescription () const
void setErrorDescription (const QString &arg)
int returnValue () const
void setReturnValue (int returnValue)
unsigned int id () const
bool isNull () const
bool operator! () const
virtual void abort ()

Protected Member Functions

 HAsyncOp ()
 HAsyncOp (qint32 returnCode, const QString &errorDescription)
 HAsyncOp (const HAsyncOp &)
HAsyncOpoperator= (const HAsyncOp &)

Detailed Description

This abstract class is used as a base for identifying an asynchronous operation and detail information of it.

Some HUPnP components provide an asynchronous interface for running possible long-standing operations. A most notable example of this is the client-side action invocation initiated with HClientAction::beginInvoke(). In cases like this, the class running the operation returns a derivative of this class, which is used to identify and describe the running operation.

Usage

The component that runs an asynchronous operation provides an instance derived from this class when the operation is started. A copy of that instance is provided also when the component signals the operation is complete. The provided instance uniquely identifies the operation, carries information whether the operation eventually succeeded or not and it may contain an error description in case of an error.

For example:

 HClientActionOp op = someActionObject->beginInvoke();

 //
 // The operation completes, after which you can:
 //

 int retVal = op.returnValue();
 // retrieve a return value indicating whether the operation succeeded.

 QString errDescr = op.errorDescription();
 // retrieve an error description if the operation failed.
Note:
HAsyncOp and any derivative class provided by HUPnP use explicit sharing, which basically means that every copy of an instance references the same underlying data and any change to that data is visible to all of the copies.
Remarks:
This class is not thread-safe.
See also:
HClientActionOp

Constructor & Destructor Documentation

HAsyncOp ( ) [protected]

Creates a new valid instance.

Creates a new valid instance, i.e isNull() always returns false.

See also:
isNull()
HAsyncOp ( qint32  returnCode,
const QString &  errorDescription 
) [protected]

Creates a new instance, invalid instance.

Parameters:
returnCodespecifies the return code.
errorDescriptionspecifies a human-readable description of the error that occurred.
HAsyncOp ( const HAsyncOp op) [protected]

Copy constructor.

Creates a shallow copy of other increasing the reference count of other.

~HAsyncOp ( ) [pure virtual]

Destroys the instance.

Decreases the reference count or destroys the instance once the reference count drops to zero.


Member Function Documentation

HAsyncOp & operator= ( const HAsyncOp op) [protected]

Assignment operator.

Switches this instance to refer to the contents of other increasing the reference count of other.

QString errorDescription ( ) const

Returns a human readable error description.

Returns:
a human readable error description, if any.
See also:
setErrorDescription()
void setErrorDescription ( const QString &  arg)

Sets a human readable error description.

Parameters:
argspecifies the human readable error description.
See also:
errorDescription()
int returnValue ( ) const

Returns the return value of the asynchronous operation.

See also:
setReturnValue()
void setReturnValue ( int  returnValue)

Sets the return value of the asynchronous operation.

Parameters:
returnValuespecifies the return value of the asynchronous operation.
See also:
returnValue()
unsigned int id ( ) const

Returns an identifier of the asynchronous operation.

Returns:
an identifier of the asynchronous operation. The identifier is "unique" within the process where the library is loaded. More specifically, the ID is monotonically incremented and it is allowed to overflow.
bool isNull ( ) const

Indicates whether the object identifies an asynchronous operation.

Return values:
truein case the object does not identify an asynchronous operation. This is usually the case when an operation was not successfully started.
falsein case the object identifies an asynchronous operation.
bool operator! ( ) const [inline]

Indicates whether the object identifies an asynchronous operation.

This is a convenience method and it is semantically equivalent with isNull().

Return values:
truein case the object does not identify an asynchronous operation. This is usually the case when an operation was not successfully started.
falsein case the object identifies an asynchronous operation.
void abort ( ) [virtual]

Aborts the execution of the operation.

Aborts the execution of the operation.

Remarks:
It is up to the implementation to decide whether to implement this. The default implementation does nothing.