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