Platinum UPnP SDK  1.0.5.13
PltStateVariable.h
Go to the documentation of this file.
1 /*****************************************************************
2 |
3 | Platinum - Service State Variable
4 |
5 | Copyright (c) 2004-2010, Plutinosoft, LLC.
6 | All rights reserved.
7 | http://www.plutinosoft.com
8 |
9 | This program is free software; you can redistribute it and/or
10 | modify it under the terms of the GNU General Public License
11 | as published by the Free Software Foundation; either version 2
12 | of the License, or (at your option) any later version.
13 |
14 | OEMs, ISVs, VARs and other distributors that combine and
15 | distribute commercially licensed software with Platinum software
16 | and do not wish to distribute the source code for the commercially
17 | licensed software under version 2, or (at your option) any later
18 | version, of the GNU General Public License (the "GPL") must enter
19 | into a commercial license agreement with Plutinosoft, LLC.
20 | licensing@plutinosoft.com
21 |
22 | This program is distributed in the hope that it will be useful,
23 | but WITHOUT ANY WARRANTY; without even the implied warranty of
24 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 | GNU General Public License for more details.
26 |
27 | You should have received a copy of the GNU General Public License
28 | along with this program; see the file LICENSE.txt. If not, write to
29 | the Free Software Foundation, Inc.,
30 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
31 | http://www.gnu.org/licenses/gpl-2.0.html
32 |
33 ****************************************************************/
34 
39 #ifndef _PLT_STATE_VARIABLE_H_
40 #define _PLT_STATE_VARIABLE_H_
41 
42 /*----------------------------------------------------------------------
43 | includes
44 +---------------------------------------------------------------------*/
45 #include "Neptune.h"
46 
47 /*----------------------------------------------------------------------
48 | forward declarations
49 +---------------------------------------------------------------------*/
50 class PLT_Argument;
51 class PLT_Service;
52 
53 /*----------------------------------------------------------------------
54 | NPT_AllowedValueRange struct
55 +---------------------------------------------------------------------*/
60 typedef struct {
61  NPT_Int32 min_value;
62  NPT_Int32 max_value;
63  NPT_Int32 step;
65 
66 /*----------------------------------------------------------------------
67 | PLT_StateVariable class
68 +---------------------------------------------------------------------*/
76 {
77 public:
80 
85  NPT_Result GetSCPDXML(NPT_XmlElementNode* node);
86 
92 
99  bool IsSendingEvents(bool indirectly = false);
100 
105 
111  NPT_Result SetRate(NPT_TimeInterval rate);
112 
119  NPT_Result SetValue(const char* value);
120 
125  NPT_Result ValidateValue(const char* value);
126 
132  NPT_Result SetExtraAttribute(const char* name, const char* value);
133 
138  const NPT_String& GetName() const { return m_Name; }
139 
144  const NPT_String& GetValue() const { return m_Value; }
145 
150  const NPT_String& GetDataType() const { return m_DataType; }
151 
156  const NPT_AllowedValueRange* GetAllowedValueRange() const { return m_AllowedValueRange; }
157 
165  static PLT_StateVariable* Find(NPT_List<PLT_StateVariable*>& vars,
166  const char* name);
167 
168 protected:
173  bool IsReadyToPublish();
174 
178  NPT_Result Serialize(NPT_XmlElementNode& node);
179 
180 protected:
181  friend class PLT_Service;
182  friend class PLT_LastChangeXMLIterator;
183 
184  //members
185  PLT_Service* m_Service;
186  NPT_AllowedValueRange* m_AllowedValueRange;
187  NPT_String m_Name;
188  NPT_String m_DataType;
189  NPT_String m_DefaultValue;
190  bool m_IsSendingEvents;
191  bool m_IsSendingEventsIndirectly;
192  NPT_TimeInterval m_Rate;
193  NPT_TimeStamp m_LastEvent;
194  NPT_Array<NPT_String*> m_AllowedValues;
195  NPT_String m_Value;
196 
197  NPT_Map<NPT_String,NPT_String> m_ExtraAttributes;
198 };
199 
200 /*----------------------------------------------------------------------
201 | PLT_StateVariableNameFinder
202 +---------------------------------------------------------------------*/
208 {
209 public:
210  // methods
211  PLT_StateVariableNameFinder(const char* name) : m_Name(name) {}
212  virtual ~PLT_StateVariableNameFinder() {}
213 
214  bool operator()(const PLT_StateVariable* const & state_variable) const {
215  return state_variable->GetName().Compare(m_Name, true) ? false : true;
216  }
217 
218 private:
219  // members
220  NPT_String m_Name;
221 };
222 
223 #endif /* _PLT_STATE_VARIABLE_H_ */
const NPT_AllowedValueRange * GetAllowedValueRange() const
Return the state variable allowed value range if any.
Definition: PltStateVariable.h:156
The PLT_Argument class provides a mechanism to set or verify the validity of a specific UPNP service ...
Definition: PltArgument.h:99
bool IsReadyToPublish()
Return whether the state variable value changed and subscribers need to be notified.
The PLT_LastChangeXMLIterator class is used to serialize the LastChange variable changes into xml giv...
Definition: PltService.h:508
const NPT_String & GetName() const
Return the state variable name.
Definition: PltStateVariable.h:138
UPnP Service.
Definition: PltService.h:67
The PLT_StateVariableNameFinder class returns the PLT_StateVariable instance given a state variable n...
Definition: PltStateVariable.h:207
The PLT_StateVariable class maintains the state of a UPnP Service state variable. ...
Definition: PltStateVariable.h:75
bool IsSendingEvents(bool indirectly=false)
Return whether the state variable is eventable directly or indirectly.
const NPT_String & GetDataType() const
Return the state variable data type.
Definition: PltStateVariable.h:150
static PLT_StateVariable * Find(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...
NPT_Result ValidateValue(const char *value)
Validate the new value of the state variable.
PLT_Service * GetService()
Return the PLT_Service that this state variable is associated with.
NPT_Result SetValue(const char *value)
Set the state variable value.
The NPT_AllowedValueRange struct holds the min, max and step value allowed of a UPnP Service state va...
Definition: PltStateVariable.h:60
NPT_Result SetRate(NPT_TimeInterval rate)
Certain state variables notifications must not be sent faster than a certain rate according to the UP...
NPT_Result Serialize(NPT_XmlElementNode &node)
Serialize the state variable into xml.
const NPT_String & GetValue() const
Return the current state variable value.
Definition: PltStateVariable.h:144
NPT_Result GetSCPDXML(NPT_XmlElementNode *node)
Populate the SCPD xml document with state variable information.
void DisableIndirectEventing()
Force the state variable to send events directly.
NPT_Result SetExtraAttribute(const char *name, const char *value)
Certain state variables require extra xml attributes when serialized.