kodi
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 
91  PLT_Service* GetService();
92 
99  bool IsSendingEvents(bool indirectly = false);
100 
104  void DisableIndirectEventing();
105 
111  NPT_Result SetRate(NPT_TimeInterval rate);
112 
120  NPT_Result SetValue(const char* value, const bool clearonsend = false);
121 
126  NPT_Result ValidateValue(const char* value);
127 
133  NPT_Result SetExtraAttribute(const char* name, const char* value);
134 
139  const NPT_String& GetName() const { return m_Name; }
140 
145  const NPT_String& GetValue() const { return m_Value; }
146 
151  const NPT_String& GetDataType() const { return m_DataType; }
152 
157  const NPT_AllowedValueRange* GetAllowedValueRange() const { return m_AllowedValueRange; }
158 
167  const char* name);
168 
169 protected:
174  bool IsReadyToPublish();
175 
180  void OnSendCompleted();
181 
185  NPT_Result Serialize(NPT_XmlElementNode& node);
186 
187 protected:
188  friend class PLT_Service;
189  friend class PLT_LastChangeXMLIterator;
190 
191  //members
192  PLT_Service* m_Service;
193  NPT_AllowedValueRange* m_AllowedValueRange;
194  NPT_String m_Name;
195  NPT_String m_DataType;
196  NPT_String m_DefaultValue;
197  bool m_IsSendingEvents;
198  bool m_IsSendingEventsIndirectly;
199  bool m_ShouldClearOnSend;
200  NPT_TimeInterval m_Rate;
201  NPT_TimeStamp m_LastEvent;
202  NPT_Array<NPT_String*> m_AllowedValues;
203  NPT_String m_Value;
204 
205  NPT_Map<NPT_String,NPT_String> m_ExtraAttributes;
206 };
207 
208 /*----------------------------------------------------------------------
209 | PLT_StateVariableNameFinder
210 +---------------------------------------------------------------------*/
216 {
217 public:
218  // methods
219  PLT_StateVariableNameFinder(const char* name) : m_Name(name) {}
220  virtual ~PLT_StateVariableNameFinder() {}
221 
222  bool operator()(const PLT_StateVariable* const & state_variable) const {
223  return state_variable->GetName().Compare(m_Name, true) ? false : true;
224  }
225 
226 private:
227  // members
228  NPT_String m_Name;
229 };
230 
231 #endif /* _PLT_STATE_VARIABLE_H_ */
NPT_Result GetSCPDXML(NPT_String &xml)
Return the service SCPD xml document.
Definition: PltService.cpp:91
const NPT_String & GetValue() const
Return the current state variable value.
Definition: PltStateVariable.h:145
The PLT_Argument class provides a mechanism to set or verify the validity of a specific UPNP service ...
Definition: PltArgument.h:99
Definition: NptXml.h:172
const NPT_AllowedValueRange * GetAllowedValueRange() const
Return the state variable allowed value range if any.
Definition: PltStateVariable.h:157
The PLT_LastChangeXMLIterator class is used to serialize the LastChange variable changes into xml giv...
Definition: PltService.h:509
Definition: NptArray.h:54
const NPT_String & GetName() const
Return the state variable name.
Definition: PltStateVariable.h:139
UPnP Service.
Definition: PltService.h:67
The PLT_StateVariableNameFinder class returns the PLT_StateVariable instance given a state variable n...
Definition: PltStateVariable.h:215
Definition: NptTime.h:50
The PLT_StateVariable class maintains the state of a UPnP Service state variable. ...
Definition: PltStateVariable.h:75
const NPT_String & GetDataType() const
Return the state variable data type.
Definition: PltStateVariable.h:151
The NPT_AllowedValueRange struct holds the min, max and step value allowed of a UPnP Service state va...
Definition: PltStateVariable.h:60
Definition: NptStrings.h:57
Definition: NptList.h:54