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