1 karl 1.72 //%2006////////////////////////////////////////////////////////////////////////
|
2 mike 1.18 //
|
3 karl 1.64 // 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.58 // IBM Corp.; EMC Corporation, The Open Group.
|
7 karl 1.64 // 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.67 // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;
10 // EMC Corporation; VERITAS Software Corporation; The Open Group.
|
11 karl 1.72 // Copyright (c) 2006 Hewlett-Packard Development Company, L.P.; IBM Corp.;
12 // EMC Corporation; Symantec Corporation; The Open Group.
|
13 mike 1.18 //
14 // Permission is hereby granted, free of charge, to any person obtaining a copy
|
15 chip 1.21 // 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.18 // 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 r.kieninger 1.74 //
|
21 chip 1.21 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
|
22 mike 1.18 // 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 chip 1.21 // 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.18 // 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 kumpf 1.34 #include "CIMClassRep.h"
|
35 mike 1.18 #include "DeclContext.h"
|
36 kumpf 1.47 #include "Resolver.h"
|
37 mike 1.18 #include "Indentor.h"
38 #include "CIMName.h"
39 #include "CIMQualifierNames.h"
|
40 kumpf 1.37 #include "CIMScope.h"
|
41 mike 1.18 #include "XmlWriter.h"
|
42 kumpf 1.42 #include "MofWriter.h"
|
43 karl 1.30 #include <Pegasus/Common/Tracer.h>
|
44 kumpf 1.76 #include <Pegasus/Common/MessageLoader.h>
|
45 r.kieninger 1.71 #include "CIMNameUnchecked.h"
|
46 mike 1.70 #include "StrLit.h"
|
47 r.kieninger 1.74 #include "CIMInstanceRep.h"
|
48 mike 1.18
49 PEGASUS_NAMESPACE_BEGIN
|
50 karl 1.29 PEGASUS_USING_STD;
|
51 mike 1.18
52 CIMClassRep::CIMClassRep(
|
53 kumpf 1.49 const CIMName& className,
54 const CIMName& superClassName)
|
55 mike 1.20 :
|
56 kumpf 1.49 CIMObjectRep(CIMObjectPath(String(), CIMNamespaceName(), className)),
|
57 mike 1.20 _superClassName(superClassName)
|
58 mike 1.18 {
59 }
60
61 CIMClassRep::~CIMClassRep()
62 {
63 }
64
65 Boolean CIMClassRep::isAssociation() const
66 {
|
67 kumpf 1.55 Uint32 index = findQualifier(CIMQualifierNames::ASSOCIATION);
|
68 mike 1.18
|
69 kumpf 1.55 if (index == PEG_NOT_FOUND)
|
70 kumpf 1.75 return false;
|
71 mike 1.18
72 Boolean flag;
73
|
74 kumpf 1.55 const CIMValue& value = getQualifier(index).getValue();
|
75 mike 1.18
|
76 kumpf 1.48 if (value.getType() != CIMTYPE_BOOLEAN)
|
77 kumpf 1.75 return false;
|
78 mike 1.18
79 value.get(flag);
80 return flag;
81 }
82
83 Boolean CIMClassRep::isAbstract() const
84 {
|
85 kumpf 1.55 Uint32 index = findQualifier(CIMQualifierNames::ABSTRACT);
|
86 mike 1.18
|
87 kumpf 1.55 if (index == PEG_NOT_FOUND)
|
88 kumpf 1.75 return false;
|
89 mike 1.18
90 Boolean flag;
|
91 kumpf 1.55 const CIMValue& value = getQualifier(index).getValue();
|
92 mike 1.18
|
93 kumpf 1.48 if (value.getType() != CIMTYPE_BOOLEAN)
|
94 kumpf 1.75 return false;
|
95 mike 1.18
96 value.get(flag);
97 return flag;
98 }
|
99 kumpf 1.49 void CIMClassRep::setSuperClassName(const CIMName& superClassName)
|
100 mike 1.18 {
101 _superClassName = superClassName;
102 }
103
104 void CIMClassRep::addProperty(const CIMProperty& x)
105 {
|
106 kumpf 1.50 if (x.isUninitialized())
|
107 kumpf 1.75 throw UninitializedObjectException();
|
108 mike 1.18
109 // Reject addition of duplicate property name:
110
|
111 kumpf 1.75 if (findProperty(x.getName()) != PEG_NOT_FOUND)
112 {
113 MessageLoaderParms parms(
114 "Common.CIMClassRep.PROPERTY",
115 "property \"$0\"",
116 x.getName().getString());
|
117 humberto 1.57 throw AlreadyExistsException(parms);
118 }
|
119 mike 1.18
|
120 kumpf 1.59 // Reject addition of a reference property without a referenceClassName
121
122 if ((x.getType() == CIMTYPE_REFERENCE) &&
123 (x.getReferenceClassName().isNull()))
124 {
125 throw TypeMismatchException();
126 }
127
|
128 mike 1.18 // Add the property:
129
130 _properties.append(x);
131 }
132
133 void CIMClassRep::addMethod(const CIMMethod& x)
134 {
|
135 kumpf 1.50 if (x.isUninitialized())
|
136 kumpf 1.75 throw UninitializedObjectException();
|
137 mike 1.18
138 // Reject duplicate method names:
139
|
140 kumpf 1.75 if (findMethod(x.getName()) != PEG_NOT_FOUND)
141 {
142 MessageLoaderParms parms(
143 "Common.CIMClassRep.METHOD",
144 "method \"$0\"",
145 x.getName().getString());
|
146 humberto 1.57 throw AlreadyExistsException(parms);
147 }
|
148 mike 1.18
149 // Add the method:
150
151 _methods.append(x);
152 }
153
|
154 kumpf 1.49 Uint32 CIMClassRep::findMethod(const CIMName& name) const
|
155 mike 1.18 {
156 for (Uint32 i = 0, n = _methods.size(); i < n; i++)
157 {
|
158 kumpf 1.75 if (name.equal(_methods[i].getName()))
159 return i;
|
160 mike 1.18 }
161
162 return PEG_NOT_FOUND;
163 }
|
164 mike 1.20
|
165 kumpf 1.55 CIMMethod CIMClassRep::getMethod(Uint32 index)
|
166 mike 1.18 {
|
167 kumpf 1.55 if (index >= _methods.size())
|
168 kumpf 1.75 throw IndexOutOfBoundsException();
|
169 mike 1.18
|
170 kumpf 1.55 return _methods[index];
|
171 mike 1.18 }
172
173 Uint32 CIMClassRep::getMethodCount() const
174 {
175 return _methods.size();
176 }
|
177 mike 1.20
|
178 kumpf 1.55 void CIMClassRep::removeMethod(Uint32 index)
|
179 mike 1.18 {
|
180 kumpf 1.55 if (index >= _methods.size())
|
181 kumpf 1.75 throw IndexOutOfBoundsException();
|
182 mike 1.18
|
183 kumpf 1.55 _methods.remove(index);
|
184 mike 1.18 }
185
186 void CIMClassRep::resolve(
187 DeclContext* context,
|
188 kumpf 1.49 const CIMNamespaceName& nameSpace)
|
189 mike 1.18 {
|
190 kumpf 1.75 PEG_METHOD_ENTER(TRC_OBJECTRESOLUTION, "CIMClassRep::resolve()");
|
191 mike 1.18 #if 0
192 if (_resolved)
|
193 kumpf 1.75 throw ClassAlreadyResolved(_reference.getClassName());
|
194 mike 1.18 #endif
195 if (!context)
|
196 kumpf 1.75 throw NullPointer();
|
197 mike 1.18
|
198 kumpf 1.75 PEG_TRACE_STRING(TRC_OBJECTRESOLUTION, Tracer::LEVEL3,
199 String("CIMClassRep::resolve class = ") +
200 _reference.getClassName().getString() + ", superclass = " +
201 _superClassName.getString());
|
202 karl 1.30
|
203 kumpf 1.49 if (!_superClassName.isNull())
|
204 kumpf 1.75 {
205 //----------------------------------------------------------------------
206 // First check to see if the super-class really exists and the
207 // subclassing legal:
208 //----------------------------------------------------------------------
209 CIMConstClass superClass =
210 context->lookupClass(nameSpace, _superClassName);
211
212 if (superClass.isUninitialized())
213 throw PEGASUS_CIM_EXCEPTION(CIM_ERR_INVALID_SUPERCLASS,
214 _superClassName.getString());
|
215 r.kieninger 1.74
|
216 mike 1.18 #if 0
|
217 kumpf 1.75 if (!superClass._rep->_resolved)
218 throw ClassNotResolved(_superClassName);
|
219 mike 1.18 #endif
|
220 kumpf 1.75 // If subclass is abstract but superclass not, throw CIM Exception
|
221 r.kieninger 1.74
|
222 kumpf 1.75 /* ATTN:KS-24 Mar 2002 P1 - Test this and confirm that rule is correct
223 if isAbstract() && !superclass.isAbstract()
224 throw PEGASUS_CIM_EXCEPTION(
225 CIM_ERR_INVALID_SUPERCLASS, _superClassName);
226 */
|
227 kumpf 1.76 /*if (superclass.isTrueQualifier(CIMQualifierNames::TERMINAL)
|
228 kumpf 1.75 throw PEGASUS_CIM_EXCEPTION(
229 CIM_ERR_INVALID_SUPERCLASS, _superClassName);
230 */
231 //----------------------------------------------------------------------
232 // Iterate all the properties of *this* class. Resolve each one and
233 // set the class-origin:
234 //----------------------------------------------------------------------
|
235 r.kieninger 1.74
|
236 kumpf 1.75 Boolean isAssociationClass = isAssociation();
|
237 a.dunfey 1.63
|
238 kumpf 1.75 for (Uint32 i = 0, n = _properties.size(); i < n; i++)
239 {
240 CIMProperty& property = _properties[i];
241
242 if (!isAssociationClass &&
243 property.getValue().getType() == CIMTYPE_REFERENCE)
244 {
245 throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_INVALID_PARAMETER,
246 MessageLoaderParms(
247 "Common.CIMClassRep.NON_ASSOCIATION_CLASS_CONTAINS_"
248 "REFERENCE_PROPERTY",
249 "Non-assocation class contains reference property"));
250 }
251
252
253 Uint32 index = superClass.findProperty(property.getName());
254
255 if (index == PEG_NOT_FOUND)
256 {
257 Resolver::resolveProperty(
258 property, context, nameSpace, false, true);
259 kumpf 1.75 if (property.getClassOrigin().isNull())
260 {
261 property.setClassOrigin(getClassName());
262 }
263 property.setPropagated(false);
264 }
265 else
266 {
267 CIMConstProperty superClassProperty =
268 superClass.getProperty(index);
269 Resolver::resolveProperty(property, context,
270 nameSpace, false, superClassProperty, true);
271 if (property.getClassOrigin().isNull())
272 {
273 property.setClassOrigin(
274 superClassProperty.getClassOrigin());
275 }
|
276 a.dunfey 1.62 }
|
277 kumpf 1.75 }
|
278 r.kieninger 1.74
|
279 kumpf 1.75 //----------------------------------------------------------------------
280 // Now prepend all properties inherited from the super-class (that
281 // are not overriden by this sub-class).
282 //----------------------------------------------------------------------
|
283 kumpf 1.54
|
284 kumpf 1.75 // Iterate super-class properties:
|
285 karl 1.29
|
286 kumpf 1.75 for (Uint32 i = 0, m = 0, n = superClass.getPropertyCount(); i < n; i++)
287 {
288 CIMConstProperty superClassProperty = superClass.getProperty(i);
289
290 // Find the property in *this* class; if not found, then clone and
291 // insert it (setting the propagated flag). Otherwise, change
292 // the class-origin and propagated flag accordingly.
293
294 Uint32 index = PEG_NOT_FOUND;
295 /* ATTN: KS move to simpler version of the find
296 for (Uint32 j = m, n = _properties.size(); j < n; j++)
297 {
298 if (_properties[j].getName() == superClassProperty.getName())
|
299 kumpf 1.66 {
|
300 kumpf 1.75 index = j;
301 break;
|
302 kumpf 1.66 }
|
303 kumpf 1.75 }
304 */
305 index = findProperty(superClassProperty.getName());
306
307 // If property exists in super class but not in this one, then
308 // clone and insert it. Otherwise, the properties class
309 // origin was set above.
310
311 CIMProperty superproperty = superClassProperty.clone();
|
312 r.kieninger 1.74
|
313 kumpf 1.75 if (index == PEG_NOT_FOUND)
314 {
315 superproperty.setPropagated(true);
316 _properties.insert(m++, superproperty);
317 }
318 else
319 {
320 // Property Qualifiers must propagate if allowed
321 // If property exists in the superclass and in the subclass,
322 // then, enumerate the qualifiers of the superclass's property.
323 // If a qualifier is defined on the superclass's property
324 // but not on the subclass's, then add it to the subclass's
325 // property's qualifier list.
326 CIMProperty subproperty = _properties[index];
327 for (Uint32 i = 0, n = superproperty.getQualifierCount();
328 i < n; i++)
329 {
330 Uint32 index = PEG_NOT_FOUND;
331 CIMQualifier superClassQualifier =
332 superproperty.getQualifier(i);
333 const CIMName name = superClassQualifier.getName();
334 kumpf 1.75 /* ATTN KS This is replacement find function.
335 if (Uint32 j = subproperty.findQualifier(q.getName()) ==
336 PEG_NOT_FOUND)
337 {
338 subproperty.addQualifier(superClassQualifier);
339 }
340 */
341 for (Uint32 j = 0, m = subproperty.getQualifierCount();
342 j < m;
343 j++)
344 {
345 CIMConstQualifier q = subproperty.getQualifier(j);
346 if (name.equal(q.getName()))
347 {
348 index = j;
349 break;
350 }
351 } // end comparison of subclass property's qualifiers
352 if (index == PEG_NOT_FOUND)
353 {
354 subproperty.addQualifier(superClassQualifier);
355 kumpf 1.75 }
356 /*
357 if ((index = subproperty.findQualifier(name)) ==
358 PEG_NOT_FOUND)
359 {
360 subproperty.addQualifier(superClassQualifier);
361 }
362 */
363 } // end iteration over superclass property's qualifiers
364 }
365 }
366
367 //----------------------------------------------------------------------
368 // Iterate all the methods of *this* class. Resolve each one and
369 // set the class-origin:
370 //----------------------------------------------------------------------
371
372 for (Uint32 i = 0, n = _methods.size(); i < n; i++)
373 {
374 CIMMethod& method = _methods[i];
375 Uint32 index = superClass.findMethod(method.getName());
376 kumpf 1.75
377 if (index == PEG_NOT_FOUND)
378 {
379 Resolver::resolveMethod(method, context, nameSpace);
380 }
381 else
382 {
383 CIMConstMethod superClassMethod = superClass.getMethod(index);
384 Resolver::resolveMethod(
385 method, context, nameSpace, superClassMethod);
386 }
387 }
388
389 //----------------------------------------------------------------------
390 // Now prepend all methods inherited from the super-class (that
391 // are not overriden by this sub-class).
392 //----------------------------------------------------------------------
393
394 for (Uint32 i = 0, m = 0, n = superClass.getMethodCount(); i < n; i++)
395 {
396 CIMConstMethod superClassMethod = superClass.getMethod(i);
397 kumpf 1.75
398 // Find the method in *this* class; if not found, then clone and
399 // insert it (setting the propagated flag). Otherwise, change
400 // the class-origin and propagated flag accordingly.
401
402 Uint32 index = PEG_NOT_FOUND;
403 /********************** KS move to simpler version
404 for (Uint32 j = m, n = _methods.size(); j < n; j++)
405 {
406 if (_methods[j].getName() == superClassMethod.getName())
407 {
408 index = j;
409 break;
410 }
411 }
412
413 // If method exists in super class but not in this one, then
414 // clone and insert it. Otherwise, the method's class origin
415 // has already been set above.
416
417 if (index == PEG_NOT_FOUND)
418 kumpf 1.75 {
419 CIMMethod method = superClassMethod.clone();
420 method.setPropagated(true);
421 _methods.insert(m++, method);
422 }
423 */
424 if ((index = findMethod(superClassMethod.getName())) ==
425 PEG_NOT_FOUND)
426 {
427 CIMMethod method = superClassMethod.clone();
428 method.setPropagated(true);
429 _methods.insert(m++, method);
430 }
431 }
432
433 //----------------------------------------------------------------------
434 // Validate the qualifiers of this class:
435 //----------------------------------------------------------------------
436 _qualifiers.resolve(
437 context,
438 nameSpace,
439 kumpf 1.75 isAssociation() ? CIMScope::ASSOCIATION : CIMScope::CLASS,
440 false,
441 superClass._rep->_qualifiers,
442 true);
443 }
444 else // No SuperClass exsts
445 {
446 //----------------------------------------------------------------------
447 // Resolve each property:
448 //----------------------------------------------------------------------
449
450 for (Uint32 i = 0, n = _properties.size(); i < n; i++)
451 {
452 Resolver::resolveProperty(
453 _properties[i], context, nameSpace, false, true);
454 _properties[i].setClassOrigin(getClassName());
455 _properties[i].setPropagated(false);
456 }
457
458 //----------------------------------------------------------------------
459 // Resolve each method:
460 kumpf 1.75 //----------------------------------------------------------------------
461
462 for (Uint32 i = 0, n = _methods.size(); i < n; i++)
463 {
464 Resolver::resolveMethod (_methods[i], context, nameSpace);
465 }
466
467 //----------------------------------------------------------------------
468 // Resolve the qualifiers:
469 //----------------------------------------------------------------------
470
471 CIMQualifierList dummy;
472
473 _qualifiers.resolve(
474 context,
475 nameSpace,
476 isAssociation() ? CIMScope::ASSOCIATION : CIMScope::CLASS,
477 false,
478 dummy,
479 true);
|
480 mike 1.18 }
481
482 // _resolved = true;
483 }
484
|
485 karl 1.61 CIMInstance CIMClassRep::buildInstance(Boolean includeQualifiers,
|
486 karl 1.60 Boolean includeClassOrigin,
487 const CIMPropertyList& propertyList) const
488 {
489
|
490 r.kieninger 1.74 // Create the new instance representation
491 CIMInstanceRep* newInstanceRep = new CIMInstanceRep(
492 CIMObjectPath(String::EMPTY,
493 CIMNamespaceName(),
494 _reference.getClassName()));
|
495 karl 1.60
496 // Copy qualifiers if required
497 if (includeQualifiers)
498 {
499 for (Uint32 i = 0 ; i < getQualifierCount() ; i++)
500 {
|
501 r.kieninger 1.74 newInstanceRep->_qualifiers.add(getQualifier(i).clone());
|
502 karl 1.60 }
503 }
504
|
505 r.kieninger 1.74 newInstanceRep->_properties.reserveCapacity(_properties.size());
506
|
507 karl 1.60 // Copy Properties
508 for (Uint32 i = 0 ; i < _properties.size() ; i++)
509 {
|
510 r.kieninger 1.74 CIMConstProperty cp = getProperty(i);
511 CIMName name = cp.getName();
|
512 karl 1.60 Array<CIMName> pl = propertyList.getPropertyNameArray();
513 if (propertyList.isNull() || Contains(pl, name))
514 {
|
515 r.kieninger 1.74 CIMProperty p;
516
517 if (includeQualifiers)
|
518 karl 1.60 {
|
519 r.kieninger 1.74 p = getProperty(i).clone();
520 }
521 else
522 {
523 p = CIMProperty(cp.getName(),
524 cp.getValue(),
525 cp.getArraySize(),
526 cp.getReferenceClassName(),
527 cp.getClassOrigin());
|
528 karl 1.60 }
|
529 r.kieninger 1.74
530 // Delete class origin attribute if required
|
531 karl 1.60 if (!includeClassOrigin)
532 {
533 p.setClassOrigin(CIMName());
534 }
535
|
536 r.kieninger 1.74 newInstanceRep->_properties.append(p);
|
537 karl 1.60 }
538 }
539
|
540 r.kieninger 1.74 // Create new CIMInstance from CIMInstanceRep
541 CIMInstance newInstance(newInstanceRep);
542
|
543 kumpf 1.76 return newInstance;
|
544 karl 1.60 }
545
|
546 mike 1.69 void CIMClassRep::toXml(Buffer& out) const
|
547 mike 1.18 {
548 // Class opening element:
549
|
550 mike 1.70 out << STRLIT("<CLASS ");
551 out << STRLIT(" NAME=\"") << _reference.getClassName() << STRLIT("\" ");
|
552 mike 1.18
|
553 kumpf 1.49 if (!_superClassName.isNull())
|
554 kumpf 1.75 out << STRLIT(" SUPERCLASS=\"") << _superClassName << STRLIT("\" ");
|
555 mike 1.18
|
556 mike 1.70 out << STRLIT(">\n");
|
557 mike 1.18
|
558 karl 1.73 // Append Class Qualifiers:
|
559 mike 1.18
560 _qualifiers.toXml(out);
561
|
562 karl 1.73 // Append Property definitions:
|
563 mike 1.18
564 for (Uint32 i = 0, n = _properties.size(); i < n; i++)
|
565 kumpf 1.75 XmlWriter::appendPropertyElement(out, _properties[i]);
|
566 mike 1.18
|
567 karl 1.73 // Append Method definitions:
|
568 mike 1.18
569 for (Uint32 i = 0, n = _methods.size(); i < n; i++)
|
570 kumpf 1.75 XmlWriter::appendMethodElement(out, _methods[i]);
|
571 mike 1.18
572 // Class closing element:
573
|
574 mike 1.70 out << STRLIT("</CLASS>\n");
|
575 mike 1.18 }
|
576 kumpf 1.75
|
577 mike 1.19 /** toMof prepares an 8-bit string with the MOF for the class.
578 The BNF for this is:
579 <pre>
|
580 kumpf 1.75 classDeclaration = [ qualifierList ]
581 CLASS className [ alias ] [ superClass ]
582 "{" *classFeature "}" ";"
|
583 r.kieninger 1.74
|
584 kumpf 1.75 superClass = :" className
|
585 mike 1.19
|
586 kumpf 1.75 classFeature = propertyDeclaration | methodDeclaration
|
587 mike 1.19
588 */
589
|
590 mike 1.69 void CIMClassRep::toMof(Buffer& out) const
|
591 mike 1.19 {
592 // Get and format the class qualifiers
|
593 mike 1.70 out << STRLIT("\n// Class ") << _reference.getClassName();
|
594 mike 1.19 if (_qualifiers.getCount())
|
595 kumpf 1.75 out.append('\n');
|
596 mike 1.70 out.append('\n');
|
597 mike 1.19 _qualifiers.toMof(out);
598
599 // Separate qualifiers from Class Name
|
600 mike 1.70 out.append('\n');
|
601 mike 1.19
602 // output class statement
|
603 mike 1.70 out << STRLIT("class ") << _reference.getClassName();
|
604 mike 1.19
|
605 kumpf 1.49 if (!_superClassName.isNull())
|
606 kumpf 1.75 out << STRLIT(" : ") << _superClassName;
|
607 chip 1.21
|
608 mike 1.70 out << STRLIT("\n{");
|
609 mike 1.19
610 // format the Properties:
611 for (Uint32 i = 0, n = _properties.size(); i < n; i++)
612 {
|
613 kumpf 1.75 // Generate MOF if this property not propagated
614 // Note that the test is required only because
615 // there is an error in getclass that does not
616 // test the localOnly flag
|
617 karl 1.73 // The inital "false" indicates to format as property declaration.
|
618 kumpf 1.75 if (!_properties[i].getPropagated())
619 MofWriter::appendPropertyElement(true, out, _properties[i]);
|
620 mike 1.19 }
621
622 // Format the Methods: for non-propagated methods
623 for (Uint32 i = 0, n = _methods.size(); i < n; i++)
624 {
|
625 kumpf 1.75 if (!_methods[i].getPropagated())
626 MofWriter::appendMethodElement(out, _methods[i]);
|
627 mike 1.19 }
628
629 // Class closing element:
|
630 mike 1.70 out << STRLIT("\n};\n");
|
631 mike 1.19 }
632
|
633 mike 1.18
634 CIMClassRep::CIMClassRep()
635 {
636 }
637
638 CIMClassRep::CIMClassRep(const CIMClassRep& x) :
|
639 mike 1.20 CIMObjectRep(x),
640 _superClassName(x._superClassName)
|
641 mike 1.18 {
|
642 kumpf 1.45 _methods.reserveCapacity(x._methods.size());
|
643 mike 1.18
644 for (Uint32 i = 0, n = x._methods.size(); i < n; i++)
|
645 kumpf 1.75 _methods.append(x._methods[i].clone());
|
646 mike 1.18 }
647
|
648 kumpf 1.36 Boolean CIMClassRep::identical(const CIMObjectRep* x) const
|
649 mike 1.18 {
|
650 mike 1.20 if (!CIMObjectRep::identical(x))
|
651 kumpf 1.75 return false;
|
652 mike 1.18
|
653 kumpf 1.36 const CIMClassRep* tmprep = dynamic_cast<const CIMClassRep*>(x);
654 if (!tmprep)
655 return false;
656
|
657 kumpf 1.56 if (!_superClassName.equal (tmprep->_superClassName))
|
658 kumpf 1.75 return false;
|
659 mike 1.18
|
660 mike 1.20 //
661 // Check methods:
662 //
|
663 mike 1.18
664 {
|
665 kumpf 1.75 const Array<CIMMethod>& tmp1 = _methods;
666 const Array<CIMMethod>& tmp2 = tmprep->_methods;
|
667 mike 1.18
|
668 kumpf 1.75 if (tmp1.size() != tmp2.size())
669 return false;
|
670 mike 1.18
|
671 kumpf 1.75 for (Uint32 i = 0, n = tmp1.size(); i < n; i++)
672 {
673 if (!tmp1[i].identical(tmp2[i]))
674 return false;
675
676 if (!tmp1[i].getClassOrigin().equal (tmp2[i].getClassOrigin()))
677 return false;
678
679 if (tmp1[i].getPropagated() != tmp2[i].getPropagated())
680 return false;
681 }
|
682 mike 1.18 }
683
|
684 kumpf 1.36 if (_resolved != tmprep->_resolved)
|
685 kumpf 1.75 return false;
|
686 mike 1.18
687 return true;
688 }
689
|
690 kumpf 1.49 void CIMClassRep::getKeyNames(Array<CIMName>& keyNames) const
|
691 mike 1.18 {
692 keyNames.clear();
693
694 for (Uint32 i = 0, n = getPropertyCount(); i < n; i++)
695 {
|
696 kumpf 1.75 CIMConstProperty property = getProperty(i);
|
697 mike 1.18
|
698 kumpf 1.55 Uint32 index;
|
699 r.kieninger 1.71 if ((index = property.findQualifier(
|
700 kumpf 1.75 CIMNameUnchecked("key"))) != PEG_NOT_FOUND)
|
701 kumpf 1.51 {
702 CIMValue value;
|
703 kumpf 1.55 value = property.getQualifier (index).getValue ();
|
704 kumpf 1.51 if (!value.isNull ())
705 {
706 Boolean isKey;
707 value.get (isKey);
708 if (isKey)
709 keyNames.append(property.getName());
710 }
711 }
|
712 mike 1.18 }
713 }
714
715 Boolean CIMClassRep::hasKeys() const
716 {
717 for (Uint32 i = 0, n = getPropertyCount(); i < n; i++)
718 {
|
719 kumpf 1.75 CIMConstProperty property = getProperty(i);
|
720 mike 1.18
|
721 kumpf 1.55 Uint32 index;
|
722 r.kieninger 1.71 if ((index = property.findQualifier(
|
723 kumpf 1.75 CIMNameUnchecked("key"))) != PEG_NOT_FOUND)
|
724 kumpf 1.51 {
725 CIMValue value;
|
726 kumpf 1.55 value = property.getQualifier (index).getValue ();
|
727 kumpf 1.51 if (!value.isNull ())
728 {
729 Boolean isKey;
730 value.get (isKey);
731 if (isKey)
732 return true;
733 }
734 }
|
735 mike 1.18 }
736
737 return false;
738 }
739
740 PEGASUS_NAMESPACE_END
741
|