kodi
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Friends | List of all members
PLT_StateVariable Class Reference

The PLT_StateVariable class maintains the state of a UPnP Service state variable. More...

#include <PltStateVariable.h>

Collaboration diagram for PLT_StateVariable:
Collaboration graph
[legend]

Public Member Functions

 PLT_StateVariable (PLT_Service *service)
 
NPT_Result GetSCPDXML (NPT_XmlElementNode *node)
 Populate the SCPD xml document with state variable information. More...
 
PLT_ServiceGetService ()
 Return the PLT_Service that this state variable is associated with. More...
 
bool IsSendingEvents (bool indirectly=false)
 Return whether the state variable is eventable directly or indirectly. More...
 
void DisableIndirectEventing ()
 Force the state variable to send events directly.
 
NPT_Result SetRate (NPT_TimeInterval rate)
 Certain state variables notifications must not be sent faster than a certain rate according to the UPnP specs. More...
 
NPT_Result SetValue (const char *value, const bool clearonsend=false)
 Set the state variable value. More...
 
NPT_Result ValidateValue (const char *value)
 Validate the new value of the state variable. More...
 
NPT_Result SetExtraAttribute (const char *name, const char *value)
 Certain state variables require extra xml attributes when serialized. More...
 
const NPT_StringGetName () const
 Return the state variable name. More...
 
const NPT_StringGetValue () const
 Return the current state variable value. More...
 
const NPT_StringGetDataType () const
 Return the state variable data type. More...
 
const NPT_AllowedValueRangeGetAllowedValueRange () const
 Return the state variable allowed value range if any. More...
 

Static Public Member Functions

static PLT_StateVariableFind (NPT_List< PLT_StateVariable *> &vars, const char *name)
 Helper function to return a state variable given a list of state variables and a state variable name. More...
 

Protected Member Functions

bool IsReadyToPublish ()
 Return whether the state variable value changed and subscribers need to be notified.
 
void OnSendCompleted ()
 If this statevariable should clear after sending to all subscribers, clears the value without eventing the change.
 
NPT_Result Serialize (NPT_XmlElementNode &node)
 Serialize the state variable into xml.
 

Protected Attributes

PLT_Servicem_Service
 
NPT_AllowedValueRangem_AllowedValueRange
 
NPT_String m_Name
 
NPT_String m_DataType
 
NPT_String m_DefaultValue
 
bool m_IsSendingEvents
 
bool m_IsSendingEventsIndirectly
 
bool m_ShouldClearOnSend
 
NPT_TimeInterval m_Rate
 
NPT_TimeStamp m_LastEvent
 
NPT_Array< NPT_String * > m_AllowedValues
 
NPT_String m_Value
 
NPT_Map< NPT_String, NPT_Stringm_ExtraAttributes
 

Friends

class PLT_Service
 
class PLT_LastChangeXMLIterator
 

Detailed Description

The PLT_StateVariable class maintains the state of a UPnP Service state variable.

It is used by a PLT_DeviceHost instance to notify subscribers of a change or by a subscriber (PLT_CtrlPoint) when a service state variable change notification has been received.

Member Function Documentation

◆ Find()

PLT_StateVariable * PLT_StateVariable::Find ( NPT_List< PLT_StateVariable *> &  vars,
const char *  name 
)
static

Helper function to return a state variable given a list of state variables and a state variable name.

Parameters
varslist of state variables
namestate variable name to look for
Returns
PLT_StateVariable pointer.

◆ GetAllowedValueRange()

const NPT_AllowedValueRange* PLT_StateVariable::GetAllowedValueRange ( ) const
inline

Return the state variable allowed value range if any.

Returns
state variable value range pointer or null if none.

◆ GetDataType()

const NPT_String& PLT_StateVariable::GetDataType ( ) const
inline

Return the state variable data type.

Returns
state variable data type.

◆ GetName()

const NPT_String& PLT_StateVariable::GetName ( ) const
inline

Return the state variable name.

Returns
state variable name.

◆ GetSCPDXML()

NPT_Result PLT_StateVariable::GetSCPDXML ( NPT_XmlElementNode node)

Populate the SCPD xml document with state variable information.

Parameters
nodeXML Element where to insert the state variable XML Element

◆ GetService()

PLT_Service * PLT_StateVariable::GetService ( )

Return the PLT_Service that this state variable is associated with.

Returns
PLT_Service pointer.

◆ GetValue()

const NPT_String& PLT_StateVariable::GetValue ( ) const
inline

Return the current state variable value.

Returns
state variable current value.

◆ IsSendingEvents()

bool PLT_StateVariable::IsSendingEvents ( bool  indirectly = false)

Return whether the state variable is eventable directly or indirectly.

A state variable sends events indirectly when part of the "LastChange" state variable.

Parameters
indirectlyBoolean to test if the state variable is sending events indirectly
Returns
Whether the state variable sends events according to the input flag specified.

◆ SetExtraAttribute()

NPT_Result PLT_StateVariable::SetExtraAttribute ( const char *  name,
const char *  value 
)

Certain state variables require extra xml attributes when serialized.

Parameters
namethe attribute name
valuethe attribute value

◆ SetRate()

NPT_Result PLT_StateVariable::SetRate ( NPT_TimeInterval  rate)

Certain state variables notifications must not be sent faster than a certain rate according to the UPnP specs.

This sets the rate for a given state variable.

Parameters
ratetime interval to respect between notifications.

◆ SetValue()

NPT_Result PLT_StateVariable::SetValue ( const char *  value,
const bool  clearonsend = false 
)

Set the state variable value.

The value is first validated to make sure it is an allowed value. Once the value is validated, it is marked for eventing by calling the PLT_Service AddChanged function.

Parameters
valuenew state variable value. Can be a comma separated list of values.
clearonsendwhether the statevariable should be cleared immediatly after sending

◆ ValidateValue()

NPT_Result PLT_StateVariable::ValidateValue ( const char *  value)

Validate the new value of the state variable.

Parameters
valuenew state variable value. Can be a comma separated list of values.

The documentation for this class was generated from the following files: