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