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 karl 1.31 @param className CIMReference representing name of the class being created
|
97 mike 1.25 @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 karl 1.31 /** isTrueQualifier - Determines if the qualifier defined by
233 the input parameter exists for the class, is Boolean, and
234 has a value of true.
235 This function is useful to quickly determine the state of a
236 qualifier.
237 @param String containing the qualifier name.
238 @return Boolean True if the qualifier exists,
239 */
240 Boolean isTrueQualifier(const String& name) const
241 {
242 _checkRep();
243 return _rep->isTrueQualifier(name);
244 }
245
246 /** getQualifier - Gets the CIMQualifier object defined
|
247 mike 1.25 by the input parameter
248 @param pos defines the position of the qualifier in the class from the
249 findQualifier method
|
250 mike 1.28 @return CIMQualifier object representing the qualifier found. On error,
251 CIMQualifier handle will be null.
|
252 mike 1.25 */
253 CIMQualifier getQualifier(Uint32 pos)
254 {
255 _checkRep();
256 return _rep->getQualifier(pos);
257 }
258
|
259 karl 1.31 /** getQualifier - Gets the qualifier defined by the input parameter
260 from the qualifier list for this CIMClass.
261 */
|
262 mike 1.25 CIMConstQualifier getQualifier(Uint32 pos) const
263 {
264 _checkRep();
265 return _rep->getQualifier(pos);
266 }
267
268 /** removeQualifier - Removes the qualifier defined by the
269 index parameter.
270 @param Defines the index of the qualifier to be removed.
271 @return There is no return.
272 @exception Throw OutOfBound exception if the index is outside
273 the range of existing qualifier objects for this class
274 */
275 void removeQualifier(Uint32 pos) const
276 {
277 _checkRep();
278 _rep->removeQualifier(pos);
279 }
280
281 /** getQualifierCount - Returns the number of qualifiers
282 in the class.
283 mike 1.25 @return ATTN:
284 */
285 Uint32 getQualifierCount() const
286 {
287 _checkRep();
288 return _rep->getQualifierCount();
289 }
290
291 /** addProperty - Adds the specified property object to the
292 properties in the CIM class
293 */
294 CIMClass& addProperty(const CIMProperty& x)
295 {
296 _checkRep();
297 _rep->addProperty(x);
298 return *this;
299 }
300
|
301 mike 1.26 /** findProperty - Finds the property object with the
|
302 mike 1.25 name defined by the input parameter in the class.
303 @param String parameter with the property name.
304 @return position representing the property object found or
305 PEG_NOT_FOUND if the property is not found.
306 */
307 Uint32 findProperty(const String& name)
308 {
309 _checkRep();
310 return _rep->findProperty(name);
311 }
312
313 Uint32 findProperty(const String& name) const
314 {
315 _checkRep();
316 return _rep->findProperty(name);
317 }
318
319 /** existsPropery - Determines if a property object with the
320 name defined by the input parameter exists in the class.
321 @parm String parameter with the property name.
322 @return True if the property object exists.
323 mike 1.25 */
324 Boolean existsProperty(const String& name)
325 {
326 _checkRep();
327 return _rep->existsProperty(name);
328 }
|
329 chip 1.29
330 Boolean existsProperty(const String& name) const
|
331 mike 1.25 {
332 _checkRep();
333 return _rep->existsProperty(name);
334 }
335
336 /** getProperty - Returns a property representing the property
337 defined by the input parameter
338 @param position for this property
339 ATTN: Should we not use something like handle for position???
340 @return CIMProperty object
341 ATTN: what is error return?
342 */
343 CIMProperty getProperty(Uint32 pos)
344 {
345 _checkRep();
346 return _rep->getProperty(pos);
347 }
348
349 /**getProperty Gets a property object from the CIMClass
350 @param pos The index of the property object to get.
351 @return Returns handle of the property object requested
352 mike 1.25 @exception Throws OutofBounds if the size field is greather than the
353 bunber of properties in the class.
354 */
355 CIMConstProperty getProperty(Uint32 pos) const
356 {
357 _checkRep();
358 return _rep->getProperty(pos);
359 }
360
361 /** removeProperty - Removes the property represented
362 by the position input parameter from the class
363 @param pos Index to the property to be removed from the
364 findPropety method
365 @exception Throws OutofBounds if index is not a property object
366 */
367 void removeProperty(Uint32 pos)
368 {
369 _checkRep();
370 _rep->removeProperty(pos);
371 }
372
373 mike 1.25 /** getPropertyCount - Gets the count of the number of properties
374 defined in the class.
375 @return count of number of proerties in the class
376 */
377 Uint32 getPropertyCount() const
378 {
379 _checkRep();
380 return _rep->getPropertyCount();
381 }
382
383 /** addMethod - Adds the method object defined by the input
384 parameter to the class and increments the count of the number of
385 methods in the class
386 @param method object representing the method to be added
387 @return Returns the CIMClass object to which the method was added.
388 @exception Throws AlreadyExists if the method already exists and throws
389 UnitializedHandle if the handle is not initialized
390 */
391 CIMClass& addMethod(const CIMMethod& x)
392 {
393 _checkRep();
394 mike 1.25 _rep->addMethod(x);
395 return *this;
396 }
397
398 /** findMethod - Locate the method object defined by the
399 name input
400 @param String representing the name of the method to be found
401 @return Position of the method object in the class to be used in
402 subsequent getmethod, etc. operations
403 */
404 Uint32 findMethod(const String& name)
405 {
406 _checkRep();
407 return _rep->findMethod(name);
408 }
409
410 Uint32 findMethod(const String& name) const
411 {
412 _checkRep();
413 return _rep->findMethod(name);
414 }
415 mike 1.25
416 /** existsMethod - Determine if the method object defined by the
417 name input exists
418 @param String representing the name of the method to be found
419 @return True if the method exists
420 */
421 Boolean existsMethod(const String& name)
422 {
423 _checkRep();
424 return _rep->existsMethod(name);
425 }
426
427 Boolean existsMethod(const String& name) const
428 {
429 _checkRep();
430 return _rep->existsMethod(name);
431 }
432
433 /** getMethod - Gets the method object defined by the
434 input parameter.
|
435 mike 1.26 @param pos Index to the method object to get
436 @return Returns handle of the method requested
|
437 mike 1.25 @exception Throws OutofBounds if the index represented by pos is greater
438 than the number of methods defined in the class object
439 */
440 CIMMethod getMethod(Uint32 pos)
441 {
442 _checkRep();
443 return _rep->getMethod(pos);
444 }
445
446 /** getMethod Gets the method object defined by the input
447 parameter. This is the const version.
448 */
449
450 CIMConstMethod getMethod(Uint32 pos) const
451 {
452 _checkRep();
453 return _rep->getMethod(pos);
454 }
455
456 /** removeMethod - Removes the method defined by the
457 index parameter.
458 mike 1.25 @param Defines the index of the method to be removed.
459 @return There is no return.
460 @exception Throw OutOfBound exception if the index is outside
461 the range of existing method objects for this class
462 */
463 void removeMethod(Uint32 pos) const
464 {
465 _checkRep();
466 _rep->removeMethod(pos);
467 }
468
|
469 mike 1.26 /** getMethodCount - Count of the number of methods in the class
|
470 mike 1.25 @return integer representing the number of methods in the class object.
471 */
472 Uint32 getMethodCount() const
473 {
474 _checkRep();
475 return _rep->getMethodCount();
476 }
477
478 /** Resolve - Resolve the class: inherit any properties and
479 qualifiers. Make sure the superClass really exists and is consistent
480 with this class. Also set the propagated flag class-origin for each
481 class feature.
482 ATTN: explain why this here
483 */
484 void resolve(
485 DeclContext* declContext,
486 const String& nameSpace)
487 {
488 _checkRep();
489 _rep->resolve(declContext, nameSpace);
490 }
491 mike 1.25
492 /// operator - ATTN:
493 operator int() const { return _rep != 0; }
494
|
495 mike 1.26 /** toXML - prepares an XML representation of the CIMClass object
496 in the provided Sint8 variable.
497 @param out Sint8 array for the XML representation
498 */
|
499 mike 1.25 void toXml(Array<Sint8>& out) const
500 {
501 _checkRep();
502 _rep->toXml(out);
503 }
504
|
505 mike 1.26 /** print - Prints the toXML output to cout
506 */
|
507 mike 1.25 void print(PEGASUS_STD(ostream) &o=PEGASUS_STD(cout)) const
508 {
509 _checkRep();
510 _rep->print(o);
511 }
512
|
513 mike 1.26 /** toMof - prepares a MOF representation of the CIMClass object
514 in the provided Sint8 variable.
515 @param out Sint8 array for the XML representation
516 */
517 void toMof(Array<Sint8>& out) const
518 {
519 _checkRep();
520 _rep->toMof(out);
521 }
522 /** printMof - Prints the toMof output to cout
523 */
524 void printMof(PEGASUS_STD(ostream) &o=PEGASUS_STD(cout)) const
525 {
526 _checkRep();
527 _rep->printMof(o);
528 }
529
530 /** identical - Compares with another class
|
531 mike 1.25 ATTN: Clarify exactly what identical means
532 @param Class object for the class to be compared
533 @return True if the classes are identical
534 */
535 Boolean identical(const CIMConstClass& x) const;
536
537 /** Makes a deep copy (clone) of the given object. */
538 CIMClass clone() const
539 {
|
540 mike 1.27 return CIMClass((CIMClassRep*)(_rep->clone()));
|
541 mike 1.25 }
542
543 /** Get names of all keys of this class. */
544 void getKeyNames(Array<String>& keyNames) const
545 {
546 _checkRep();
547 _rep->getKeyNames(keyNames);
548 }
549
550 Boolean hasKeys() const
551 {
552 _checkRep();
553 return _rep->hasKeys();
554 }
555
556 private:
557
558 CIMClass(CIMClassRep* rep) : _rep(rep)
559 {
560 }
561
562 mike 1.25 void _checkRep() const
563 {
564 if (!_rep)
565 ThrowUnitializedHandle();
566 }
567
568 CIMClassRep* _rep;
569 friend class CIMConstClass;
570 friend class CIMObject;
|
571 mike 1.27 friend class CIMConstObject;
|
572 mike 1.25 };
573
574 #define PEGASUS_ARRAY_T CIMClass
575 # include "ArrayInter.h"
576 #undef PEGASUS_ARRAY_T
577
578 /** CIMConstClass - ATTN: define this.
579
580 */
581 class PEGASUS_COMMON_LINKAGE CIMConstClass
582 {
583 public:
584
585 CIMConstClass() : _rep(0)
586 {
587 }
588
589 CIMConstClass(const CIMConstClass& x)
590 {
591 Inc(_rep = x._rep);
592 }
593 mike 1.25
594 CIMConstClass(const CIMClass& x)
595 {
596 Inc(_rep = x._rep);
597 }
598
|
599 mike 1.27 PEGASUS_EXPLICIT CIMConstClass(const CIMObject& x);
600
601 PEGASUS_EXPLICIT CIMConstClass(const CIMConstObject& x);
602
603 PEGASUS_EXPLICIT CIMConstClass(const CIMObject& x, NoThrow&);
604
605 PEGASUS_EXPLICIT CIMConstClass(const CIMConstObject& x, NoThrow&);
606
|
607 mike 1.25 CIMConstClass& operator=(const CIMConstClass& x)
608 {
609 if (x._rep != _rep)
610 {
611 Dec(_rep);
612 Inc(_rep = x._rep);
613 }
614 return *this;
615 }
616
617 CIMConstClass& operator=(const CIMClass& x)
618 {
619 if (x._rep != _rep)
620 {
621 Dec(_rep);
622 Inc(_rep = x._rep);
623 }
624 return *this;
625 }
626
627 // Throws IllegalName if className argument not legal CIM identifier.
628 mike 1.25
629 CIMConstClass(
|
630 chip 1.29 const CIMReference& reference,
|
631 mike 1.25 const String& superClassName = String())
632 {
|
633 chip 1.29 _rep = new CIMClassRep(reference, superClassName);
|
634 mike 1.25 }
635
636 ~CIMConstClass()
637 {
638 Dec(_rep);
639 }
640
641 Boolean isAssociation() const
642 {
643 _checkRep();
644 return _rep->isAssociation();
645 }
646
647 Boolean isAbstract() const
648 {
649 _checkRep();
650 return _rep->isAbstract();
651 }
652
653 const String& getClassName() const
654 {
655 mike 1.25 _checkRep();
656 return _rep->getClassName();
|
657 chip 1.29 }
658
659 const CIMReference& getPath() const
660 {
661 _checkRep();
662 return _rep->getPath();
|
663 mike 1.25 }
664
665 const String& getSuperClassName() const
666 {
667 _checkRep();
668 return _rep->getSuperClassName();
669 }
670
671 Uint32 findQualifier(const String& name) const
672 {
673 _checkRep();
674 return _rep->findQualifier(name);
675 }
676
677 CIMConstQualifier getQualifier(Uint32 pos) const
678 {
679 _checkRep();
680 return _rep->getQualifier(pos);
|
681 karl 1.31 }
682
683 Boolean isTrueQualifier(const String& name) const
684 {
685 _checkRep();
686 return _rep->isTrueQualifier(name);
|
687 mike 1.25 }
688
689 Uint32 getQualifierCount() const
690 {
691 _checkRep();
692 return _rep->getQualifierCount();
693 }
694
695 Uint32 findProperty(const String& name) const
696 {
697 _checkRep();
698 return _rep->findProperty(name);
699 }
700
701 CIMConstProperty getProperty(Uint32 pos) const
702 {
703 _checkRep();
704 return _rep->getProperty(pos);
705 }
706
707 Uint32 getPropertyCount() const
708 mike 1.25 {
709 _checkRep();
710 return _rep->getPropertyCount();
711 }
712
713 Uint32 findMethod(const String& name) const
714 {
715 _checkRep();
716 return _rep->findMethod(name);
717 }
718
719 CIMConstMethod getMethod(Uint32 pos) const
720 {
721 _checkRep();
722 return _rep->getMethod(pos);
723 }
724
725 Uint32 getMethodCount() const
726 {
727 _checkRep();
728 return _rep->getMethodCount();
729 mike 1.25 }
730
731 operator int() const { return _rep != 0; }
732
733 void toXml(Array<Sint8>& out) const
734 {
735 _checkRep();
736 _rep->toXml(out);
737 }
738
739 void print(PEGASUS_STD(ostream) &o=PEGASUS_STD(cout)) const
740 {
741 _checkRep();
742 _rep->print(o);
743 }
744
745 Boolean identical(const CIMConstClass& x) const
746 {
747 x._checkRep();
748 _checkRep();
749 return _rep->identical(x._rep);
750 mike 1.25 }
751
752 CIMClass clone() const
753 {
|
754 mike 1.27 return CIMClass((CIMClassRep*)(_rep->clone()));
|
755 mike 1.25 }
756
757 void getKeyNames(Array<String>& keyNames) const
758 {
759 _checkRep();
760 _rep->getKeyNames(keyNames);
761 }
762
763 Boolean hasKeys() const
764 {
765 _checkRep();
766 return _rep->hasKeys();
767 }
768
769 private:
770
771 void _checkRep() const
772 {
773 if (!_rep)
774 ThrowUnitializedHandle();
775 }
776 mike 1.25
777 CIMClassRep* _rep;
778
779 friend class CIMClassRep;
780 friend class CIMClass;
781 friend class CIMInstanceRep;
|
782 mike 1.27 friend class CIMObject;
783 friend class CIMConstObject;
|
784 mike 1.25 };
785
786 PEGASUS_NAMESPACE_END
787
788 #endif /* Pegasus_CIMClass_h */
|