Public Member Functions

# HWritableStateVariable Class Reference
[Device Model]

Class that provides write access to a state variable. More...

`#include <HWritableStateVariable>`

Inheritance diagram for HWritableStateVariable:

List of all members.

## Public Member Functions
virtual | ~HWritableStateVariable ()
bool | setValue (const QVariant &newValue)

## Detailed Description

`HWritableStateVariable` is a core component of the HUPnP Device Model and it models a UPnP state variable, which allows read-write access. Typically, instances of this class are available only on server-side.

Attention:
  if you need exclusive access to a writable state variable, see HStateVariableLocker.

See also:
  Device Hosting, About State Variables, HStateVariable, HReadableStateVariable, HService, HStateVariableLocker

Remarks:
  the methods introduced in this class are thread-safe, but the `QObject` ancestor is largely not.

## Constructor & Destructor Documentation

~HWritableStateVariable | ( |  | ) | `[virtual]`

Destroys the instance.

An `HWritableStateVariable` is always destroyed by the containing HService when it is being deleted. You should never destroy an `HWritableStateVariable`.

## Member Function Documentation

bool setValue | ( | const QVariant & | newValue | ) |

Changes the value of the state variable.

If the instance is evented (eventingType() is not HStateVariable::NoEvents), after the value has been changed, valueChanged() signal is emitted.

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

Reimplemented from HStateVariable.