1 karl 1.35 //%2005////////////////////////////////////////////////////////////////////////
|
2 mike 1.9 //
|
3 karl 1.33 // Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development
4 // Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems.
5 // Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L.P.;
|
6 karl 1.29 // IBM Corp.; EMC Corporation, The Open Group.
|
7 karl 1.33 // Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.;
8 // IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group.
|
9 karl 1.35 // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;
10 // EMC Corporation; VERITAS Software Corporation; The Open Group.
|
11 mike 1.9 //
12 // Permission is hereby granted, free of charge, to any person obtaining a copy
|
13 kumpf 1.19 // of this software and associated documentation files (the "Software"), to
14 // deal in the Software without restriction, including without limitation the
15 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
16 mike 1.9 // sell copies of the Software, and to permit persons to whom the Software is
17 // furnished to do so, subject to the following conditions:
|
18 chip 1.36 //
|
19 kumpf 1.19 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
|
20 mike 1.9 // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
21 // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
22 kumpf 1.19 // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
23 // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
24 // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
25 mike 1.9 // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
26 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27 //
28 //==============================================================================
29 //
30 // Author: Mike Brasher (mbrasher@bmc.com)
31 //
|
32 kumpf 1.20 // Modified By: Carol Ann Krug Graves, Hewlett-Packard Company
|
33 david.dillard 1.34 // (carolann_graves@hp.com)
34 // David Dillard, VERITAS Software Corp.
35 // (david.dillard@veritas.com)
|
36 mike 1.9 //
37 //%/////////////////////////////////////////////////////////////////////////////
38
|
39 sage 1.11 #include <Pegasus/Common/Config.h>
|
40 mike 1.9 #include <cstdio>
41 #include "CIMParameter.h"
|
42 kumpf 1.16 #include "CIMParameterRep.h"
|
43 mike 1.9 #include "Indentor.h"
44 #include "CIMName.h"
45 #include "CIMScope.h"
46 #include "XmlWriter.h"
47
48 PEGASUS_NAMESPACE_BEGIN
49
|
50 chip 1.36 CIMParameterRep::CIMParameterRep()
51 {
52 }
53
54 CIMParameterRep::CIMParameterRep(const CIMParameterRep& x) :
55 Sharable(),
56 _name(x._name),
57 _type(x._type),
58 _isArray(x._isArray),
59 _arraySize(x._arraySize),
60 _referenceClassName(x._referenceClassName)
61 {
62 x._qualifiers.cloneTo(_qualifiers);
63 }
64
|
65 mike 1.9 CIMParameterRep::CIMParameterRep(
|
66 chip 1.36 const CIMName& name,
|
67 mike 1.9 CIMType type,
68 Boolean isArray,
69 Uint32 arraySize,
|
70 chip 1.36 const CIMName& referenceClassName)
71 : _name(name), _type(type),
72 _isArray(isArray), _arraySize(arraySize),
|
73 mike 1.9 _referenceClassName(referenceClassName)
74 {
|
75 chip 1.36 // ensure name is not null
76 if(name.isNull())
77 {
78 throw UninitializedObjectException();
79 }
80
81 if((_arraySize != 0) && !_isArray)
82 {
83 throw TypeMismatchException();
84 }
|
85 mike 1.9
|
86 kumpf 1.21 if (!referenceClassName.isNull())
|
87 mike 1.9 {
|
88 chip 1.36 if (_type != CIMTYPE_REFERENCE)
89 {
90 throw TypeMismatchException();
91 }
|
92 mike 1.9 }
93 else
94 {
|
95 chip 1.36 if (_type == CIMTYPE_REFERENCE)
96 {
97 throw TypeMismatchException();
98 }
|
99 mike 1.9 }
100 }
101
102 CIMParameterRep::~CIMParameterRep()
103 {
104 }
105
|
106 chip 1.36 void CIMParameterRep::setName(const CIMName& name)
|
107 mike 1.9 {
|
108 chip 1.36 // ensure name is not null
109 if(name.isNull())
110 {
111 throw UninitializedObjectException();
112 }
113
114 _name = name;
|
115 mike 1.9 }
116
|
117 kumpf 1.26 void CIMParameterRep::removeQualifier(Uint32 index)
|
118 kumpf 1.23 {
|
119 kumpf 1.26 if (index >= _qualifiers.getCount())
|
120 kumpf 1.24 throw IndexOutOfBoundsException();
|
121 kumpf 1.23
|
122 kumpf 1.26 _qualifiers.removeQualifier (index);
|
123 kumpf 1.23 }
124
|
125 mike 1.9 void CIMParameterRep::resolve(
126 DeclContext* declContext,
|
127 kumpf 1.21 const CIMNamespaceName& nameSpace)
|
128 mike 1.9 {
129 // Validate the qualifiers of the method (according to
130 // superClass's method with the same name). This method
131 // will throw an exception if the validation fails.
132
133 CIMQualifierList dummy;
134
135 _qualifiers.resolve(
136 declContext,
137 nameSpace,
138 CIMScope::PARAMETER,
139 false,
|
140 mike 1.14 dummy,
141 true);
|
142 mike 1.9 }
143
|
144 mike 1.36.2.1 void CIMParameterRep::toXml(Buffer& out) const
|
145 mike 1.9 {
146 if (_isArray)
147 {
|
148 kumpf 1.30 if (_type == CIMTYPE_REFERENCE)
149 {
|
150 mike 1.36.2.2 out << LIT("<PARAMETER.REFARRAY");
151 out << LIT(" NAME=\"") << _name;
152 out.append('"');
|
153 kumpf 1.30
154 if (!_referenceClassName.isNull())
155 {
|
156 mike 1.36.2.2 out << LIT(" REFERENCECLASS=\"");
157 out << _referenceClassName.getString();
158 out.append('"');
|
159 kumpf 1.30 }
160
|
161 mike 1.36.2.2 if (_arraySize)
|
162 h.sterling 1.32 {
163 char buffer[32];
164 sprintf(buffer, "%d", _arraySize);
|
165 mike 1.36.2.2 out << LIT(" ARRAYSIZE=\"") << buffer;
166 out.append('"');
|
167 h.sterling 1.32 }
168
|
169 mike 1.36.2.2 out << LIT(">\n");
|
170 kumpf 1.30
171 _qualifiers.toXml(out);
172
|
173 mike 1.36.2.2 out << LIT("</PARAMETER.REFARRAY>\n");
|
174 kumpf 1.30 }
175 else
176 {
|
177 mike 1.36.2.2 out << LIT("<PARAMETER.ARRAY");
178 out << LIT(" NAME=\"") << _name << LIT("\" ");
179 out << LIT(" TYPE=\"") << cimTypeToString (_type);
180 out.append('"');
|
181 kumpf 1.30
182 if (_arraySize)
183 {
184 char buffer[32];
185 sprintf(buffer, "%d", _arraySize);
|
186 mike 1.36.2.2 out << LIT(" ARRAYSIZE=\"") << buffer;
187 out.append('"');
|
188 kumpf 1.30 }
|
189 mike 1.9
|
190 mike 1.36.2.2 out << LIT(">\n");
|
191 mike 1.9
|
192 kumpf 1.30 _qualifiers.toXml(out);
|
193 mike 1.9
|
194 mike 1.36.2.2 out << LIT("</PARAMETER.ARRAY>\n");
|
195 kumpf 1.30 }
|
196 mike 1.9 }
|
197 kumpf 1.20 else if (_type == CIMTYPE_REFERENCE)
|
198 mike 1.10 {
|
199 mike 1.36.2.2 out << LIT("<PARAMETER.REFERENCE");
200 out << LIT(" NAME=\"") << _name;
201 out.append('"');
202
|
203 kumpf 1.30 if (!_referenceClassName.isNull())
204 {
|
205 mike 1.36.2.2 out << LIT(" REFERENCECLASS=\"");
206 out << _referenceClassName.getString();
207 out.append('"');
|
208 kumpf 1.30 }
|
209 mike 1.36.2.2 out << LIT(">\n");
|
210 mike 1.10
211 _qualifiers.toXml(out);
212
|
213 mike 1.36.2.2 out << LIT("</PARAMETER.REFERENCE>\n");
|
214 mike 1.10 }
|
215 mike 1.9 else
216 {
|
217 mike 1.36.2.2 out << LIT("<PARAMETER");
218 out << LIT(" NAME=\"") << _name << LIT("\" ");
219 out << LIT(" TYPE=\"") << cimTypeToString (_type);
220 out.append('"');
221 out << LIT(">\n");
|
222 mike 1.9
223 _qualifiers.toXml(out);
224
|
225 mike 1.36.2.2 out << LIT("</PARAMETER>\n");
|
226 mike 1.9 }
227 }
|
228 mike 1.10
229 /** toMof - puts the Mof representation of teh Parameter object to
230 the output parameter array
231 The BNF for this conversion is:
232 parameterList = parameter *( "," parameter )
233
234 parameter = [ qualifierList ] (dataType|objectRef) parameterName
235 [ array ]
236
237 parameterName= IDENTIFIER
|
238 chip 1.36
|
239 mike 1.10 array = "[" [positiveDecimalValue] "]"
|
240 chip 1.36
|
241 mike 1.10 Format on a single line.
242 */
|
243 mike 1.36.2.1 void CIMParameterRep::toMof(Buffer& out) const
|
244 mike 1.10 {
245 // Output the qualifiers for the parameter
246 _qualifiers.toMof(out);
247
248 if (_qualifiers.getCount())
|
249 mike 1.36.2.2 out.append(' ');
|
250 mike 1.10
251 // Output the data type and name
|
252 mike 1.36.2.2 out << cimTypeToString (_type);
253 out.append(' ');
254 out << _name;
|
255 mike 1.10
256 if (_isArray)
257 {
258 //Output the array indicator "[ [arraysize] ]"
259 if (_arraySize)
260 {
261 char buffer[32];
262 sprintf(buffer, "[%d]", _arraySize);
263 out << buffer;
264 }
265 else
|
266 mike 1.36.2.2 out << LIT("[]");
|
267 mike 1.10 }
268 }
269
|
270 mike 1.9
271 Boolean CIMParameterRep::identical(const CIMParameterRep* x) const
272 {
|
273 kumpf 1.28 if (!_name.equal (x->_name))
|
274 mike 1.9 return false;
275
276 if (_type != x->_type)
277 return false;
278
|
279 kumpf 1.28 if (!_referenceClassName.equal (x->_referenceClassName))
|
280 mike 1.9 return false;
281
282 if (!_qualifiers.identical(x->_qualifiers))
283 return false;
284
285 return true;
286 }
287
288 PEGASUS_NAMESPACE_END
|