Public Member Functions | Protected Member Functions

HServerAction Class Reference
[Device Model]

A class that represents a server-side UPnP action. More...

Inherited by HDefaultServerAction.

List of all members.

Public Member Functions

virtual ~HServerAction ()=0
HServerServiceparentService () const
const HActionInfoinfo () const
qint32 invoke (const HActionArguments &inArgs, HActionArguments *outArgs=0)

Protected Member Functions

 HServerAction (const HActionInfo &info, HServerService *parentService)

Detailed Description

HServerAction is a core component of the HUPnP's server-side Device Model and it models a UPnP action. The UPnP Device Architecture specifies a UPnP action as command, which takes one or more input or output arguments and that may have a return value.

This class is used to invoke the server-side UPnP actions directly in process. You can get information of the action using info(), which includes the action's input and output arguments. You can invoke an action synchronously using invoke().

See also:
HActionInfo, HServerService
Remarks:
This class is not thread-safe.

Constructor & Destructor Documentation

HServerAction ( const HActionInfo info,
HServerService parentService 
) [protected]

Creates a new instance.

Parameters:
infospecifies information of the action. This is usually read from a service description document.
parentServicespecifies the UPnP service instance that contains this action.
~HServerAction (  ) [pure virtual]

Destroys the instance.

An HServerAction is always destroyed by the HServerService that contains it when it is being deleted. Further, unless you hold the ownership of the HServerAction instance, you should never destroy it.


Member Function Documentation

HServerService * parentService (  ) const

Returns the parent service of the action.

Returns:
the parent service of the action.
Warning:
the pointer is guaranteed to point to a valid object as long as the HServerAction exists, which ultimately is as long as the containing root device exists.
See also:
HServerDevice
const HActionInfo & info (  ) const

Returns information about the action that is read from the service description.

Returns:
information about the action that is read from the service description.
qint32 invoke ( const HActionArguments inArgs,
HActionArguments outArgs = 0 
)

Invokes the action synchronously.

For example,

 Herqq::Upnp::HActionArguments inArgs = action->info().inputArguments();
 inArgs.setValue("EchoInArgument", "Ping");

 Herqq::Upnp::HActionArguments outArgs;

 qint32 retVal = action->invoke(inArgs, &outArgs);
 if (retVal == Herqq::Upnp::HServerAction::Success)
 {
     qDebug() << outArgs.value("EchoOutArgument").toString();
 }
Parameters:
inArgsspecifies the input arguments for the action.
outArgsspecifies a pointer to HActionArguments instance created by the user. This can be null in which case the output arguments will not be set even if the action has output arguments. If the parameter is specified and the action has output arguments, the values of the arguments will be set accordingly. If the action doesn't have output arguments, the parameter is ignored.
Returns:
UpnpSuccess on success. Any other value indicates that an error occurred.