comparison deps/Platinum/Source/Core/PltAction.h @ 0:3425707ddbf6

Initial import (hopefully this mercurial stuff works...)
author fraserofthenight
date Mon, 06 Jul 2009 08:06:28 -0700
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:3425707ddbf6
1 /*****************************************************************
2 |
3 | Platinum - Service Action
4 |
5 | Copyright (c) 2004-2008, 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 |
21 | This program is distributed in the hope that it will be useful,
22 | but WITHOUT ANY WARRANTY; without even the implied warranty of
23 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 | GNU General Public License for more details.
25 |
26 | You should have received a copy of the GNU General Public License
27 | along with this program; see the file LICENSE.txt. If not, write to
28 | the Free Software Foundation, Inc.,
29 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
30 | http://www.gnu.org/licenses/gpl-2.0.html
31 |
32 ****************************************************************/
33
34 #ifndef _PLT_ACTION_H_
35 #define _PLT_ACTION_H_
36
37 /*----------------------------------------------------------------------
38 | includes
39 +---------------------------------------------------------------------*/
40 #include "Neptune.h"
41 #include "PltArgument.h"
42
43 /*----------------------------------------------------------------------
44 | forward declarations
45 +---------------------------------------------------------------------*/
46 class PLT_Service;
47
48 /*----------------------------------------------------------------------
49 | PLT_ActionDesc
50 +---------------------------------------------------------------------*/
51 class PLT_ActionDesc
52 {
53 public:
54 PLT_ActionDesc(const char* name, PLT_Service* service);
55 ~PLT_ActionDesc();
56
57 NPT_Array<PLT_ArgumentDesc*>& GetArgumentDescs() {
58 return m_ArgumentDescs;
59 }
60
61 const NPT_String& GetName() const { return m_Name;}
62 PLT_ArgumentDesc* GetArgumentDesc(const char* name);
63 NPT_Result GetSCPDXML(NPT_XmlElementNode* node);
64 PLT_Service* GetService();
65
66 protected:
67 //members
68 NPT_String m_Name;
69 PLT_Service* m_Service;
70 NPT_Array<PLT_ArgumentDesc*> m_ArgumentDescs;
71 };
72
73 /*----------------------------------------------------------------------
74 | PLT_Action
75 +---------------------------------------------------------------------*/
76 class PLT_Action
77 {
78 public:
79 PLT_Action(PLT_ActionDesc* action_desc);
80 ~PLT_Action();
81
82 PLT_ActionDesc* GetActionDesc() { return m_ActionDesc; }
83
84 NPT_Result GetArgumentValue(const char* name, NPT_String& value);
85 NPT_Result GetArgumentValue(const char* name, NPT_UInt32& value);
86 NPT_Result GetArgumentValue(const char* name, NPT_Int32& value);
87 NPT_Result VerifyArgumentValue(const char* name, const char* value);
88 NPT_Result VerifyArguments(bool input);
89 NPT_Result SetArgumentOutFromStateVariable(const char* name);
90 NPT_Result SetArgumentsOutFromStateVariable();
91 NPT_Result SetArgumentValue(const char* name, const char* value);
92
93 NPT_Result SetError(unsigned int code, const char* description);
94 const char* GetError(unsigned int& code);
95 unsigned int GetErrorCode();
96
97 NPT_Result FormatSoapRequest(NPT_OutputStream& stream);
98 NPT_Result FormatSoapResponse(NPT_OutputStream& stream);
99
100 static NPT_Result FormatSoapError(unsigned int code,
101 NPT_String desc,
102 NPT_OutputStream& stream);
103
104 private:
105 NPT_Result SetArgumentOutFromStateVariable(PLT_ArgumentDesc* arg_desc);
106 PLT_Argument* GetArgument(const char* name);
107
108 protected:
109 // members
110 PLT_ActionDesc* m_ActionDesc;
111 PLT_Arguments m_Arguments;
112 unsigned int m_ErrorCode;
113 NPT_String m_ErrorDescription;
114 };
115
116 typedef NPT_Reference<PLT_Action> PLT_ActionReference;
117
118 /*----------------------------------------------------------------------
119 | PLT_GetSCPDXMLIterator
120 +---------------------------------------------------------------------*/
121 template <class T>
122 class PLT_GetSCPDXMLIterator
123 {
124 public:
125 PLT_GetSCPDXMLIterator<T>(NPT_XmlElementNode* node) :
126 m_Node(node) {}
127
128 NPT_Result operator()(T* const & data) const {
129 return data->GetSCPDXML(m_Node);
130 }
131
132 private:
133 NPT_XmlElementNode* m_Node;
134 };
135
136 /*----------------------------------------------------------------------
137 | PLT_ActionDescNameFinder
138 +---------------------------------------------------------------------*/
139 class PLT_ActionDescNameFinder
140 {
141 public:
142 // methods
143 PLT_ActionDescNameFinder(PLT_Service* service, const char* name) :
144 m_Service(service), m_Name(name) {}
145 virtual ~PLT_ActionDescNameFinder() {}
146
147 bool operator()(const PLT_ActionDesc* const & action_desc) const {
148 return action_desc->GetName().Compare(m_Name, true) ? false : true;
149 }
150
151 private:
152 // members
153 PLT_Service* m_Service;
154 NPT_String m_Name;
155 };
156
157 #endif /* _PLT_ACTION_H_ */