1 mike 1.1 //BEGIN_LICENSE
2 //
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 //END_LICENSE
21 //BEGIN_HISTORY
22 mike 1.1 //
23 // Author:
24 //
25 // $Log: CIMClass.h,v $
|
26 bob 1.5 // Revision 1.4 2001/02/26 10:13:24 karl
27 // documentation changes
28 //
|
29 karl 1.4 // Revision 1.3 2001/02/20 05:16:57 mike
30 // Implemented CIMInstance::getInstanceName()
31 //
|
32 mike 1.3 // Revision 1.2 2001/02/19 01:47:16 mike
33 // Renamed names of the form CIMConst to ConstCIM.
34 //
|
35 mike 1.2 // Revision 1.1 2001/02/18 18:39:05 mike
36 // new
37 //
|
38 mike 1.1 // Revision 1.2 2001/02/18 03:56:00 mike
|
39 mike 1.2 // Changed more class names (e.g., ConstClassDecl -> ConstCIMClass)
|
40 mike 1.1 //
41 // Revision 1.1 2001/02/16 02:06:06 mike
42 // Renamed many classes and headers.
43 //
44 // Revision 1.5 2001/01/30 23:39:00 karl
45 // Add doc++ Documentation to header files
46 //
47 // Revision 1.4 2001/01/28 18:48:07 mike
48 // fixed typo in comment
49 //
50 // Revision 1.3 2001/01/28 18:46:50 mike
51 // more docs
52 //
53 // Revision 1.2 2001/01/15 04:31:43 mike
54 // worked on resolve scheme
55 //
56 // Revision 1.1.1.1 2001/01/14 19:50:37 mike
57 // Pegasus import
58 //
59 //
60 //END_HISTORY
61 mike 1.1
62 #ifndef Pegasus_ClassDecl_h
63 #define Pegasus_ClassDecl_h
64
65 #include <Pegasus/Common/Config.h>
66 #include <Pegasus/Common/CIMClassRep.h>
67
68 PEGASUS_NAMESPACE_BEGIN
69
|
70 mike 1.2 class ConstCIMClass;
|
71 mike 1.1
|
72 karl 1.4 /** The CIMClass class is used to represent CIM classes in Pegasus. In CIM,
73 a class object may be a class or an associator. A CIM class must contain a
74 name and may contain methods, properties, and qualifiers. It is a template
75 for creating a CIM instance. A CIM class represents a collection of CIM
76 instances, all of which support a common type (for example, a set of
77 properties, methods, and associations).
|
78 mike 1.1 */
79
80 class PEGASUS_COMMON_LINKAGE CIMClass
81 {
82 public:
83
84 /** Constructor - Creates and instantiates a new object reprenting a CIM
|
85 karl 1.4 class. If you use this constructor, use setName to define a name for
|
86 mike 1.1 the class
87 */
88 CIMClass() : _rep(0)
89 {
90
91 }
92
93 /// Constructor - Creates a class from a previous class
94 CIMClass(const CIMClass& x)
95 {
96 Inc(_rep = x._rep);
97 }
98
99 /// Operator = ATTN:
100 CIMClass& operator=(const CIMClass& x)
101 {
102 if (x._rep != _rep)
103 {
104 Dec(_rep);
105 Inc(_rep = x._rep);
106 }
107 mike 1.1 return *this;
108 }
109
|
110 karl 1.4 /** Constructor - Creates a Class from inputs of a classname and
|
111 mike 1.3 SuperClassName
|
112 karl 1.4 @param className - String representing name of the class being created
|
113 mike 1.3 @param superClassName - String representing name of the SuperClass
114 ATTN: Define what makes up legal name.
115 @return Throws IllegalName if className argument illegal CIM identifier.
|
116 mike 1.1 */
117 CIMClass(
|
118 karl 1.4 const String& className,
|
119 mike 1.1 const String& superClassName = String())
120 {
121 _rep = new CIMClassRep(className, superClassName);
122 }
|
123 mike 1.3
|
124 mike 1.1 /// Destructor
125 ~CIMClass()
126 {
127 Dec(_rep);
128 }
|
129 mike 1.3
|
130 karl 1.4 /** CIMMethod isAssociation - Identifies whether or not this CIM class
131 is an association. An association is a relationship between two
132 (or more) classes or instances of two classes. The properties of an
133 association class include pointers, or references, to the two (or
134 more) instances. All CIM classes can be included in one or more
|
135 mike 1.3 associations. ATTN: Move the association definition elsewhere
|
136 karl 1.4 @return Boolean True if this CIM class belongs to an association;
137 otherwise, false.
138 */
|
139 mike 1.1 Boolean isAssociation() const
140 {
141 _checkRep();
142 return _rep->isAssociation();
143 }
|
144 mike 1.3
|
145 mike 1.1 /// CIMMethod isAbstract
146 Boolean isAbstract() const
147 {
148 _checkRep();
149 return _rep->isAbstract();
150 }
|
151 mike 1.3
|
152 mike 1.1 /** CIMMethod Gets the name of the class
|
153 mike 1.3 ATTN: COMMENT. Why not just get name so we have common method for all.
|
154 mike 1.1 */
|
155 karl 1.4 const String& getClassName() const
|
156 mike 1.3 {
|
157 mike 1.1 _checkRep();
|
158 karl 1.4 return _rep->getClassName();
|
159 mike 1.1 }
|
160 mike 1.3
|
161 mike 1.1 /** CIMMethod getSuperClassName - Gets the name of the Parent
|
162 mike 1.3 @return String with parent class name.
|
163 mike 1.1 */
|
164 karl 1.4 const String& getSuperClassName() const
|
165 mike 1.3 {
|
166 mike 1.1 _checkRep();
|
167 karl 1.4 return _rep->getSuperClassName();
|
168 mike 1.1 }
|
169 mike 1.3
|
170 mike 1.1 /** CIMMethod setSuperClassName - Sets the name of the parent class from
|
171 mike 1.3 the input parameter. \REF{CLASSNAME}. ATTN: Define legal classnames
172 @param - String defining parent name.
|
173 karl 1.4 @return Throws IllegalName if superClassName argument not legal CIM
174 identifier.
|
175 mike 1.3 */
|
176 mike 1.1 void setSuperClassName(const String& superClassName)
177 {
178 _checkRep();
179 _rep->setSuperClassName(superClassName);
180 }
|
181 mike 1.3
|
182 mike 1.1 /** CIMMethod addQualifier - Adds the specified qualifier to the class
|
183 mike 1.3 and increments the qualifier count. It is illegal to add the same
184 qualifier more than one time.
185 @param - CIMQualifier object representing the qualifier to be added
186 ATTN: Pointer to qualifier object.
187 @return Throws AlreadyExists.
|
188 mike 1.1 */
189 CIMClass& addQualifier(const CIMQualifier& qualifier)
190 {
191 _checkRep();
192 _rep->addQualifier(qualifier);
193 return *this;
194 }
|
195 mike 1.3
|
196 karl 1.4 /** CIMMethod findQualifier - Finds a qualifier with the specified input
197 name if it exists in the class @param name CIMName of the qualifier
198 to be found @return Position of the qualifier in the Class ATTN:
|
199 mike 1.3 Clarify the return. What if not found, etc.
|
200 mike 1.1 */
201 Uint32 findQualifier(const String& name)
202 {
203 _checkRep();
204 return _rep->findQualifier(name);
205 }
|
206 mike 1.3
|
207 mike 1.1 /** CIMMethod FindQualifier - ATTN:
|
208 mike 1.3 @param name of the qualifier to be found
209 @return ATTN: Define this
|
210 mike 1.1 */
211 Uint32 findQualifier(const String& name) const
212 {
213 _checkRep();
214 return _rep->findQualifier(name);
215 }
|
216 mike 1.3
|
217 mike 1.1 /** CIMMethod getQualifier - Gets the CIMQualifier object defined
|
218 mike 1.3 by the input parameter
219 @param pos defines the position of the qualifier in the class from the
220 findQualifier method
221 @return CIMQualifier object representing the qualifier found.
222 ATTN: what is error return here?
|
223 mike 1.1 */
224 CIMQualifier getQualifier(Uint32 pos)
225 {
226 _checkRep();
227 return _rep->getQualifier(pos);
228 }
|
229 mike 1.3
|
230 mike 1.1 /// CIMMethod getQualifier - ATTN:
231 CIMConstQualifier getQualifier(Uint32 pos) const
232 {
233 _checkRep();
234 return _rep->getQualifier(pos);
235 }
|
236 mike 1.3
|
237 mike 1.1 /** CIMMethod getQualifierCount - Returns the number of qualifiers
|
238 karl 1.4 in the class.
|
239 mike 1.3 @return ATTN:
|
240 mike 1.1 */
241 Uint32 getQualifierCount() const
242 {
243 _checkRep();
244 return _rep->getQualifierCount();
245 }
|
246 mike 1.3
|
247 mike 1.1 /** CIMMethod addProperty - Adds the specified property object to the
|
248 mike 1.3 properties in the CIM class
|
249 mike 1.1 */
250 CIMClass& addProperty(const CIMProperty& x)
251 {
252 _checkRep();
253 _rep->addProperty(x);
254 return *this;
255 }
|
256 mike 1.3
|
257 mike 1.1 /** CIMMethod removeProperty - Removes the property represented
|
258 mike 1.3 by the position input parameter from the class
|
259 karl 1.4 @param position parameter for the property to be removed from the
|
260 mike 1.3 findPropety method
261 @return ATTN:
|
262 mike 1.1 */
263 void removeProperty(Uint32 pos)
264 {
265 _checkRep();
266 _rep->removeProperty(pos);
267 }
|
268 mike 1.3
|
269 mike 1.1 /** CIMMethod findProperty - Finds the property object with the
|
270 mike 1.3 name defined by the input parameter in the class.
271 @param String parameter with the property name.
272 @return position representing the property object found.
273 ATTN: Clarify case of not found
|
274 mike 1.1 */
275 Uint32 findProperty(const String& name)
276 {
277 _checkRep();
278 return _rep->findProperty(name);
279 }
|
280 mike 1.3
|
281 mike 1.1 /// CIMMethod findProperty
282 Uint32 findProperty(const String& name) const
283 {
284 _checkRep();
285 return _rep->findProperty(name);
286 }
|
287 mike 1.3
|
288 karl 1.4 /** CIMMethod getProperty - Returns a property representing the property
|
289 mike 1.3 defined by the input parameter
290 @param position for this property
291 ATTN: Should we not use something like handle for position???
292 @return CIMProperty object
293 ATTN: what is error return?
|
294 mike 1.1 */
295 CIMProperty getProperty(Uint32 pos)
296 {
297 _checkRep();
298 return _rep->getProperty(pos);
299 }
|
300 mike 1.3
|
301 mike 1.1 /// CIMMethod getProperty - ATTN
|
302 mike 1.3 ConstCIMProperty getProperty(Uint32 pos) const
|
303 mike 1.1 {
304 _checkRep();
305 return _rep->getProperty(pos);
306 }
|
307 mike 1.3
|
308 mike 1.1 /** CIMMethod getProperty - Gets the count of the number of properties
|
309 mike 1.3 defined in the class.
310 @return count of number of proerties in the class
|
311 mike 1.1 */
312 Uint32 getPropertyCount() const
313 {
314 _checkRep();
315 return _rep->getPropertyCount();
316 }
|
317 mike 1.3
|
318 karl 1.4 /** CIMMethod addMethod - Adds the method object defined by the input
319 parameter to the class and increments the count of the number of
|
320 mike 1.3 methods in the class
|
321 karl 1.4 @param - method object representing the method to be added
|
322 mike 1.1 */
323 CIMClass& addMethod(const CIMMethod& x)
324 {
325 _checkRep();
326 _rep->addMethod(x);
327 return *this;
328 }
|
329 mike 1.3
|
330 mike 1.1 /** CIMMethod findMethod - Located the method object defined by the
|
331 mike 1.3 name input
332 @param String representing the name of the method to be found
|
333 karl 1.4 @return Position of the method object in the class to be used in
|
334 mike 1.3 subsequent getmethod, etc. operations
|
335 mike 1.1 */
336 Uint32 findMethod(const String& name)
337 {
338 _checkRep();
339 return _rep->findMethod(name);
340 }
|
341 mike 1.3
|
342 mike 1.1 /// CIMMethod findMethod - ATTN:
343 Uint32 findMethod(const String& name) const
344 {
345 _checkRep();
346 return _rep->findMethod(name);
347 }
|
348 mike 1.3
|
349 mike 1.1 /** CIMMethod getMethod - Gets the method object defined by the
|
350 mike 1.3 input parameter.
351 @param ATTN:
|
352 karl 1.4 @ method object representing the method defined
|
353 mike 1.3 ATTN: Error???
|
354 mike 1.1 */
355 CIMMethod getMethod(Uint32 pos)
356 {
357 _checkRep();
358 return _rep->getMethod(pos);
359 }
|
360 mike 1.3
|
361 mike 1.1 /// CIMMethod getMethod - ATTN:
362 CIMConstMethod getMethod(Uint32 pos) const
363 {
364 _checkRep();
365 return _rep->getMethod(pos);
366 }
|
367 mike 1.3
|
368 mike 1.1 /** CIMMethod getMethodCount - Count of the number of methods in the class
|
369 mike 1.3 @return integer representing the number of methods in the class
|
370 mike 1.1 */
371 Uint32 getMethodCount() const
372 {
373 _checkRep();
374 return _rep->getMethodCount();
375 }
|
376 karl 1.4
377 /** CIMMethod Resolve - Resolve the class: inherit any properties and
378 qualifiers. Make sure the superClass really exists and is consistent
|
379 mike 1.3 with this class. Also set the propagated flag class-origin for each
380 class feature.
381 ATTN: explain why this here
|
382 mike 1.1 */
383 void resolve(
384 DeclContext* declContext,
385 const String& nameSpace)
386 {
387 _checkRep();
388 _rep->resolve(declContext, nameSpace);
389 }
|
390 mike 1.3
|
391 mike 1.1 /// operator - ATTN:
392 operator int() const { return _rep != 0; }
|
393 mike 1.3
|
394 karl 1.4 /// CIMMethod toXML
|
395 mike 1.1 void toXml(Array<Sint8>& out) const
396 {
397 _checkRep();
398 _rep->toXml(out);
399 }
|
400 mike 1.3
|
401 bob 1.5 /// CIMMethod print
402 void print(std::ostream &o=std::cout) const
|
403 mike 1.1 {
404 _checkRep();
|
405 bob 1.5 _rep->print(o);
|
406 mike 1.1 }
|
407 mike 1.3
|
408 mike 1.1 /** CIMMethod identical - Compares with another class
|
409 mike 1.3 ATTN: Clarify exactly what identical means
410 @parm Class object for the class to be compared
411 @return True if the classes are identical
|
412 mike 1.1 */
|
413 mike 1.2 Boolean identical(const ConstCIMClass& x) const;
|
414 mike 1.3
|
415 mike 1.1 /// CIMMethod clone - ATTN:
416 CIMClass clone() const
417 {
418 return CIMClass(_rep->clone());
419 }
420
|
421 mike 1.3 void getKeyNames(Array<String>& keyNames) const
422 {
423 _checkRep();
424 _rep->getKeyNames(keyNames);
425 }
426
|
427 mike 1.1 private:
428
429 CIMClass(CIMClassRep* rep) : _rep(rep)
430 {
431 }
432
433 void _checkRep() const
434 {
435 if (!_rep)
436 throw UnitializedHandle();
437 }
438
439 CIMClassRep* _rep;
|
440 mike 1.2 friend class ConstCIMClass;
|
441 mike 1.1 };
442
|
443 karl 1.4 /** ConstCIMClass - ATTN: define this.
|
444 mike 1.3
445 */
|
446 mike 1.1
|
447 mike 1.2 class PEGASUS_COMMON_LINKAGE ConstCIMClass
|
448 mike 1.1 {
449 public:
450
|
451 mike 1.2 ConstCIMClass() : _rep(0)
|
452 mike 1.1 {
453
454 }
455
|
456 mike 1.2 ConstCIMClass(const ConstCIMClass& x)
|
457 mike 1.1 {
458 Inc(_rep = x._rep);
459 }
460
|
461 mike 1.2 ConstCIMClass(const CIMClass& x)
|
462 mike 1.1 {
463 Inc(_rep = x._rep);
464 }
465
|
466 mike 1.2 ConstCIMClass& operator=(const ConstCIMClass& x)
|
467 mike 1.1 {
468 if (x._rep != _rep)
469 {
470 Dec(_rep);
471 Inc(_rep = x._rep);
472 }
473 return *this;
474 }
475
|
476 mike 1.2 ConstCIMClass& operator=(const CIMClass& x)
|
477 mike 1.1 {
478 if (x._rep != _rep)
479 {
480 Dec(_rep);
481 Inc(_rep = x._rep);
482 }
483 return *this;
484 }
485
486 // Throws IllegalName if className argument not legal CIM identifier.
487
|
488 mike 1.2 ConstCIMClass(
|
489 karl 1.4 const String& className,
|
490 mike 1.1 const String& superClassName = String())
491 {
492 _rep = new CIMClassRep(className, superClassName);
493 }
494
|
495 mike 1.2 ~ConstCIMClass()
|
496 mike 1.1 {
497 Dec(_rep);
498 }
499
500 Boolean isAssociation() const
501 {
502 _checkRep();
503 return _rep->isAssociation();
504 }
505
506 Boolean isAbstract() const
507 {
508 _checkRep();
509 return _rep->isAbstract();
510 }
511
|
512 karl 1.4 const String& getClassName() const
513 {
|
514 mike 1.1 _checkRep();
|
515 karl 1.4 return _rep->getClassName();
|
516 mike 1.1 }
517
|
518 karl 1.4 const String& getSuperClassName() const
519 {
|
520 mike 1.1 _checkRep();
|
521 karl 1.4 return _rep->getSuperClassName();
|
522 mike 1.1 }
523
524 Uint32 findQualifier(const String& name) const
525 {
526 _checkRep();
527 return _rep->findQualifier(name);
528 }
529
530 CIMConstQualifier getQualifier(Uint32 pos) const
531 {
532 _checkRep();
533 return _rep->getQualifier(pos);
534 }
535
536 Uint32 getQualifierCount() const
537 {
538 _checkRep();
539 return _rep->getQualifierCount();
540 }
541
542 Uint32 findProperty(const String& name) const
543 mike 1.1 {
544 _checkRep();
545 return _rep->findProperty(name);
546 }
547
|
548 mike 1.3 ConstCIMProperty getProperty(Uint32 pos) const
|
549 mike 1.1 {
550 _checkRep();
551 return _rep->getProperty(pos);
552 }
553
554 Uint32 getPropertyCount() const
555 {
556 _checkRep();
557 return _rep->getPropertyCount();
558 }
559
560 Uint32 findMethod(const String& name) const
561 {
562 _checkRep();
563 return _rep->findMethod(name);
564 }
565
566 CIMConstMethod getMethod(Uint32 pos) const
567 {
568 _checkRep();
569 return _rep->getMethod(pos);
570 mike 1.1 }
571
572 Uint32 getMethodCount() const
573 {
574 _checkRep();
575 return _rep->getMethodCount();
576 }
577
578 operator int() const { return _rep != 0; }
579
580 void toXml(Array<Sint8>& out) const
581 {
582 _checkRep();
583 _rep->toXml(out);
584 }
585
|
586 bob 1.5 void print(std::ostream &o=std::cout) const
|
587 mike 1.1 {
588 _checkRep();
|
589 bob 1.5 _rep->print(o);
|
590 mike 1.1 }
591
|
592 mike 1.2 Boolean identical(const ConstCIMClass& x) const
|
593 mike 1.1 {
594 x._checkRep();
595 _checkRep();
596 return _rep->identical(x._rep);
597 }
598
599 CIMClass clone() const
600 {
601 return CIMClass(_rep->clone());
|
602 mike 1.3 }
603
604 void getKeyNames(Array<String>& keyNames) const
605 {
606 _checkRep();
607 _rep->getKeyNames(keyNames);
|
608 mike 1.1 }
609
610 private:
611
612 void _checkRep() const
613 {
614 if (!_rep)
615 throw UnitializedHandle();
616 }
617
618 CIMClassRep* _rep;
619
620 friend class CIMClassRep;
621 friend class CIMClass;
622 friend class CIMInstanceRep;
623 };
624
625 PEGASUS_NAMESPACE_END
626
627 #endif /* Pegasus_ClassDecl_h */
|