1 karl 1.52 //%2006////////////////////////////////////////////////////////////////////////
|
2 mike 1.13 //
|
3 karl 1.44 // 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.40 // IBM Corp.; EMC Corporation, The Open Group.
|
7 karl 1.44 // 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.46 // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;
10 // EMC Corporation; VERITAS Software Corporation; The Open Group.
|
11 karl 1.52 // Copyright (c) 2006 Hewlett-Packard Development Company, L.P.; IBM Corp.;
12 // EMC Corporation; Symantec Corporation; The Open Group.
|
13 mike 1.13 //
14 // Permission is hereby granted, free of charge, to any person obtaining a copy
|
15 kumpf 1.26 // of this software and associated documentation files (the "Software"), to
16 // deal in the Software without restriction, including without limitation the
17 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
18 mike 1.13 // sell copies of the Software, and to permit persons to whom the Software is
19 // furnished to do so, subject to the following conditions:
|
20 karl 1.52 //
|
21 kumpf 1.26 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
|
22 mike 1.13 // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
23 // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
24 kumpf 1.26 // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
25 // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
26 // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
27 mike 1.13 // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
28 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29 //
30 //==============================================================================
31 //
32 //%/////////////////////////////////////////////////////////////////////////////
33
34 #include <cstdio>
|
35 kumpf 1.19 #include "CIMPropertyRep.h"
|
36 mike 1.13 #include "Indentor.h"
37 #include "CIMName.h"
38 #include "CIMScope.h"
|
39 kumpf 1.25 #include "XmlWriter.h"
40 #include "MofWriter.h"
|
41 a.dunfey 1.42 #include "DeclContext.h"
|
42 mike 1.51 #include "StrLit.h"
|
43 mike 1.13
|
44 mike 1.17 PEGASUS_USING_STD;
45
|
46 mike 1.13 PEGASUS_NAMESPACE_BEGIN
47
|
48 chip 1.48 CIMPropertyRep::CIMPropertyRep(
49 const CIMPropertyRep& x,
50 Boolean propagateQualifiers)
51 :
52 Sharable(),
53 _name(x._name),
54 _value(x._value),
55 _arraySize(x._arraySize),
56 _referenceClassName(x._referenceClassName),
57 _classOrigin(x._classOrigin),
|
58 marek 1.60 _propagated(x._propagated),
59 _ownerCount(0)
|
60 chip 1.48 {
|
61 marek 1.60 // Set the CIM name tag.
62 _nameTag = generateCIMNameTag(_name);
63
|
64 chip 1.48 if (propagateQualifiers)
|
65 kumpf 1.56 x._qualifiers.cloneTo(_qualifiers);
|
66 chip 1.48 }
67
|
68 mike 1.13 CIMPropertyRep::CIMPropertyRep(
|
69 kumpf 1.30 const CIMName& name,
|
70 mike 1.13 const CIMValue& value,
71 Uint32 arraySize,
|
72 kumpf 1.30 const CIMName& referenceClassName,
73 const CIMName& classOrigin,
|
74 chip 1.48 Boolean propagated)
|
75 mike 1.17 :
|
76 mike 1.13 _name(name), _value(value), _arraySize(arraySize),
77 _referenceClassName(referenceClassName), _classOrigin(classOrigin),
|
78 marek 1.60 _propagated(propagated), _ownerCount(0)
|
79 mike 1.13 {
|
80 chip 1.48 // ensure name is not null
|
81 kumpf 1.57 if (name.isNull())
|
82 chip 1.48 {
83 throw UninitializedObjectException();
84 }
85
|
86 marek 1.60 // Set the CIM name tag.
87 _nameTag = generateCIMNameTag(_name);
88
|
89 kumpf 1.56 if ((arraySize != 0) &&
90 (!value.isArray() || value.getArraySize() != arraySize))
|
91 chip 1.48 {
|
92 kumpf 1.38 throw TypeMismatchException();
|
93 chip 1.48 }
|
94 mike 1.13
|
95 kumpf 1.49 // A CIM Property may not be of reference array type
96 if (value.isArray() && (value.getType() == CIMTYPE_REFERENCE))
97 {
98 throw TypeMismatchException();
99 }
100
|
101 chip 1.48 // if referenceClassName exists, must be CIMType REFERENCE.
|
102 kumpf 1.30 if (!referenceClassName.isNull())
|
103 mike 1.13 {
|
104 kumpf 1.30 if (_value.getType() != CIMTYPE_REFERENCE)
|
105 chip 1.48 {
|
106 kumpf 1.38 throw TypeMismatchException();
|
107 chip 1.48 }
|
108 kumpf 1.30 }
|
109 kumpf 1.41
110 // Can a property be of reference type with a null referenceClassName?
111 // The DMTF says yes if it is a property of an instance; no if it is a
112 // property of a class. We'll allow it here, but check in the CIMClass
113 // addProperty() method.
|
114 mike 1.13 }
115
116 CIMPropertyRep::~CIMPropertyRep()
117 {
118 }
119
|
120 kumpf 1.30 void CIMPropertyRep::setName(const CIMName& name)
|
121 mike 1.13 {
|
122 chip 1.48 // ensure name is not null
|
123 kumpf 1.57 if (name.isNull())
|
124 chip 1.48 {
125 throw UninitializedObjectException();
126 }
127
|
128 marek 1.60 if (_ownerCount != 0 && _name != name)
129 {
130 MessageLoaderParms parms(
131 "Common.CIMPropertyRep.CONTAINED_PROPERTY_NAMECHANGEDEXCEPTION",
132 "Attempted to change the name of a property"
133 " already in a container.");
134 throw Exception(parms);
135 }
136
|
137 mike 1.13 _name = name;
|
138 marek 1.60
139 // Set the CIM name tag.
140 _nameTag = generateCIMNameTag(_name);
|
141 mike 1.13 }
142
|
143 kumpf 1.30 void CIMPropertyRep::setClassOrigin(const CIMName& classOrigin)
|
144 mike 1.13 {
145 _classOrigin = classOrigin;
146 }
147
148 void CIMPropertyRep::resolve(
149 DeclContext* declContext,
|
150 kumpf 1.30 const CIMNamespaceName& nameSpace,
|
151 mike 1.13 Boolean isInstancePart,
|
152 mike 1.17 const CIMConstProperty& inheritedProperty,
153 Boolean propagateQualifiers)
|
154 mike 1.13 {
|
155 kumpf 1.32 PEGASUS_ASSERT(!inheritedProperty.isUninitialized());
|
156 mike 1.13
157 // Check the type:
158
159 if (!inheritedProperty.getValue().typeCompatible(_value))
|
160 dave.sudlik 1.47 {
161 if (!(
162 (inheritedProperty.getValue().getType() == CIMTYPE_OBJECT) &&
163 (_value.getType() == CIMTYPE_STRING) &&
164 (_qualifiers.find(CIMName("EmbeddedObject")) != PEG_NOT_FOUND) &&
165 (inheritedProperty.getValue().isArray() == _value.isArray())
|
166 a.dunfey 1.53 #ifdef PEGASUS_EMBEDDED_INSTANCE_SUPPORT
167 ) &&
168 !(
169 (inheritedProperty.getValue().getType() == CIMTYPE_INSTANCE) &&
170 (_value.getType() == CIMTYPE_STRING) &&
171 (_qualifiers.find(CIMName("EmbeddedInstance")) != PEG_NOT_FOUND) &&
172 (inheritedProperty.getValue().isArray() == _value.isArray())
173 #endif // PEGASUS_EMBEDDED_INSTANCE_SUPPORT
|
174 dave.sudlik 1.47 ))
175 {
176 throw TypeMismatchException();
177 }
178 }
|
179 mike 1.13
180 // Validate the qualifiers of the property (according to
181 // superClass's property with the same name). This method
182 // will throw an exception if the validation fails.
183
|
184 kumpf 1.35 CIMScope scope = CIMScope::PROPERTY;
|
185 mike 1.13
|
186 kumpf 1.29 if (_value.getType() == CIMTYPE_REFERENCE)
|
187 a.dunfey 1.53 scope = CIMScope::REFERENCE;
|
188 mike 1.13
|
189 a.dunfey 1.42 // Test the reference class name against the inherited property
|
190 a.dunfey 1.53 #ifdef PEGASUS_EMBEDDED_INSTANCE_SUPPORT
|
191 dmitry.mikulin 1.61 if (_value.getType() == CIMTYPE_REFERENCE ||
192 _value.getType() == CIMTYPE_INSTANCE)
193 #else // !PEGASUS_EMBEDDED_INSTANCE_SUPPORT
194 if (_value.getType() == CIMTYPE_REFERENCE)
195 #endif // end PEGASUS_EMBEDDED_INSTANCE_SUPPORT
|
196 a.dunfey 1.53 {
197 CIMName inheritedClassName;
198 Array<CIMName> classNames;
|
199 a.dunfey 1.55
|
200 dmitry.mikulin 1.61 #ifdef PEGASUS_EMBEDDED_INSTANCE_SUPPORT
201 if (_value.getType() == CIMTYPE_INSTANCE)
|
202 a.dunfey 1.43 {
|
203 a.dunfey 1.53 Uint32 pos = inheritedProperty.findQualifier("EmbeddedInstance");
|
204 kumpf 1.57 if (pos != PEG_NOT_FOUND)
|
205 a.dunfey 1.43 {
|
206 a.dunfey 1.53 String qualStr;
207 inheritedProperty.getQualifier(pos).getValue().get(qualStr);
208 inheritedClassName = qualStr;
209 }
210
|
211 kumpf 1.57 if (_value.isArray())
|
212 a.dunfey 1.53 {
213 Array<CIMInstance> embeddedInstances;
214 _value.get(embeddedInstances);
|
215 kumpf 1.57 for (Uint32 i = 0, n = embeddedInstances.size(); i < n; ++i)
|
216 a.dunfey 1.43 {
|
217 a.dunfey 1.53 classNames.append(embeddedInstances[i].getClassName());
|
218 a.dunfey 1.43 }
|
219 a.dunfey 1.53 }
220 else
221 {
222 CIMInstance embeddedInst;
223 _value.get(embeddedInst);
224 classNames.append(embeddedInst.getClassName());
|
225 a.dunfey 1.43 }
226 }
|
227 a.dunfey 1.53 else
|
228 dmitry.mikulin 1.61 #endif // end PEGASUS_EMBEDDED_INSTANCE_SUPPORT
|
229 a.dunfey 1.43 {
|
230 a.dunfey 1.55 CIMName referenceClass;
231 if (_referenceClassName.isNull())
232 {
|
233 kumpf 1.56 CIMObjectPath reference;
|
234 a.dunfey 1.55 _value.get(reference);
235 referenceClass = reference.getClassName();
236 }
237 else
238 {
239 referenceClass = _referenceClassName;
240 }
241
242 inheritedClassName = inheritedProperty.getReferenceClassName();
243 classNames.append(referenceClass);
|
244 a.dunfey 1.43 }
|
245 a.dunfey 1.42
|
246 a.dunfey 1.53 // This algorithm is friendly to arrays of embedded instances. It
247 // remembers the class names that are found to be subclasses of the
248 // inherited class name retrieved from the inherited property. This
249 // ensures that any branch in the inheritance hierarchy will only be
250 // traversed once. This provides significant optimization given that
251 // most elements of an array of embedded instances will probably be of
252 // very closely related types.
253 Array<CIMName> successTree;
254 successTree.append(inheritedClassName);
|
255 kumpf 1.57 for (Uint32 i = 0, n = classNames.size(); i < n; ++i)
|
256 a.dunfey 1.43 {
|
257 a.dunfey 1.53 Array<CIMName> traversalHistory;
258 CIMName currentName = classNames[i];
259 Boolean found = false;
|
260 kumpf 1.57 while (!found && !currentName.isNull())
|
261 a.dunfey 1.43 {
|
262 kumpf 1.57 for (Uint32 j = 0, m = successTree.size(); j < m; ++j)
|
263 a.dunfey 1.43 {
|
264 kumpf 1.57 if (currentName == successTree[j])
|
265 a.dunfey 1.53 {
266 found = true;
267 break;
268 }
|
269 a.dunfey 1.43 }
270
|
271 kumpf 1.57 if (!found)
|
272 a.dunfey 1.53 {
273 traversalHistory.append(currentName);
274 CIMClass currentClass = declContext->lookupClass(
275 nameSpace, currentName);
|
276 kumpf 1.57 if (currentClass.isUninitialized())
|
277 a.dunfey 1.53 {
278 throw PEGASUS_CIM_EXCEPTION(
279 CIM_ERR_NOT_FOUND, currentName.getString());
280 }
281 currentName = currentClass.getSuperClassName();
282 }
|
283 a.dunfey 1.43 }
|
284 a.dunfey 1.53
|
285 kumpf 1.57 if (!found)
|
286 a.dunfey 1.53 {
287 throw TypeMismatchException();
288 }
289
290 successTree.appendArray(traversalHistory);
|
291 a.dunfey 1.43 }
|
292 kumpf 1.41 }
293
|
294 mike 1.13 _qualifiers.resolve(
|
295 a.dunfey 1.53 declContext, nameSpace, scope, isInstancePart,
296 inheritedProperty._rep->_qualifiers, propagateQualifiers);
|
297 mike 1.13
298 _classOrigin = inheritedProperty.getClassOrigin();
299 }
300
301 void CIMPropertyRep::resolve(
302 DeclContext* declContext,
|
303 kumpf 1.30 const CIMNamespaceName& nameSpace,
|
304 mike 1.17 Boolean isInstancePart,
|
305 kumpf 1.28 Boolean propagateQualifiers)
|
306 mike 1.13 {
307 CIMQualifierList dummy;
308
|
309 kumpf 1.35 CIMScope scope = CIMScope::PROPERTY;
|
310 mike 1.13
|
311 kumpf 1.29 if (_value.getType() == CIMTYPE_REFERENCE)
|
312 a.dunfey 1.53 scope = CIMScope::REFERENCE;
|
313 mike 1.13
314 _qualifiers.resolve(
|
315 a.dunfey 1.53 declContext,
316 nameSpace,
317 scope,
318 isInstancePart,
319 dummy,
320 propagateQualifiers);
|
321 mike 1.13 }
322
323 static const char* _toString(Boolean x)
324 {
325 return x ? "true" : "false";
326 }
327
|
328 mike 1.50 void CIMPropertyRep::toXml(Buffer& out) const
|
329 mike 1.13 {
330 if (_value.isArray())
331 {
|
332 kumpf 1.56 out << STRLIT("<PROPERTY.ARRAY NAME=\"") << _name << STRLIT("\" ");
|
333 mike 1.13
|
334 kumpf 1.56 if (_value.getType() == CIMTYPE_OBJECT)
335 {
336 // If the property array type is CIMObject, then
337 // encode the property in CIM-XML as a string array with the
338 // EMBEDDEDOBJECT attribute (there is not currently a CIM-XML
339 // "object" datatype)
340
341 Array<CIMObject> a;
342 _value.get(a);
343 out << STRLIT(" TYPE=\"string\"");
344 // If the Embedded Object is an instance, always add the
345 // EMBEDDEDOBJECT attribute.
346 if (a.size() > 0 && a[0].isInstance())
347 out << STRLIT(" EMBEDDEDOBJECT=\"object\"");
|
348 dave.sudlik 1.47 #ifndef PEGASUS_SNIA_INTEROP_COMPATIBILITY
|
349 kumpf 1.56 else
350 {
|
351 dave.sudlik 1.47 #endif
|
352 kumpf 1.56 // Else the Embedded Object is a class, always add the
353 // EmbeddedObject qualifier. Note that if the macro
354 // PEGASUS_SNIA_INTEROP_COMPATIBILITY is defined, then
355 // the EmbeddedObject qualifier will always be added,
356 // whether it's a class or an instance.
357 if (_qualifiers.find(CIMName("EmbeddedObject")) ==
358 PEG_NOT_FOUND)
359 {
360 // Note that _qualifiers is not defined as const, and
361 // neither is add(), but this method toXml() *is* const.
362 // However, in this case we really do want to add the
363 // EmbeddedObject qualifier, so we cast away the implied
364 // const-ness of _qualifiers.
365 CIMQualifierList * tmpQualifiers =
366 const_cast<CIMQualifierList *>(&_qualifiers);
367 tmpQualifiers->add(
368 CIMQualifier(CIMName("EmbeddedObject"), true));
369 }
370 #ifndef PEGASUS_SNIA_INTEROP_COMPATIBILITY
|
371 dave.sudlik 1.47 }
|
372 kumpf 1.56 #endif
|
373 dave.sudlik 1.47 }
|
374 a.dunfey 1.53 #ifdef PEGASUS_EMBEDDED_INSTANCE_SUPPORT
|
375 kumpf 1.57 else if (_value.getType() == CIMTYPE_INSTANCE)
|
376 kumpf 1.56 {
377 // If the property array type is CIMInstance, then
378 // encode the property in CIM-XML as a string array with the
379 // EMBEDDEDOBJECT attribute (there is not currently a CIM-XML
380 // "instance" datatype)
381
382 Array<CIMInstance> a;
383 _value.get(a);
384 out << " TYPE=\"string\"";
385
386 // add the EMBEDDEDOBJECT attribute
387 if (a.size() > 0)
388 {
389 out << " EMBEDDEDOBJECT=\"instance\"";
390
391 // Note that if the macro PEGASUS_SNIA_INTEROP_COMPATIBILITY is
392 // defined, then the EmbeddedInstance qualifier will be added
|
393 a.dunfey 1.53 #ifdef PEGASUS_SNIA_INTEROP_COMPATIBILITY
|
394 kumpf 1.56 if (_qualifiers.find(CIMName("EmbeddedInstance")) ==
395 PEG_NOT_FOUND)
396 {
397 // Note that _qualifiers is not defined as const, and
398 // neither is add(), but this method toXml() *is* const.
399 // However, in this case we really do want to add the
400 // EmbeddedObject qualifier, so we cast away the implied
401 // const-ness of _qualifiers.
402
403 // For now, we assume that all the embedded instances in
404 // the array are of the same type
405 CIMQualifierList * tmpQualifiers =
406 const_cast<CIMQualifierList *>(&_qualifiers);
407 tmpQualifiers->add(CIMQualifier(
408 CIMName("EmbeddedInstance"),
409 a[0].getClassName().getString()));
410 }
411 #endif
412 }
413 }
414 #endif // PEGASUS_EMBEDDED_INSTANCE_SUPPORT
415 kumpf 1.56 else
|
416 a.dunfey 1.53 {
|
417 kumpf 1.56 out << STRLIT(" TYPE=\"") << cimTypeToString(_value.getType ());
418 out.append('"');
|
419 a.dunfey 1.53 }
|
420 mike 1.13
|
421 kumpf 1.56 if (_arraySize)
422 {
423 char buffer[32];
424 sprintf(buffer, "%d", _arraySize);
425 out << STRLIT(" ARRAYSIZE=\"") << buffer;
426 out.append('"');
427 }
|
428 mike 1.13
|
429 kumpf 1.56 if (!_classOrigin.isNull())
430 {
431 out << STRLIT(" CLASSORIGIN=\"") << _classOrigin;
432 out.append('"');
433 }
|
434 mike 1.13
|
435 kumpf 1.56 if (_propagated != false)
436 {
437 out << STRLIT(" PROPAGATED=\"") << _toString(_propagated);
438 out.append('"');
439 }
|
440 mike 1.13
|
441 kumpf 1.56 out << STRLIT(">\n");
|
442 mike 1.13
|
443 kumpf 1.56 _qualifiers.toXml(out);
|
444 mike 1.13
|
445 kumpf 1.56 XmlWriter::appendValueElement(out, _value);
|
446 mike 1.13
|
447 kumpf 1.56 out << STRLIT("</PROPERTY.ARRAY>\n");
|
448 mike 1.13 }
|
449 kumpf 1.29 else if (_value.getType() == CIMTYPE_REFERENCE)
|
450 mike 1.13 {
|
451 kumpf 1.56 out << STRLIT("<PROPERTY.REFERENCE");
|
452 mike 1.13
|
453 kumpf 1.56 out << STRLIT(" NAME=\"") << _name << STRLIT("\" ");
|
454 mike 1.13
|
455 kumpf 1.41 if (!_referenceClassName.isNull())
456 {
|
457 mike 1.51 out << STRLIT(" REFERENCECLASS=\"") << _referenceClassName;
|
458 kumpf 1.56 out.append('"');
|
459 kumpf 1.41 }
|
460 mike 1.13
|
461 kumpf 1.56 if (!_classOrigin.isNull())
462 {
463 out << STRLIT(" CLASSORIGIN=\"") << _classOrigin;
464 out.append('"');
465 }
|
466 mike 1.13
|
467 kumpf 1.56 if (_propagated != false)
468 {
469 out << STRLIT(" PROPAGATED=\"") << _toString(_propagated);
470 out.append('"');
471 }
|
472 mike 1.13
|
473 kumpf 1.56 out << STRLIT(">\n");
|
474 mike 1.13
|
475 kumpf 1.56 _qualifiers.toXml(out);
|
476 chip 1.48
|
477 kumpf 1.56 XmlWriter::appendValueElement(out, _value);
|
478 mike 1.13
|
479 kumpf 1.56 out << STRLIT("</PROPERTY.REFERENCE>\n");
|
480 mike 1.13 }
481 else
482 {
|
483 kumpf 1.56 out << STRLIT("<PROPERTY NAME=\"") << _name << STRLIT("\" ");
484
485 if (!_classOrigin.isNull())
486 {
487 out << STRLIT(" CLASSORIGIN=\"") << _classOrigin;
488 out.append('"');
489 }
|
490 mike 1.13
|
491 kumpf 1.56 if (_propagated != false)
492 {
493 out << STRLIT(" PROPAGATED=\"") << _toString(_propagated);
494 out.append('"');
495 }
496
497 if (_value.getType() == CIMTYPE_OBJECT)
498 {
499 // If the property type is CIMObject, then
500 // encode the property in CIM-XML as a string with the
501 // EMBEDDEDOBJECT attribute (there is not currently a CIM-XML
502 // "object" datatype)
503
504 CIMObject a;
505 _value.get(a);
506 out << STRLIT(" TYPE=\"string\"");
507
508 // If the Embedded Object is an instance, always add the
509 // EMBEDDEDOBJECT attribute.
510 if (a.isInstance())
511 out << STRLIT(" EMBEDDEDOBJECT=\"object\"");
512 kumpf 1.56 // Else the Embedded Object is a class, always add the
513 // EmbeddedObject qualifier.
514 #ifndef PEGASUS_SNIA_INTEROP_COMPATIBILITY
515 else
516 {
517 #endif
518 // Note that if the macro PEGASUS_SNIA_INTEROP_COMPATIBILITY
519 // is defined, then the EmbeddedObject qualifier will always
520 // be added, whether it's a class or an instance.
521 if (_qualifiers.find(CIMName("EmbeddedObject")) ==
522 PEG_NOT_FOUND)
523 {
524 // Note that _qualifiers is not defined as const, and
525 // neither is add(), but this method toXml() *is* const.
526 // However, in this case we really do want to add the
527 // EmbeddedObject qualifier, so we cast away the implied
528 // const-ness of _qualifiers.
529 CIMQualifierList * tmpQualifiers =
530 const_cast<CIMQualifierList *>(&_qualifiers);
531 tmpQualifiers->add(
532 CIMQualifier(CIMName("EmbeddedObject"), true));
533 kumpf 1.56 }
|
534 dave.sudlik 1.47 #ifndef PEGASUS_SNIA_INTEROP_COMPATIBILITY
|
535 kumpf 1.56 }
536 #endif
537 }
538 #ifdef PEGASUS_EMBEDDED_INSTANCE_SUPPORT
539 else if (_value.getType() == CIMTYPE_INSTANCE)
|
540 dave.sudlik 1.47 {
|
541 kumpf 1.56 CIMInstance a;
542 _value.get(a);
543 out << " TYPE=\"string\"";
544 out << " EMBEDDEDOBJECT=\"instance\"";
545
546 #ifdef PEGASUS_SNIA_INTEROP_COMPATIBILITY
|
547 dave.sudlik 1.47 if (_qualifiers.find(CIMName("EmbeddedObject")) == PEG_NOT_FOUND)
548 {
|
549 kumpf 1.56 // Note that _qualifiers is not defined as const, and neither
550 // is add(), but this method toXml() *is* const. However, in
551 // this case we really do want to add the EmbeddedObject
552 // qualifier, so we cast away the implied const-ness of
553 // _qualifiers.
|
554 a.dunfey 1.53 CIMQualifierList * tmpQualifiers =
555 const_cast<CIMQualifierList *>(&_qualifiers);
556 tmpQualifiers->add(
|
557 kumpf 1.56 CIMQualifier(CIMName("EmbeddedInstance"),
558 a.getClassName.getString()));
|
559 dave.sudlik 1.47 }
|
560 kumpf 1.56 #endif
|
561 dave.sudlik 1.47 }
|
562 a.dunfey 1.53 #endif // PEGASUS_EMBEDDED_INSTANCE_SUPPORT
|
563 kumpf 1.56 else
564 {
565 out << STRLIT(" TYPE=\"") << cimTypeToString(_value.getType());
566 out.append('"');
567 }
|
568 mike 1.13
|
569 kumpf 1.56 out << STRLIT(">\n");
|
570 mike 1.13
|
571 kumpf 1.56 _qualifiers.toXml(out);
|
572 chip 1.48
|
573 kumpf 1.56 XmlWriter::appendValueElement(out, _value);
|
574 mike 1.13
|
575 kumpf 1.56 out << STRLIT("</PROPERTY>\n");
|
576 mike 1.13 }
577 }
578
|
579 mike 1.14 /** toMof - returns the MOF for the CIM Property Object in the parameter.
|
580 kumpf 1.56 The MOF for property declaration in a class and value presentation in
|
581 karl 1.54 an instance are different.
|
582 kumpf 1.56
|
583 karl 1.54 The BNF for the property Declaration MOF is:
|
584 mike 1.14 <pre>
|
585 kumpf 1.56 propertyDeclaration = [ qualifierList ] dataType propertyName
586 [ array ] [ defaultValue ] ";"
|
587 chip 1.48
|
588 kumpf 1.56 array = "[" [positiveDecimalValue] "]"
|
589 chip 1.48
|
590 kumpf 1.56 defaultValue = "=" initializer
|
591 mike 1.14 </pre>
592 Format with qualifiers on one line and declaration on another. Start
593 with newline but none at the end.
|
594 kumpf 1.56
|
595 karl 1.54 Note that instances have a different format that propertyDeclarations:
596 instanceDeclaration = [ qualifiersList ] INSTANCE OF className | alias
597 "["valueInitializer "]" ";"
598 valueInitializer = [ qualifierList ] [ propertyName | referenceName ] "="
599 initializer ";"
|
600 mike 1.14 */
|
601 karl 1.54 void CIMPropertyRep::toMof(Boolean isDeclaration, Buffer& out) const
|
602 mike 1.14 {
603 //Output the qualifier list
604 if (_qualifiers.getCount())
|
605 kumpf 1.56 out.append('\n');
|
606 mike 1.14 _qualifiers.toMof(out);
607
608 // Output the Type and name on a new line
|
609 kumpf 1.56 out << '\n';
|
610 karl 1.54 if (isDeclaration)
611 {
612 out << cimTypeToString(_value.getType ());
613 out.append(' ');
614 }
|
615 mike 1.51 out << _name;
|
616 mike 1.14
617 // If array put the Array indicator "[]" and possible size after name.
|
618 karl 1.54 if (isDeclaration)
|
619 mike 1.14 {
|
620 karl 1.54 if (_value.isArray())
621 {
622 if (_arraySize)
623 {
624 char buffer[32];
625 int n = sprintf(buffer, "[%d]", _arraySize);
626 out.append(buffer, n);
627 }
628 else
629 out << STRLIT("[]");
630 }
|
631 mike 1.14 }
632
633 // If the property value is not Null, add value after "="
634 if (!_value.isNull())
635 {
|
636 kumpf 1.56 out << STRLIT(" = ");
637 if (_value.isArray())
638 {
639 // Insert any property values
640 MofWriter::appendValueElement(out, _value);
641 }
642 else if (_value.getType() == CIMTYPE_REFERENCE)
643 {
644 MofWriter::appendValueElement(out, _value);
645 }
646 else
647 {
648 MofWriter::appendValueElement(out, _value);
649 }
|
650 mike 1.14 }
|
651 karl 1.54 else if (!isDeclaration)
652 out << STRLIT(" = NULL");
653
|
654 mike 1.14 // Close the property MOF
|
655 mike 1.51 out.append(';');
|
656 mike 1.14
657 }
658
|
659 mike 1.13 Boolean CIMPropertyRep::identical(const CIMPropertyRep* x) const
660 {
|
661 kumpf 1.58 // If the pointers are the same, the objects must be identical
662 if (this == x)
663 {
664 return true;
665 }
666
|
667 kumpf 1.39 if (!_name.equal (x->_name))
|
668 kumpf 1.56 return false;
|
669 mike 1.13
670 if (_value != x->_value)
|
671 kumpf 1.56 return false;
|
672 mike 1.13
|
673 kumpf 1.39 if (!_referenceClassName.equal (x->_referenceClassName))
|
674 kumpf 1.56 return false;
|
675 mike 1.13
676 if (!_qualifiers.identical(x->_qualifiers))
|
677 kumpf 1.56 return false;
|
678 mike 1.13
|
679 kumpf 1.39 if (!_classOrigin.equal (x->_classOrigin))
|
680 kumpf 1.56 return false;
|
681 mike 1.13
682 if (_propagated != x->_propagated)
|
683 kumpf 1.56 return false;
|
684 mike 1.13
685 return true;
686 }
687
688 void CIMPropertyRep::setValue(const CIMValue& value)
689 {
690 // CIMType of value is immutable:
691
692 if (!value.typeCompatible(_value))
|
693 kumpf 1.56 throw TypeMismatchException();
|
694 mike 1.13
695 if (_arraySize && _arraySize != value.getArraySize())
|
696 kumpf 1.56 throw TypeMismatchException();
|
697 mike 1.13
|
698 kumpf 1.49 // A CIM Property may not be of reference array type
699 if (value.isArray() && (value.getType() == CIMTYPE_REFERENCE))
700 {
701 throw TypeMismatchException();
702 }
703
|
704 mike 1.13 _value = value;
705 }
706
707 PEGASUS_NAMESPACE_END
|