Signals | Public Member Functions | Protected Member Functions

HClientStateVariable Class Reference
[Device Model]

A client-side class that represents a server-side UPnP state variable. More...

#include <HClientStateVariable>

Inherited by HDefaultClientStateVariable.

List of all members.

Signals

void valueChanged (const Herqq::Upnp::HClientStateVariable *source, const Herqq::Upnp::HStateVariableEvent &event)

Public Member Functions

virtual ~HClientStateVariable ()=0
HClientServiceparentService () const
QVariant value () const
const HStateVariableInfoinfo () const
bool setValue (const QVariant &newValue)

Protected Member Functions

 HClientStateVariable (const HStateVariableInfo &info, HClientService *parent)

Detailed Description

HClientStateVariable is a core component of the HUPnP's client-side Device Model and it models a UPnP state variable. The UPnP Device Architecture specifies a UPnP state variable as an item or aspect that models state in a service. In a way a state variable is an abstraction to a member variable inside a UPnP service.

A state variable can be evented in which case it notifies interested listeners of changes in its value. You can see if a state variable is evented by checking the HStateVariableInfo object using info() and you can connect to the signal valueChanged() to be notified when the value of the state variable changes. Note, only evented state variables emit the valueChanged() signal.

See also:
HClientService
Remarks:
This class is not thread-safe.

Constructor & Destructor Documentation

HClientStateVariable ( const HStateVariableInfo info,
HClientService parent 
) [protected]

Creates a new instance.

Parameters:
infospecifies information of the state variable. This is often read from a service description document.
parentspecifies the UPnP service instance that contains this state variable.
~HClientStateVariable (  ) [pure virtual]

Destroys the instance.

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


Member Function Documentation

HClientService * parentService (  ) const

Returns the HClientService that contains this state variable.

Returns:
the HClientService that contains this state variable.
Warning:
the pointer is guaranteed to point to a valid object as long as the HClientStateVariable exists, which ultimately is as long as the containing root device exists.
QVariant value (  ) const

Returns the current value of the state variable.

Returns:
the current value of the state variable.
const HStateVariableInfo & info (  ) const

Returns information about the state variable.

Returns:
information about the state variable. This information is often read from a service description document.
bool setValue ( const QVariant &  newValue )

Changes the value of the state variable.

If the instance is evented, the valueChanegd() signal is emitted after the value has been changed.

Parameters:
newValuespecifies the new value of the state variable. The new value must have the same underlying data type as the previous value (and the default value). If the new value has different data type, the value is not changed, no event is sent and false is returned.
Return values:
truein case the new value was successfully set.
falsein case the new value could not be set.
Remarks:
the new value will be set if the value:
  • does not violate the defined constraints
  • has the same variant type or the type of the new value can be converted to the same variant type
  • is not QVariant::Invalid
void valueChanged ( const Herqq::Upnp::HClientStateVariable source,
const Herqq::Upnp::HStateVariableEvent event 
) [signal]

This signal is emitted when the value of the state variable has changed.

Parameters:
sourcespecifies the state variable that sent the event.
eventspecifies information about the event that occurred.
Remarks:
This signal has thread affinity to the thread where the object resides. Do not connect to this signal from other threads.