1 mike 1.25 //%/////////////////////////////////////////////////////////////////////////////
2 //
3 // Copyright (c) 2000, 2001 The Open group, BMC Software, Tivoli Systems, IBM
4 //
5 // Permission is hereby granted, free of charge, to any person obtaining a copy
|
6 chip 1.29 // of this software and associated documentation files (the "Software"), to
7 // deal in the Software without restriction, including without limitation the
8 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
9 mike 1.25 // sell copies of the Software, and to permit persons to whom the Software is
10 // furnished to do so, subject to the following conditions:
|
11 chip 1.29 //
12 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
|
13 mike 1.25 // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
14 // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
15 chip 1.29 // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
16 // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
17 // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
18 mike 1.25 // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
19 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20 //
21 //==============================================================================
22 //
23 // Author: Mike Brasher (mbrasher@bmc.com)
24 //
25 // Modified By:
26 //
27 //%/////////////////////////////////////////////////////////////////////////////
28
29 #ifndef Pegasus_CIMClass_h
30 #define Pegasus_CIMClass_h
31
32 #include <Pegasus/Common/Config.h>
|
33 mike 1.27 #include <Pegasus/Common/CIMObject.h>
|
34 mike 1.25 #include <Pegasus/Common/CIMClassRep.h>
35
36 PEGASUS_NAMESPACE_BEGIN
37
38 class CIMConstClass;
39 class CIMObject;
|
40 mike 1.27 class CIMConstObject;
|
41 mike 1.25
|
42 mike 1.28 // REVIEW: redocument.
43
|
44 mike 1.25 /** The CIMClass class is used to represent CIM classes in Pegasus. In CIM,
45 a class object may be a class or an associator. A CIM class must contain a
46 name and may contain methods, properties, and qualifiers. It is a template
47 for creating a CIM instance. A CIM class represents a collection of CIM
48 instances, all of which support a common type (for example, a set of
49 properties, methods, and associations).
50 */
51 class PEGASUS_COMMON_LINKAGE CIMClass
52 {
53 public:
54
55 /** Constructor - Creates an uninitiated a new CIM object
56 reprenting a CIM class. The class object created by this
57 constructor can only be used in an operation such as the
58 copy constructor. It cannot be used to create a class by
59 appending names, properties, etc. since it is unitiated.
60
61 Use one of the other constructors to create an initiated new CIM class
62 object.
63 @exception Throws an exception "unitialized handle" if this
64 unitialized handle is used
65 mike 1.25 /REF(HPEGASUS_HANDLES)
66 */
67 CIMClass() : _rep(0)
68 {
69 }
70
71 /** Constructor - Creates a class from a previous class
72 */
73 CIMClass(const CIMClass& x)
74 {
75 Inc(_rep = x._rep);
76 }
77
|
78 mike 1.27 PEGASUS_EXPLICIT CIMClass(const CIMObject& x);
79
80 PEGASUS_EXPLICIT CIMClass(const CIMObject& x, NoThrow&);
81
82 /** Assignment operator.
83 */
|
84 mike 1.25 CIMClass& operator=(const CIMClass& x)
85 {
86 if (x._rep != _rep)
87 {
88 Dec(_rep);
89 Inc(_rep = x._rep);
90 }
91 return *this;
92 }
93
|
94 mike 1.28 /** Constructor - Creates a Class from inputs of a classname and
|
95 mike 1.25 SuperClassName
96 @param className String representing name of the class being created
97 @param superClassName String representing name of the SuperClass
98 ATTN: Define what makes up legal name.
99 @return Throws IllegalName if className argument illegal CIM identifier.
100 <pre>
101 CIMClass NewCass("MyClass", "YourClass");
102 </pre>
103
104 */
105 CIMClass(
|
106 chip 1.29 const CIMReference& reference,
|
107 mike 1.25 const String& superClassName = String())
108 {
|
109 chip 1.29 _rep = new CIMClassRep(reference, superClassName);
|
110 mike 1.25 }
111
112 /// Destructor
113 ~CIMClass()
114 {
115 Dec(_rep);
116 }
117
118 /** isAssociation - Identifies whether or not this CIM class
119 is an association. An association is a relationship between two
120 (or more) classes or instances of two classes. The properties of an
121 association class include pointers, or references, to the two (or
122 more) instances. All CIM classes can be included in one or more
123 associations.
124 @return Boolean True if this CIM class belongs to an association;
125 otherwise, false.
126 */
127 Boolean isAssociation() const
128 {
129 _checkRep();
130 return _rep->isAssociation();
131 mike 1.25 }
132
|
133 mike 1.26 /** isAbstract Test if the CIMClass is abstract.
134 @return - True if the CIMClass Object is abstract
135 SeeAlso: Abstract
136 */
|
137 mike 1.25 Boolean isAbstract() const
138 {
139 _checkRep();
140 return _rep->isAbstract();
141 }
142
143 /** getClassName Gets the name of the class
144 ATTN: COMMENT. Why not just get name so we have common method for all.
145 @return Returns string with the class name.
146 */
147 const String& getClassName() const
148 {
149 _checkRep();
150 return _rep->getClassName();
151 }
152
|
153 chip 1.29 const CIMReference& getPath() const
154 {
155 _checkRep();
156 return _rep->getPath();
157 }
158
|
159 mike 1.26 /** getSuperClassName - Gets the name of the Parent
|
160 mike 1.25 @return String with parent class name.
161 */
162 const String& getSuperClassName() const
163 {
164 _checkRep();
165 return _rep->getSuperClassName();
166 }
167
|
168 mike 1.26 /** setSuperClassName - Sets the name of the parent class from
|
169 mike 1.25 the input parameter. \REF{CLASSNAME}. ATTN: Define legal classnames
170 @param String defining parent name.
171 @return Throws IllegalName if superClassName argument not legal CIM
172 identifier
173 @exception throws IllegalName if the name is not correct. See
174 \URL[ClassNames]{DefinitionofTerms.html#CLASSNAME}
175 */
176 void setSuperClassName(const String& superClassName)
177 {
178 _checkRep();
179 _rep->setSuperClassName(superClassName);
180 }
181
182 /** addQualifier - Adds the specified qualifier to the class
183 and increments the qualifier count. It is illegal to add the same
184 qualifier more than one time.
185 @param qualifier CIMQualifier object representing the qualifier to be
186 added
187 @return Returns handle of the class object
188 @exception Throws AlreadyExists.
189 */
190 mike 1.25 CIMClass& addQualifier(const CIMQualifier& qualifier)
191 {
192 _checkRep();
193 _rep->addQualifier(qualifier);
194 return *this;
195 }
196
197 /** findQualifier - Searches for a qualifier with the specified `
198 input name if it exists in the class
199 @param name CIMName of the qualifier
200 to be found @return Position of the qualifier in the Class.
201 @return Returns index of the qualifier found or PEG_NOT_FOUND
202 if not found.
203 */
204 Uint32 findQualifier(const String& name)
205 {
206 _checkRep();
207 return _rep->findQualifier(name);
208 }
209 ///
210 Uint32 findQualifier(const String& name) const
211 mike 1.25 {
212 _checkRep();
213 return _rep->findQualifier(name);
214 }
215 /** existsQualifier - Returns true if the qualifier with the
216 specified name exists in the class
217 @param name String name of the qualifier object being tested.
218 @return True if the qualifier exits. Otherwise false is returned.
219 */
220 Boolean existsQualifier(const String& name)
221 {
222 _checkRep();
223 return _rep->existsQualifier(name);
224 }
225 ///
226 Boolean existsQualifier(const String& name) const
227 {
228 _checkRep();
229 return _rep->existsQualifier(name);
230 }
231
232 mike 1.25 /** getQualifier - Gets the CIMQualifier object defined
233 by the input parameter
234 @param pos defines the position of the qualifier in the class from the
235 findQualifier method
|
236 mike 1.28 @return CIMQualifier object representing the qualifier found. On error,
237 CIMQualifier handle will be null.
|
238 mike 1.25 */
239 CIMQualifier getQualifier(Uint32 pos)
240 {
241 _checkRep();
242 return _rep->getQualifier(pos);
243 }
244
245 /// getQualifier - ATTN:
246 CIMConstQualifier getQualifier(Uint32 pos) const
247 {
248 _checkRep();
249 return _rep->getQualifier(pos);
250 }
251
252 /** removeQualifier - Removes the qualifier defined by the
253 index parameter.
254 @param Defines the index of the qualifier to be removed.
255 @return There is no return.
256 @exception Throw OutOfBound exception if the index is outside
257 the range of existing qualifier objects for this class
258 */
259 mike 1.25 void removeQualifier(Uint32 pos) const
260 {
261 _checkRep();
262 _rep->removeQualifier(pos);
263 }
264
265 /** getQualifierCount - Returns the number of qualifiers
266 in the class.
267 @return ATTN:
268 */
269 Uint32 getQualifierCount() const
270 {
271 _checkRep();
272 return _rep->getQualifierCount();
273 }
274
275 /** addProperty - Adds the specified property object to the
276 properties in the CIM class
277 */
278 CIMClass& addProperty(const CIMProperty& x)
279 {
280 mike 1.25 _checkRep();
281 _rep->addProperty(x);
282 return *this;
283 }
284
|
285 mike 1.26 /** findProperty - Finds the property object with the
|
286 mike 1.25 name defined by the input parameter in the class.
287 @param String parameter with the property name.
288 @return position representing the property object found or
289 PEG_NOT_FOUND if the property is not found.
290 */
291 Uint32 findProperty(const String& name)
292 {
293 _checkRep();
294 return _rep->findProperty(name);
295 }
296
297 Uint32 findProperty(const String& name) const
298 {
299 _checkRep();
300 return _rep->findProperty(name);
301 }
302
303 /** existsPropery - Determines if a property object with the
304 name defined by the input parameter exists in the class.
305 @parm String parameter with the property name.
306 @return True if the property object exists.
307 mike 1.25 */
308 Boolean existsProperty(const String& name)
309 {
310 _checkRep();
311 return _rep->existsProperty(name);
312 }
|
313 chip 1.29
314 Boolean existsProperty(const String& name) const
|
315 mike 1.25 {
316 _checkRep();
317 return _rep->existsProperty(name);
318 }
319
320 /** getProperty - Returns a property representing the property
321 defined by the input parameter
322 @param position for this property
323 ATTN: Should we not use something like handle for position???
324 @return CIMProperty object
325 ATTN: what is error return?
326 */
327 CIMProperty getProperty(Uint32 pos)
328 {
329 _checkRep();
330 return _rep->getProperty(pos);
331 }
332
333 /**getProperty Gets a property object from the CIMClass
334 @param pos The index of the property object to get.
335 @return Returns handle of the property object requested
336 mike 1.25 @exception Throws OutofBounds if the size field is greather than the
337 bunber of properties in the class.
338 */
339 CIMConstProperty getProperty(Uint32 pos) const
340 {
341 _checkRep();
342 return _rep->getProperty(pos);
343 }
344
345 /** removeProperty - Removes the property represented
346 by the position input parameter from the class
347 @param pos Index to the property to be removed from the
348 findPropety method
349 @exception Throws OutofBounds if index is not a property object
350 */
351 void removeProperty(Uint32 pos)
352 {
353 _checkRep();
354 _rep->removeProperty(pos);
355 }
356
357 mike 1.25 /** getPropertyCount - Gets the count of the number of properties
358 defined in the class.
359 @return count of number of proerties in the class
360 */
361 Uint32 getPropertyCount() const
362 {
363 _checkRep();
364 return _rep->getPropertyCount();
365 }
366
367 /** addMethod - Adds the method object defined by the input
368 parameter to the class and increments the count of the number of
369 methods in the class
370 @param method object representing the method to be added
371 @return Returns the CIMClass object to which the method was added.
372 @exception Throws AlreadyExists if the method already exists and throws
373 UnitializedHandle if the handle is not initialized
374 */
375 CIMClass& addMethod(const CIMMethod& x)
376 {
377 _checkRep();
378 mike 1.25 _rep->addMethod(x);
379 return *this;
380 }
381
382 /** findMethod - Locate the method object defined by the
383 name input
384 @param String representing the name of the method to be found
385 @return Position of the method object in the class to be used in
386 subsequent getmethod, etc. operations
387 */
388 Uint32 findMethod(const String& name)
389 {
390 _checkRep();
391 return _rep->findMethod(name);
392 }
393
394 Uint32 findMethod(const String& name) const
395 {
396 _checkRep();
397 return _rep->findMethod(name);
398 }
399 mike 1.25
400 /** existsMethod - Determine if the method object defined by the
401 name input exists
402 @param String representing the name of the method to be found
403 @return True if the method exists
404 */
405 Boolean existsMethod(const String& name)
406 {
407 _checkRep();
408 return _rep->existsMethod(name);
409 }
410
411 Boolean existsMethod(const String& name) const
412 {
413 _checkRep();
414 return _rep->existsMethod(name);
415 }
416
417
418 /** getMethod - Gets the method object defined by the
419 input parameter.
|
420 mike 1.26 @param pos Index to the method object to get
421 @return Returns handle of the method requested
|
422 mike 1.25 @exception Throws OutofBounds if the index represented by pos is greater
423 than the number of methods defined in the class object
424 */
425 CIMMethod getMethod(Uint32 pos)
426 {
427 _checkRep();
428 return _rep->getMethod(pos);
429 }
430
431 /** getMethod Gets the method object defined by the input
432 parameter. This is the const version.
433 */
434
435 CIMConstMethod getMethod(Uint32 pos) const
436 {
437 _checkRep();
438 return _rep->getMethod(pos);
439 }
440
441 /** removeMethod - Removes the method defined by the
442 index parameter.
443 mike 1.25 @param Defines the index of the method to be removed.
444 @return There is no return.
445 @exception Throw OutOfBound exception if the index is outside
446 the range of existing method objects for this class
447 */
448 void removeMethod(Uint32 pos) const
449 {
450 _checkRep();
451 _rep->removeMethod(pos);
452 }
453
|
454 mike 1.26 /** getMethodCount - Count of the number of methods in the class
|
455 mike 1.25 @return integer representing the number of methods in the class object.
456 */
457 Uint32 getMethodCount() const
458 {
459 _checkRep();
460 return _rep->getMethodCount();
461 }
462
463 /** Resolve - Resolve the class: inherit any properties and
464 qualifiers. Make sure the superClass really exists and is consistent
465 with this class. Also set the propagated flag class-origin for each
466 class feature.
467 ATTN: explain why this here
468 */
469 void resolve(
470 DeclContext* declContext,
471 const String& nameSpace)
472 {
473 _checkRep();
474 _rep->resolve(declContext, nameSpace);
475 }
476 mike 1.25
477 /// operator - ATTN:
478 operator int() const { return _rep != 0; }
479
|
480 mike 1.26 /** toXML - prepares an XML representation of the CIMClass object
481 in the provided Sint8 variable.
482 @param out Sint8 array for the XML representation
483 */
|
484 mike 1.25 void toXml(Array<Sint8>& out) const
485 {
486 _checkRep();
487 _rep->toXml(out);
488 }
489
|
490 mike 1.26 /** print - Prints the toXML output to cout
491 */
|
492 mike 1.25 void print(PEGASUS_STD(ostream) &o=PEGASUS_STD(cout)) const
493 {
494 _checkRep();
495 _rep->print(o);
496 }
497
|
498 mike 1.26 /** toMof - prepares a MOF representation of the CIMClass object
499 in the provided Sint8 variable.
500 @param out Sint8 array for the XML representation
501 */
502 void toMof(Array<Sint8>& out) const
503 {
504 _checkRep();
505 _rep->toMof(out);
506 }
507 /** printMof - Prints the toMof output to cout
508 */
509 void printMof(PEGASUS_STD(ostream) &o=PEGASUS_STD(cout)) const
510 {
511 _checkRep();
512 _rep->printMof(o);
513 }
514
515 /** identical - Compares with another class
|
516 mike 1.25 ATTN: Clarify exactly what identical means
517 @param Class object for the class to be compared
518 @return True if the classes are identical
519 */
520 Boolean identical(const CIMConstClass& x) const;
521
522 /** Makes a deep copy (clone) of the given object. */
523 CIMClass clone() const
524 {
|
525 mike 1.27 return CIMClass((CIMClassRep*)(_rep->clone()));
|
526 mike 1.25 }
527
528 /** Get names of all keys of this class. */
529 void getKeyNames(Array<String>& keyNames) const
530 {
531 _checkRep();
532 _rep->getKeyNames(keyNames);
533 }
534
535 Boolean hasKeys() const
536 {
537 _checkRep();
538 return _rep->hasKeys();
539 }
540
541 private:
542
543 CIMClass(CIMClassRep* rep) : _rep(rep)
544 {
545 }
546
547 mike 1.25 void _checkRep() const
548 {
549 if (!_rep)
550 ThrowUnitializedHandle();
551 }
552
553 CIMClassRep* _rep;
554 friend class CIMConstClass;
555 friend class CIMObject;
|
556 mike 1.27 friend class CIMConstObject;
|
557 mike 1.25 };
558
559 #define PEGASUS_ARRAY_T CIMClass
560 # include "ArrayInter.h"
561 #undef PEGASUS_ARRAY_T
562
563 /** CIMConstClass - ATTN: define this.
564
565 */
566 class PEGASUS_COMMON_LINKAGE CIMConstClass
567 {
568 public:
569
570 CIMConstClass() : _rep(0)
571 {
572 }
573
574 CIMConstClass(const CIMConstClass& x)
575 {
576 Inc(_rep = x._rep);
577 }
578 mike 1.25
579 CIMConstClass(const CIMClass& x)
580 {
581 Inc(_rep = x._rep);
582 }
583
|
584 mike 1.27 PEGASUS_EXPLICIT CIMConstClass(const CIMObject& x);
585
586 PEGASUS_EXPLICIT CIMConstClass(const CIMConstObject& x);
587
588 PEGASUS_EXPLICIT CIMConstClass(const CIMObject& x, NoThrow&);
589
590 PEGASUS_EXPLICIT CIMConstClass(const CIMConstObject& x, NoThrow&);
591
|
592 mike 1.25 CIMConstClass& operator=(const CIMConstClass& x)
593 {
594 if (x._rep != _rep)
595 {
596 Dec(_rep);
597 Inc(_rep = x._rep);
598 }
599 return *this;
600 }
601
602 CIMConstClass& operator=(const CIMClass& x)
603 {
604 if (x._rep != _rep)
605 {
606 Dec(_rep);
607 Inc(_rep = x._rep);
608 }
609 return *this;
610 }
611
612 // Throws IllegalName if className argument not legal CIM identifier.
613 mike 1.25
614 CIMConstClass(
|
615 chip 1.29 const CIMReference& reference,
|
616 mike 1.25 const String& superClassName = String())
617 {
|
618 chip 1.29 _rep = new CIMClassRep(reference, superClassName);
|
619 mike 1.25 }
620
621 ~CIMConstClass()
622 {
623 Dec(_rep);
624 }
625
626 Boolean isAssociation() const
627 {
628 _checkRep();
629 return _rep->isAssociation();
630 }
631
632 Boolean isAbstract() const
633 {
634 _checkRep();
635 return _rep->isAbstract();
636 }
637
638 const String& getClassName() const
639 {
640 mike 1.25 _checkRep();
641 return _rep->getClassName();
|
642 chip 1.29 }
643
644 const CIMReference& getPath() const
645 {
646 _checkRep();
647 return _rep->getPath();
|
648 mike 1.25 }
649
650 const String& getSuperClassName() const
651 {
652 _checkRep();
653 return _rep->getSuperClassName();
654 }
655
656 Uint32 findQualifier(const String& name) const
657 {
658 _checkRep();
659 return _rep->findQualifier(name);
660 }
661
662 CIMConstQualifier getQualifier(Uint32 pos) const
663 {
664 _checkRep();
665 return _rep->getQualifier(pos);
666 }
667
668 Uint32 getQualifierCount() const
669 mike 1.25 {
670 _checkRep();
671 return _rep->getQualifierCount();
672 }
673
674 Uint32 findProperty(const String& name) const
675 {
676 _checkRep();
677 return _rep->findProperty(name);
678 }
679
680 CIMConstProperty getProperty(Uint32 pos) const
681 {
682 _checkRep();
683 return _rep->getProperty(pos);
684 }
685
686 Uint32 getPropertyCount() const
687 {
688 _checkRep();
689 return _rep->getPropertyCount();
690 mike 1.25 }
691
692 Uint32 findMethod(const String& name) const
693 {
694 _checkRep();
695 return _rep->findMethod(name);
696 }
697
698 CIMConstMethod getMethod(Uint32 pos) const
699 {
700 _checkRep();
701 return _rep->getMethod(pos);
702 }
703
704 Uint32 getMethodCount() const
705 {
706 _checkRep();
707 return _rep->getMethodCount();
708 }
709
710 operator int() const { return _rep != 0; }
711 mike 1.25
712 void toXml(Array<Sint8>& out) const
713 {
714 _checkRep();
715 _rep->toXml(out);
716 }
717
718 void print(PEGASUS_STD(ostream) &o=PEGASUS_STD(cout)) const
719 {
720 _checkRep();
721 _rep->print(o);
722 }
723
724 Boolean identical(const CIMConstClass& x) const
725 {
726 x._checkRep();
727 _checkRep();
728 return _rep->identical(x._rep);
729 }
730
731 CIMClass clone() const
732 mike 1.25 {
|
733 mike 1.27 return CIMClass((CIMClassRep*)(_rep->clone()));
|
734 mike 1.25 }
735
736 void getKeyNames(Array<String>& keyNames) const
737 {
738 _checkRep();
739 _rep->getKeyNames(keyNames);
740 }
741
742 Boolean hasKeys() const
743 {
744 _checkRep();
745 return _rep->hasKeys();
746 }
747
748 private:
749
750 void _checkRep() const
751 {
752 if (!_rep)
753 ThrowUnitializedHandle();
754 }
755 mike 1.25
756 CIMClassRep* _rep;
757
758 friend class CIMClassRep;
759 friend class CIMClass;
760 friend class CIMInstanceRep;
|
761 mike 1.27 friend class CIMObject;
762 friend class CIMConstObject;
|
763 mike 1.25 };
764
765 PEGASUS_NAMESPACE_END
766
767 #endif /* Pegasus_CIMClass_h */
|