1 karl 1.64 //%2004////////////////////////////////////////////////////////////////////////
|
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 mike 1.18 //
10 // Permission is hereby granted, free of charge, to any person obtaining a copy
|
11 chip 1.21 // of this software and associated documentation files (the "Software"), to
12 // deal in the Software without restriction, including without limitation the
13 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
14 mike 1.18 // sell copies of the Software, and to permit persons to whom the Software is
15 // furnished to do so, subject to the following conditions:
|
16 kumpf 1.44 //
|
17 chip 1.21 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
|
18 mike 1.18 // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
19 // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
20 chip 1.21 // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
21 // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
22 // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
23 mike 1.18 // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
24 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 //
26 //==============================================================================
27 //
28 // Author: Mike Brasher (mbrasher@bmc.com)
29 //
|
30 kumpf 1.35 // Modified By: Karl Schopmeyer(k.schopmeyer@attglobal.net)
31 // Roger Kumpf, Hewlett-Packard Company (roger_kumpf@hp.com)
|
32 kumpf 1.46 // Carol Ann Krug Graves, Hewlett-Packard Company
33 // (carolann_graves@hp.com)
|
34 mike 1.18 //
35 //%/////////////////////////////////////////////////////////////////////////////
36
|
37 kumpf 1.34 #include "CIMClassRep.h"
|
38 mike 1.18 #include "DeclContext.h"
|
39 kumpf 1.47 #include "Resolver.h"
|
40 mike 1.18 #include "Indentor.h"
41 #include "CIMName.h"
42 #include "CIMQualifierNames.h"
|
43 kumpf 1.37 #include "CIMScope.h"
|
44 mike 1.18 #include "XmlWriter.h"
|
45 kumpf 1.42 #include "MofWriter.h"
|
46 karl 1.30 #include <Pegasus/Common/Tracer.h>
|
47 humberto 1.57 #include <Pegasus/Common/MessageLoader.h> //l10n
|
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 mike 1.18 return false;
71
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 mike 1.18 return false;
78
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 mike 1.18 return false;
89
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 mike 1.18 return false;
95
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.54 throw UninitializedObjectException();
|
108 mike 1.18
109 // Reject addition of duplicate property name:
110
|
111 humberto 1.57 if (findProperty(x.getName()) != PEG_NOT_FOUND){
112 //l10n
113 //throw AlreadyExistsException
114 //("property \"" + x.getName().getString () + "\"");
115 MessageLoaderParms parms("Common.CIMClassRep.PROPERTY",
116 "property \"$0\"",
117 x.getName().getString());
118 throw AlreadyExistsException(parms);
119
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 // Set the class origin:
131 // ATTN: put this check in other places:
132
|
133 kumpf 1.49 if (x.getClassOrigin().isNull())
|
134 chip 1.23 CIMProperty(x).setClassOrigin(_reference.getClassName());
|
135 mike 1.18
136 // Add the property:
137
138 _properties.append(x);
139 }
140
141 void CIMClassRep::addMethod(const CIMMethod& x)
142 {
|
143 kumpf 1.50 if (x.isUninitialized())
|
144 kumpf 1.54 throw UninitializedObjectException();
|
145 mike 1.18
146 // Reject duplicate method names:
147
|
148 humberto 1.57 if (findMethod(x.getName()) != PEG_NOT_FOUND){
149 //l10n
150 //throw AlreadyExistsException
151 //("method \"" + x.getName().getString() + "\"");
152 MessageLoaderParms parms("Common.CIMClassRep.METHOD",
153 "method \"$0\"",
154 x.getName().getString());
155 throw AlreadyExistsException(parms);
156
157 }
|
158 mike 1.18
159 // Add the method:
160
161 _methods.append(x);
162 }
163
|
164 kumpf 1.49 Uint32 CIMClassRep::findMethod(const CIMName& name) const
|
165 mike 1.18 {
166 for (Uint32 i = 0, n = _methods.size(); i < n; i++)
167 {
|
168 kumpf 1.49 if (name.equal(_methods[i].getName()))
|
169 mike 1.18 return i;
170 }
171
172 return PEG_NOT_FOUND;
173 }
|
174 mike 1.20
|
175 kumpf 1.55 CIMMethod CIMClassRep::getMethod(Uint32 index)
|
176 mike 1.18 {
|
177 kumpf 1.55 if (index >= _methods.size())
|
178 kumpf 1.54 throw IndexOutOfBoundsException();
|
179 mike 1.18
|
180 kumpf 1.55 return _methods[index];
|
181 mike 1.18 }
182
183 Uint32 CIMClassRep::getMethodCount() const
184 {
185 return _methods.size();
186 }
|
187 mike 1.20
|
188 kumpf 1.55 void CIMClassRep::removeMethod(Uint32 index)
|
189 mike 1.18 {
|
190 kumpf 1.55 if (index >= _methods.size())
|
191 kumpf 1.54 throw IndexOutOfBoundsException();
|
192 mike 1.18
|
193 kumpf 1.55 _methods.remove(index);
|
194 mike 1.18 }
195
196 void CIMClassRep::resolve(
197 DeclContext* context,
|
198 kumpf 1.49 const CIMNamespaceName& nameSpace)
|
199 mike 1.18 {
|
200 karl 1.30 PEG_METHOD_ENTER(TRC_OBJECTRESOLUTION, "CIMClassRep::resolve()");
|
201 mike 1.18 #if 0
202 if (_resolved)
|
203 chip 1.23 throw ClassAlreadyResolved(_reference.getClassName());
|
204 mike 1.18 #endif
205 if (!context)
206 throw NullPointer();
207
|
208 kumpf 1.32 PEG_TRACE_STRING(TRC_OBJECTRESOLUTION, Tracer::LEVEL3,
209 String("CIMClassRep::resolve class = ") +
|
210 kumpf 1.56 _reference.getClassName().getString() + ", superclass = " +
211 _superClassName.getString());
|
212 karl 1.30
|
213 kumpf 1.49 if (!_superClassName.isNull())
|
214 karl 1.29 {
215 //cout << "KSTEST Class Resolve with Super class " << getClassName()
216 //<< " superClass " << _superClassName << endl;
217 //----------------------------------------------------------------------
218 // First check to see if the super-class really exists and the subclassing legal:
219 //----------------------------------------------------------------------
220 CIMConstClass superClass
221 = context->lookupClass(nameSpace, _superClassName);
222
|
223 kumpf 1.50 if (superClass.isUninitialized())
|
224 kumpf 1.56 throw PEGASUS_CIM_EXCEPTION(CIM_ERR_INVALID_SUPERCLASS,
|
225 humberto 1.57 _superClassName.getString());
226
|
227 karl 1.29
|
228 mike 1.18 #if 0
|
229 karl 1.29 if (!superClass._rep->_resolved)
230 throw ClassNotResolved(_superClassName);
|
231 mike 1.18 #endif
|
232 karl 1.29 // If subclass is abstract but superclass not, throw CIM Exception
233
234 /* ATTN:KS-24 Mar 2002 P1 - Test this and confirm that rule is correct
235 if isAbstract() && !superclass.isAbstract()
236 throw PEGASUS_CIM_EXCEPTION(CIM_ERR_INVALID_SUPERCLASS,_superClassName);
237 */
|
238 karl 1.31 /*if(superclass.isTrueQualifier(CIMQualifierNames::TERMINAL)
239 throw PEGASUS_CIM_EXCEPTION(CIM_ERR_INVALID_SUPERCLASS,_superClassName);
240 */
|
241 karl 1.29 //----------------------------------------------------------------------
242 // Iterate all the properties of *this* class. Resolve each one and
243 // set the class-origin:
244 //----------------------------------------------------------------------
245
|
246 kumpf 1.54 Boolean isAssociationClass = isAssociation();
247
|
248 karl 1.29 for (Uint32 i = 0, n = _properties.size(); i < n; i++)
249 {
250 CIMProperty& property = _properties[i];
|
251 kumpf 1.54
|
252 a.dunfey 1.63 if(!isAssociationClass &&
253 property.getValue().getType() == CIMTYPE_REFERENCE)
|
254 a.dunfey 1.62 {
|
255 humberto 1.57 //l10n
256 //throw PEGASUS_CIM_EXCEPTION(CIM_ERR_INVALID_PARAMETER,
257 //"Non-assocation class contains reference property");
258 throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_INVALID_PARAMETER,
259 MessageLoaderParms("Common.CIMClassRep.NON_ASSOCIATION_CLASS_CONTAINS_REFERENCE_PROPERTY",
260 "Non-assocation class contains reference property"));
261
|
262 a.dunfey 1.63
|
263 a.dunfey 1.62 }
264
|
265 kumpf 1.54
|
266 kumpf 1.55 Uint32 index = superClass.findProperty(property.getName());
|
267 karl 1.29
|
268 kumpf 1.55 if (index == PEG_NOT_FOUND)
|
269 karl 1.29 {
|
270 kumpf 1.47 Resolver::resolveProperty (property, context,
271 nameSpace, false, true);
|
272 karl 1.29 }
273 else
|
274 karl 1.28 {
|
275 karl 1.29 CIMConstProperty superClassProperty =
|
276 kumpf 1.55 superClass.getProperty(index);
|
277 kumpf 1.47 Resolver::resolveProperty (property, context,
278 nameSpace, false, superClassProperty, true);
|
279 karl 1.28 }
|
280 karl 1.29 }
281
282 //----------------------------------------------------------------------
283 // Now prepend all properties inherited from the super-class (that
284 // are not overriden by this sub-class).
285 //----------------------------------------------------------------------
286
287 // Iterate super-class properties:
288
289 for (Uint32 i = 0, m = 0, n = superClass.getPropertyCount(); i < n; i++)
|
290 karl 1.28 {
|
291 karl 1.29 CIMConstProperty superClassProperty = superClass.getProperty(i);
292
293 // Find the property in *this* class; if not found, then clone and
294 // insert it (setting the propagated flag). Otherwise, change
295 // the class-origin and propagated flag accordingly.
296
|
297 kumpf 1.55 Uint32 index = PEG_NOT_FOUND;
|
298 karl 1.29 /* ATTN: KS move to simpler version of the find
299 for (Uint32 j = m, n = _properties.size(); j < n; j++)
|
300 karl 1.28 {
|
301 karl 1.29 if (CIMName::equal(_properties[j].getName(),
302 superClassProperty.getName()))
|
303 karl 1.28 {
|
304 kumpf 1.55 index = j;
|
305 karl 1.29 break;
306 }
307 }
308 */
|
309 kumpf 1.55 index = findProperty(superClassProperty.getName());
|
310 karl 1.29
311 // If property exists in super class but not in this one, then
312 // clone and insert it. Otherwise, the properties class
313 // origin was set above.
314
|
315 kumpf 1.51 CIMProperty superproperty = superClassProperty.clone();
|
316 karl 1.29
|
317 kumpf 1.55 if (index == PEG_NOT_FOUND)
|
318 karl 1.29 {
319 superproperty.setPropagated(true);
320 _properties.insert(m++, superproperty);
321 }
322 else
323 {
324 // Property Qualifiers must propagate if allowed
325 // If property exists in the superclass and in the subclass,
326 // then, enumerate the qualifiers of the superclass's property.
327 // If a qualifier is defined on the superclass's property
328 // but not on the subclass's, then add it to the subclass's
329 // property's qualifier list.
|
330 kumpf 1.55 CIMProperty subproperty = _properties[index];
|
331 karl 1.29 for (Uint32 i = 0, n = superproperty.getQualifierCount();
332 i < n; i++)
333 {
|
334 kumpf 1.55 Uint32 index = PEG_NOT_FOUND;
|
335 karl 1.29 CIMQualifier superClassQualifier =
336 superproperty.getQualifier(i);
|
337 kumpf 1.49 const CIMName name = superClassQualifier.getName();
|
338 karl 1.29 /* ATTN KS This is replacement find function.
339 if((Uint32 j = subproperty.findQualifier(q.getName()) == PEG_NOT_FOUND)
|
340 karl 1.28 {
|
341 karl 1.29 subproperty.addQualifier(superClassQualifier);
342
|
343 karl 1.28 }
|
344 karl 1.29 */
345 for (Uint32 j = 0, m = subproperty.getQualifierCount();
346 j < m;
347 j++)
348 {
349 CIMConstQualifier q = subproperty.getQualifier(j);
|
350 kumpf 1.49 if (name.equal(q.getName()))
|
351 karl 1.29 {
|
352 kumpf 1.55 index = j;
|
353 karl 1.29 break;
354 }
355 } // end comparison of subclass property's qualifiers
|
356 kumpf 1.55 if (index == PEG_NOT_FOUND)
|
357 karl 1.29 {
358 subproperty.addQualifier(superClassQualifier);
359 }
360 /*
|
361 kumpf 1.55 if ((index = subproperty.findQualifier(name)) == PEG_NOT_FOUND)
|
362 karl 1.29 {
363 subproperty.addQualifier(superClassQualifier);
364 }
365 */
366 } // end iteration over superclass property's qualifiers
367 }
368 }
369
370 //----------------------------------------------------------------------
371 // Iterate all the methods of *this* class. Resolve each one and
372 // set the class-origin:
373 //----------------------------------------------------------------------
374
375 for (Uint32 i = 0, n = _methods.size(); i < n; i++)
376 {
377 CIMMethod& method = _methods[i];
|
378 kumpf 1.55 Uint32 index = superClass.findMethod(method.getName());
|
379 karl 1.29
|
380 kumpf 1.55 if (index == PEG_NOT_FOUND)
|
381 karl 1.29 {
|
382 kumpf 1.47 Resolver::resolveMethod (method, context,
383 nameSpace);
|
384 karl 1.29 }
385 else
386 {
|
387 kumpf 1.55 CIMConstMethod superClassMethod = superClass.getMethod(index);
|
388 kumpf 1.47 Resolver::resolveMethod (method, context,
389 nameSpace, superClassMethod);
|
390 karl 1.29 }
391 }
392
393 //----------------------------------------------------------------------
394 // Now prepend all methods inherited from the super-class (that
395 // are not overriden by this sub-class).
396 //----------------------------------------------------------------------
397
398 for (Uint32 i = 0, m = 0, n = superClass.getMethodCount(); i < n; i++)
399 {
400 CIMConstMethod superClassMethod = superClass.getMethod(i);
401
402 // Find the method in *this* class; if not found, then clone and
403 // insert it (setting the propagated flag). Otherwise, change
404 // the class-origin and propagated flag accordingly.
405
|
406 kumpf 1.55 Uint32 index = PEG_NOT_FOUND;
|
407 karl 1.29 /********************** KS move to simpler version
408 for (Uint32 j = m, n = _methods.size(); j < n; j++)
409 {
410 if (CIMName::equal(_methods[j].getName(),
411 superClassMethod.getName()))
|
412 karl 1.28 {
|
413 kumpf 1.55 index = j;
|
414 karl 1.29 break;
|
415 karl 1.28 }
|
416 karl 1.29 }
417
418 // If method exists in super class but not in this one, then
419 // clone and insert it. Otherwise, the method's class origin
420 // has already been set above.
421
|
422 kumpf 1.55 if (index == PEG_NOT_FOUND)
|
423 karl 1.29 {
424 CIMMethod method = superClassMethod.clone();
425 method.setPropagated(true);
426 _methods.insert(m++, method);
427 }
428 */
|
429 kumpf 1.55 if((index = findMethod(superClassMethod.getName())) == PEG_NOT_FOUND)
|
430 karl 1.28 {
|
431 karl 1.29 CIMMethod method = superClassMethod.clone();
432 method.setPropagated(true);
433 _methods.insert(m++, method);
|
434 karl 1.28 }
435 }
|
436 karl 1.29
437 //----------------------------------------------------------------------
438 // Validate the qualifiers of this class:
439 //----------------------------------------------------------------------
440 //cout << "KSTEST Class Qualifiers resolve for class" << getClassName() << endl;
441 _qualifiers.resolve(
442 context,
443 nameSpace,
444 isAssociation() ? CIMScope::ASSOCIATION : CIMScope::CLASS,
445 false,
446 superClass._rep->_qualifiers,
447 true);
|
448 mike 1.18 }
|
449 karl 1.29 else // No SuperClass exsts
|
450 mike 1.18 {
|
451 karl 1.28 //----------------------------------------------------------------------
452 // Resolve each property:
453 //----------------------------------------------------------------------
|
454 karl 1.29 //cout << "KSTEST Class Resolve, No Super class " << getClassName() << endl;
455
|
456 karl 1.28 for (Uint32 i = 0, n = _properties.size(); i < n; i++)
|
457 kumpf 1.47 Resolver::resolveProperty (_properties[i], context,
458 nameSpace, false, true);
|
459 karl 1.28
460 //----------------------------------------------------------------------
461 // Resolve each method:
462 //----------------------------------------------------------------------
463
464 for (Uint32 i = 0, n = _methods.size(); i < n; i++)
|
465 kumpf 1.47 Resolver::resolveMethod (_methods[i], context, nameSpace);
|
466 karl 1.28
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 // Create the new instance
491 CIMInstance newInstance(_reference.getClassName());
492
493 // Copy qualifiers if required
494 if (includeQualifiers)
495 {
496 for (Uint32 i = 0 ; i < getQualifierCount() ; i++)
497 {
498 newInstance.addQualifier(getQualifier(i).clone());
499 }
500 }
501
502 // Copy Properties
503 for (Uint32 i = 0 ; i < _properties.size() ; i++)
504 {
505 CIMConstProperty p = getProperty(i);
506 CIMName name = p.getName();
507 karl 1.60 Array<CIMName> pl = propertyList.getPropertyNameArray();
508 if (propertyList.isNull() || Contains(pl, name))
509 {
510 CIMProperty p = getProperty(i).clone();
511 if (!includeQualifiers && p.getQualifierCount() != 0)
512 {
513 for (Uint32 j = 0 ; j < getQualifierCount() ; j++)
514 {
515 p.removeQualifier(i - 1);
516 }
517 }
518 if (!includeClassOrigin)
519 {
520 p.setClassOrigin(CIMName());
521 }
522 newInstance.addProperty(p);
523
524 // Delete class origin attribute if required
525 }
526 }
527
528 karl 1.60 return(newInstance);
529 }
530
|
531 mike 1.18 void CIMClassRep::toXml(Array<Sint8>& out) const
532 {
533 // Class opening element:
534
535 out << "<CLASS ";
|
536 chip 1.23 out << " NAME=\"" << _reference.getClassName() << "\" ";
|
537 mike 1.18
|
538 kumpf 1.49 if (!_superClassName.isNull())
|
539 mike 1.18 out << " SUPERCLASS=\"" << _superClassName << "\" ";
540
541 out << ">\n";
542
543 // Qualifiers:
544
545 _qualifiers.toXml(out);
546
547 // Parameters:
548
549 for (Uint32 i = 0, n = _properties.size(); i < n; i++)
|
550 kumpf 1.41 XmlWriter::appendPropertyElement(out, _properties[i]);
|
551 mike 1.18
552 // Methods:
553
554 for (Uint32 i = 0, n = _methods.size(); i < n; i++)
|
555 kumpf 1.41 XmlWriter::appendMethodElement(out, _methods[i]);
|
556 mike 1.18
557 // Class closing element:
558
559 out << "</CLASS>\n";
560 }
|
561 mike 1.19 /** toMof prepares an 8-bit string with the MOF for the class.
562 The BNF for this is:
563 <pre>
564 classDeclaration = [ qualifierList ]
565 CLASS className [ alias ] [ superClass ]
566 "{" *classFeature "}" ";"
|
567 chip 1.21
|
568 mike 1.19 superClass = :" className
569
570 classFeature = propertyDeclaration | methodDeclaration
571
572 */
573
574 void CIMClassRep::toMof(Array<Sint8>& out) const
575 {
576 // Get and format the class qualifiers
|
577 chip 1.23 out << "\n// Class " << _reference.getClassName();
|
578 mike 1.19 if (_qualifiers.getCount())
579 out << "\n";
|
580 karl 1.26 out << "\n";
|
581 mike 1.19 _qualifiers.toMof(out);
582
583 // Separate qualifiers from Class Name
584 out << "\n";
585
586 // output class statement
|
587 chip 1.23 out << "class " << _reference.getClassName();
|
588 mike 1.19
|
589 kumpf 1.49 if (!_superClassName.isNull())
|
590 mike 1.19 out << " : " << _superClassName;
|
591 chip 1.21
|
592 mike 1.19 out << "\n{";
593
594 // format the Properties:
595 for (Uint32 i = 0, n = _properties.size(); i < n; i++)
596 {
|
597 kumpf 1.51 // Generate MOF if this property not propagated
|
598 mike 1.19 // Note that the test is required only because
599 // there is an error in getclass that does not
600 // test the localOnly flag.
601 if (!_properties[i].getPropagated())
|
602 kumpf 1.42 MofWriter::appendPropertyElement(out, _properties[i]);
|
603 mike 1.19 }
604
605 // Format the Methods: for non-propagated methods
606 for (Uint32 i = 0, n = _methods.size(); i < n; i++)
607 {
608 if (!_methods[i].getPropagated())
|
609 kumpf 1.42 MofWriter::appendMethodElement(out, _methods[i]);
|
610 mike 1.19 }
611
612 // Class closing element:
613 out << "\n};\n";
614 }
615
|
616 mike 1.18
617 CIMClassRep::CIMClassRep()
618 {
619 }
620
621 CIMClassRep::CIMClassRep(const CIMClassRep& x) :
|
622 mike 1.20 CIMObjectRep(x),
623 _superClassName(x._superClassName)
|
624 mike 1.18 {
|
625 kumpf 1.45 _methods.reserveCapacity(x._methods.size());
|
626 mike 1.18
627 for (Uint32 i = 0, n = x._methods.size(); i < n; i++)
628 _methods.append(x._methods[i].clone());
629 }
630
|
631 kumpf 1.36 Boolean CIMClassRep::identical(const CIMObjectRep* x) const
|
632 mike 1.18 {
|
633 mike 1.20 if (!CIMObjectRep::identical(x))
|
634 mike 1.18 return false;
635
|
636 kumpf 1.36 const CIMClassRep* tmprep = dynamic_cast<const CIMClassRep*>(x);
637 if (!tmprep)
638 return false;
639
|
640 kumpf 1.56 if (!_superClassName.equal (tmprep->_superClassName))
|
641 mike 1.18 return false;
642
|
643 mike 1.20 //
644 // Check methods:
645 //
|
646 mike 1.18
647 {
648 const Array<CIMMethod>& tmp1 = _methods;
|
649 kumpf 1.36 const Array<CIMMethod>& tmp2 = tmprep->_methods;
|
650 mike 1.18
651 if (tmp1.size() != tmp2.size())
652 return false;
653
654 for (Uint32 i = 0, n = tmp1.size(); i < n; i++)
655 {
656 if (!tmp1[i].identical(tmp2[i]))
657 return false;
658
|
659 kumpf 1.56 if (!tmp1[i].getClassOrigin().equal (tmp2[i].getClassOrigin()))
|
660 mike 1.18 return false;
661
662 if (tmp1[i].getPropagated() != tmp2[i].getPropagated())
663 return false;
664 }
665 }
666
|
667 kumpf 1.36 if (_resolved != tmprep->_resolved)
|
668 mike 1.18 return false;
669
670 return true;
671 }
672
|
673 kumpf 1.49 void CIMClassRep::getKeyNames(Array<CIMName>& keyNames) const
|
674 mike 1.18 {
675 keyNames.clear();
676
677 for (Uint32 i = 0, n = getPropertyCount(); i < n; i++)
678 {
679 CIMConstProperty property = getProperty(i);
680
|
681 kumpf 1.55 Uint32 index;
|
682 kumpf 1.56 if ((index = property.findQualifier (CIMName ("key"))) != PEG_NOT_FOUND)
|
683 kumpf 1.51 {
684 CIMValue value;
|
685 kumpf 1.55 value = property.getQualifier (index).getValue ();
|
686 kumpf 1.51 if (!value.isNull ())
687 {
688 Boolean isKey;
689 value.get (isKey);
690 if (isKey)
691 keyNames.append(property.getName());
692 }
693 }
|
694 mike 1.18 }
695 }
696
697 Boolean CIMClassRep::hasKeys() const
698 {
699 for (Uint32 i = 0, n = getPropertyCount(); i < n; i++)
700 {
701 CIMConstProperty property = getProperty(i);
702
|
703 kumpf 1.55 Uint32 index;
|
704 kumpf 1.56 if ((index = property.findQualifier (CIMName ("key"))) != PEG_NOT_FOUND)
|
705 kumpf 1.51 {
706 CIMValue value;
|
707 kumpf 1.55 value = property.getQualifier (index).getValue ();
|
708 kumpf 1.51 if (!value.isNull ())
709 {
710 Boolean isKey;
711 value.get (isKey);
712 if (isKey)
713 return true;
714 }
715 }
|
716 mike 1.18 }
717
718 return false;
719 }
720
721 PEGASUS_NAMESPACE_END
722
|