Merge pull request #26220 from 78andyp/blurayfixes
[xbmc.git] / lib / libUPnP / Platinum / Source / Core / PltArgument.h
blob4730e28ca3cd5ad956f50d03d455b46ed92fba95
1 /*****************************************************************
3 | Platinum - Action Argument
5 | Copyright (c) 2004-2010, Plutinosoft, LLC.
6 | All rights reserved.
7 | http://www.plutinosoft.com
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.
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
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.
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
33 ****************************************************************/
35 /** @file
36 UPnP Service Action Argument
39 #ifndef _PLT_ARGUMENT_H_
40 #define _PLT_ARGUMENT_H_
42 /*----------------------------------------------------------------------
43 | includes
44 +---------------------------------------------------------------------*/
45 #include "Neptune.h"
47 /*----------------------------------------------------------------------
48 | forward declarations
49 +---------------------------------------------------------------------*/
50 class PLT_StateVariable;
51 class PLT_Argument;
52 class PLT_ActionDesc;
53 typedef NPT_Array<PLT_Argument*> PLT_Arguments;
55 /*----------------------------------------------------------------------
56 | PLT_ArgumentDesc
57 +---------------------------------------------------------------------*/
58 /**
59 The PLT_ArgumentDesc class provides information about a given argument of a
60 UPnP Service given action.
61 It has a name, a position, a direction (in/out), a PLT_StateVariable state
62 variable association and whether it is the return value of the action or not.
64 class PLT_ArgumentDesc
66 public:
67 PLT_ArgumentDesc(const char* name,
68 NPT_Ordinal position,
69 const char* direction = "in",
70 PLT_StateVariable* variable = NULL,
71 bool has_ret = false);
73 // accessor methods
74 NPT_Result GetSCPDXML(NPT_XmlElementNode* node);
75 const NPT_String& GetName() const { return m_Name; }
76 const NPT_String& GetDirection() const { return m_Direction; }
77 NPT_Ordinal GetPosition() { return m_Position; }
78 PLT_StateVariable* GetRelatedStateVariable() { return m_RelatedStateVariable; }
79 bool HasReturnValue() { return m_HasReturnValue; }
81 protected:
82 NPT_String m_Name;
83 NPT_Ordinal m_Position;
84 NPT_String m_Direction;
85 PLT_StateVariable* m_RelatedStateVariable;
86 bool m_HasReturnValue;
89 /*----------------------------------------------------------------------
90 | PLT_Argument
91 +---------------------------------------------------------------------*/
92 /**
93 The PLT_Argument class provides a mechanism to set or verify the validity of a
94 specific UPNP service action argument.
95 Typically, only a PLT_Action uses this class. Since an argument can be
96 associated to a state variable, the argument is automatically updated when
97 the associated state variable is changed
99 class PLT_Argument
101 public:
102 PLT_Argument(PLT_ArgumentDesc& arg_desc);
104 // class methods
105 static NPT_Result CreateArgument(PLT_ActionDesc& action_desc,
106 const char* arg_name,
107 const char* arg_value,
108 PLT_Argument*& arg);
110 // accessor methods
111 PLT_ArgumentDesc& GetDesc() { return m_ArgDesc; }
112 NPT_Ordinal GetPosition() { return m_ArgDesc.GetPosition(); }
113 NPT_Result SetValue(const char* value);
114 const NPT_String& GetValue();
116 private:
117 NPT_Result ValidateValue(const char* value);
119 protected:
120 PLT_ArgumentDesc& m_ArgDesc;
121 NPT_String m_Value;
124 /*----------------------------------------------------------------------
125 | PLT_ArgumentNameFinder
126 +---------------------------------------------------------------------*/
127 /**
128 The PLT_ArgumentNameFinder class provides a mechanism to find a PLT_Argument given
129 an argument name.
131 class PLT_ArgumentNameFinder
133 public:
134 // methods
135 PLT_ArgumentNameFinder(const char* name) : m_Name(name) {}
137 bool operator()(PLT_Argument* const & argument) const {
138 return argument->GetDesc().GetName().Compare(m_Name, true) ? false : true;
141 private:
142 // members
143 NPT_String m_Name;
146 /*----------------------------------------------------------------------
147 | PLT_ArgumentDescNameFinder
148 +---------------------------------------------------------------------*/
149 /**
150 The PLT_ArgumentDescNameFinder class provides a mechanism to find a PLT_ArgumentDesc given
151 an argument name.
153 class PLT_ArgumentDescNameFinder
155 public:
156 // methods
157 PLT_ArgumentDescNameFinder(const char* name) : m_Name(name) {}
159 bool operator()(PLT_ArgumentDesc* const & arg_desc) const {
160 return arg_desc->GetName().Compare(m_Name, true) ? false : true;
163 private:
164 // members
165 NPT_String m_Name;
168 #endif /* _PLT_ARGUMENT_H_ */