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