Signals | Public Member Functions | Protected Member Functions

HServerStateVariable Class Reference
[Device Model]

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

#include <HServerStateVariable>

Inherited by HDefaultServerStateVariable.

List of all members.

Signals

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

Public Member Functions

virtual ~HServerStateVariable ()=0
HServerServiceparentService () const
QVariant value () const
const HStateVariableInfoinfo () const
bool setValue (const QVariant &newValue)

Protected Member Functions

 HServerStateVariable (const HStateVariableInfo &info, HServerService *parent)

Detailed Description

HServerStateVariable is a core component of the HUPnP's server-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:
HServerStateVariable
Remarks:
This class is not thread-safe.

Constructor & Destructor Documentation

HServerStateVariable ( const HStateVariableInfo info,
HServerService parent 
) [protected]

Creates a new instance.

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

Destroys the instance.

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


Member Function Documentation

HServerService * parentService (  ) const

Returns the HServerService that contains this state variable.

Returns:
the HServerService that contains this state variable.
Warning:
the pointer is guaranteed to point to a valid object as long as the HServerStateVariable 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 ( Herqq::Upnp::HServerStateVariable ,
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.