Herqq

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- Class List
- Class Hierarchy
- Class Members

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
HClientService * | parentService () const
QVariant | value () const
const HStateVariableInfo & | info () const
## Protected Member Functions
| HClientStateVariable (const HStateVariableInfo &info, HClientService *parent)
bool | setValue (const QVariant &newValue)

## Detailed Description

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

`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:

  info | specifies information of the state variable. This is often read from a service description document.
  parent | specifies 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

bool setValue | ( | const QVariant & | newValue | ) | `[protected]`

Changes the value of the state variable.

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

Parameters:

  newValue | specifies 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:

  true | in case the new value was successfully set.
  false | in 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

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.

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:

  source | specifies the state variable that sent the event.
  event | specifies 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.