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