(file) Return to CIMClass.h CVS log (file) (dir) Up to [Pegasus] / pegasus / src / Pegasus / Common

  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.6     /** Constructor - Creates an uninitiated a new CIM object 
 51           	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           	
 56 karl  1.7 	Use one of the other constructors to create an initiated new CIM class 
 57 karl  1.6 	object.
 58 karl  1.7 	@exception Throws an exception "unitialized handle" if this 
 59           	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.4 	@param className - String representing name of the class being created
 88 mike  1.3 	@param superClassName - String representing name of the SuperClass
 89           	ATTN: Define what makes up legal name.
 90           	@return Throws IllegalName if className argument illegal CIM identifier.
 91 karl  1.7 	<pre>
 92           	    CIMClass NewCass("MyClass", "YourClass"); 
 93           	</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.4     /** CIMMethod isAssociation - Identifies whether or not this CIM class
110           	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 mike  1.3 	associations.  ATTN: Move the association definition elsewhere
115 karl  1.4 	@return  Boolean True if this CIM class belongs to an association;
116           	otherwise, false.
117               */
118 mike  1.1     Boolean isAssociation() const
119               {
120           	_checkRep();
121           	return _rep->isAssociation();
122               }
123 mike  1.3 
124 mike  1.1     ///	 CIMMethod isAbstract
125               Boolean isAbstract() const
126               {
127           	_checkRep();
128           	return _rep->isAbstract();
129               }
130 mike  1.3 
131 mike  1.1     /** CIMMethod Gets the name of the class
132 mike  1.3 	ATTN: COMMENT. Why not just get name so we have common method for all.
133 mike  1.1     */
134 karl  1.4     const String& getClassName() const
135 mike  1.3     {
136 mike  1.1 	_checkRep();
137 karl  1.4 	return _rep->getClassName();
138 mike  1.1     }
139 mike  1.3 
140 mike  1.1     /** CIMMethod getSuperClassName - Gets the name of the Parent
141 mike  1.3 	@return String with parent class name.
142 mike  1.1     */
143 karl  1.4     const String& getSuperClassName() const
144 mike  1.3     {
145 mike  1.1 	_checkRep();
146 karl  1.4 	return _rep->getSuperClassName();
147 mike  1.1     }
148 mike  1.3 
149 mike  1.1     /**	CIMMethod setSuperClassName - Sets the name of the parent class from
150 mike  1.3 	the input parameter. \REF{CLASSNAME}. ATTN: Define legal classnames
151           	@param - String defining parent name.
152 karl  1.4 	@return Throws IllegalName if superClassName argument not legal CIM
153           	identifier.
154 mike  1.3     */
155 mike  1.1     void setSuperClassName(const String& superClassName)
156               {
157           	_checkRep();
158           	_rep->setSuperClassName(superClassName);
159               }
160 mike  1.3 
161 mike  1.1     /** CIMMethod addQualifier - Adds the specified qualifier to the class
162 mike  1.3 	and increments the qualifier count. It is illegal to add the same
163           	qualifier more than one time.
164           	@param - CIMQualifier object representing the qualifier to be added
165           	ATTN: Pointer to qualifier object.
166           	@return Throws AlreadyExists.
167 mike  1.1     */
168               CIMClass& addQualifier(const CIMQualifier& qualifier)
169               {
170           	_checkRep();
171           	_rep->addQualifier(qualifier);
172           	return *this;
173               }
174 mike  1.3 
175 karl  1.4     /**	CIMMethod findQualifier - Finds a qualifier with the specified input
176           	name if it exists in the class @param name CIMName of the qualifier
177           	to be found @return Position of the qualifier in the Class ATTN:
178 mike  1.3 	Clarify the return.  What if not found, etc.
179 mike  1.1     */
180               Uint32 findQualifier(const String& name)
181               {
182           	_checkRep();
183           	return _rep->findQualifier(name);
184               }
185 mike  1.3 
186 mike  1.1     /** CIMMethod FindQualifier - ATTN:
187 mike  1.3 	@param name of the qualifier to be found
188           	@return ATTN: Define this
189 mike  1.1     */
190               Uint32 findQualifier(const String& name) const
191               {
192           	_checkRep();
193           	return _rep->findQualifier(name);
194               }
195 mike  1.3 
196 mike  1.1     /**	 CIMMethod getQualifier - Gets the CIMQualifier object defined
197 mike  1.3 	by the input parameter
198           	@param pos defines the position of the qualifier in the class from the
199           	findQualifier method
200           	@return CIMQualifier object representing the qualifier found.
201           	ATTN: what is error return here?
202 mike  1.1     */
203               CIMQualifier getQualifier(Uint32 pos)
204               {
205           	_checkRep();
206           	return _rep->getQualifier(pos);
207               }
208 mike  1.3 
209 mike  1.1     /// CIMMethod getQualifier - ATTN:
210               CIMConstQualifier getQualifier(Uint32 pos) const
211               {
212           	_checkRep();
213           	return _rep->getQualifier(pos);
214               }
215 mike  1.3 
216 mike  1.1     /** CIMMethod getQualifierCount - Returns the number of qualifiers
217 karl  1.4 	in the class.
218 mike  1.3 	@return ATTN:
219 mike  1.1     */
220               Uint32 getQualifierCount() const
221               {
222           	_checkRep();
223           	return _rep->getQualifierCount();
224               }
225 mike  1.3 
226 mike  1.1     /**	CIMMethod addProperty - Adds the specified property object to the
227 mike  1.3 	properties in the CIM class
228 mike  1.1     */
229               CIMClass& addProperty(const CIMProperty& x)
230               {
231           	_checkRep();
232           	_rep->addProperty(x);
233           	return *this;
234               }
235 mike  1.3 
236 mike  1.1     /** CIMMethod removeProperty - Removes the property represented
237 mike  1.3 	by the position input parameter from the class
238 karl  1.4 	@param position parameter for the property to be removed from the
239 mike  1.3 	findPropety method
240           	@return ATTN:
241 mike  1.1     */
242               void removeProperty(Uint32 pos)
243               {
244           	_checkRep();
245           	_rep->removeProperty(pos);
246               }
247 mike  1.3 
248 mike  1.1     /** CIMMethod findProperty - Finds the property object with the
249 mike  1.3 	name defined by the input parameter in the class.
250           	@param String parameter with the property name.
251           	@return position representing the property object found.
252           	ATTN:   Clarify case of not found
253 mike  1.1     */
254               Uint32 findProperty(const String& name)
255               {
256           	_checkRep();
257           	return _rep->findProperty(name);
258               }
259 mike  1.3 
260 mike  1.1     /// CIMMethod findProperty
261               Uint32 findProperty(const String& name) const
262               {
263           	_checkRep();
264           	return _rep->findProperty(name);
265               }
266 mike  1.3 
267 karl  1.4     /** CIMMethod getProperty - Returns a property representing the property
268 mike  1.3 	defined by the input parameter
269           	@param position for this property
270           	ATTN: Should we not use something like handle for position???
271           	@return CIMProperty object
272           	ATTN: what is error return?
273 mike  1.1     */
274               CIMProperty getProperty(Uint32 pos)
275               {
276           	_checkRep();
277           	return _rep->getProperty(pos);
278               }
279 mike  1.3 
280 mike  1.1     /// CIMMethod getProperty - ATTN
281 mike  1.8     CIMConstProperty getProperty(Uint32 pos) const
282 mike  1.1     {
283           	_checkRep();
284           	return _rep->getProperty(pos);
285               }
286 mike  1.3 
287 mike  1.1     /** CIMMethod getProperty -   Gets the count of the number of properties
288 mike  1.3 	defined in the class.
289           	@return count of number of proerties in the class
290 mike  1.1     */
291               Uint32 getPropertyCount() const
292               {
293           	_checkRep();
294           	return _rep->getPropertyCount();
295               }
296 mike  1.3 
297 karl  1.4     /** CIMMethod addMethod - Adds the method object defined by the input
298           	parameter to the class and increments the count of the number of
299 mike  1.3 	methods in the class
300 karl  1.4 	@param - method object representing the method to be added
301 mike  1.1     */
302               CIMClass& addMethod(const CIMMethod& x)
303               {
304           	_checkRep();
305           	_rep->addMethod(x);
306           	return *this;
307               }
308 mike  1.3 
309 mike  1.1     /** CIMMethod findMethod - Located the method object defined by the
310 mike  1.3 	name input
311           	@param String representing the name of the method to be found
312 karl  1.4 	@return Position of the method object in the class to be used in
313 mike  1.3 	subsequent getmethod, etc. operations
314 mike  1.1     */
315               Uint32 findMethod(const String& name)
316               {
317           	_checkRep();
318           	return _rep->findMethod(name);
319               }
320 mike  1.3 
321 mike  1.1     /// CIMMethod findMethod - ATTN:
322               Uint32 findMethod(const String& name) const
323               {
324           	_checkRep();
325           	return _rep->findMethod(name);
326               }
327 mike  1.3 
328 mike  1.1     /** CIMMethod getMethod - Gets the method object defined by the
329 mike  1.3 	input parameter.
330           	@param   ATTN:
331 karl  1.4 	@ method object representing the method defined
332 mike  1.3 	ATTN: Error???
333 mike  1.1     */
334               CIMMethod getMethod(Uint32 pos)
335               {
336           	_checkRep();
337           	return _rep->getMethod(pos);
338               }
339 mike  1.3 
340 mike  1.1     /// CIMMethod getMethod - ATTN:
341               CIMConstMethod getMethod(Uint32 pos) const
342               {
343           	_checkRep();
344           	return _rep->getMethod(pos);
345               }
346 mike  1.3 
347 mike  1.1     /** CIMMethod getMethodCount - Count of the number of methods in the class
348 mike  1.3 	@return integer representing the number of methods in the class
349 mike  1.1     */
350               Uint32 getMethodCount() const
351               {
352           	_checkRep();
353           	return _rep->getMethodCount();
354               }
355 karl  1.4 
356               /** CIMMethod Resolve -  Resolve the class: inherit any properties and
357           	qualifiers. Make sure the superClass really exists and is consistent
358 mike  1.3 	with this class. Also set the propagated flag class-origin for each
359           	class feature.
360           	ATTN: explain why this here
361 mike  1.1     */
362               void resolve(
363           	DeclContext* declContext,
364           	const String& nameSpace)
365               {
366           	_checkRep();
367           	_rep->resolve(declContext, nameSpace);
368               }
369 mike  1.3 
370 mike  1.1     /// operator - ATTN:
371               operator int() const { return _rep != 0; }
372 mike  1.3 
373 karl  1.4     /// CIMMethod toXML
374 mike  1.1     void toXml(Array<Sint8>& out) const
375               {
376           	_checkRep();
377           	_rep->toXml(out);
378               }
379 mike  1.3 
380 bob   1.5     /// CIMMethod print 
381               void print(std::ostream &o=std::cout) const
382 mike  1.1     {
383           	_checkRep();
384 bob   1.5 	_rep->print(o);
385 mike  1.1     }
386 mike  1.3 
387 mike  1.1     /** CIMMethod identical -  Compares with another class
388 mike  1.3 	ATTN: Clarify exactly what identical means
389           	@parm Class object for the class to be compared
390           	@return True if the classes are identical
391 mike  1.1     */
392 mike  1.8     Boolean identical(const CIMConstClass& x) const;
393 mike  1.3 
394 mike  1.1     /// CIMMethod clone - ATTN:
395               CIMClass clone() const
396               {
397           	return CIMClass(_rep->clone());
398               }
399           
400 mike  1.3     void getKeyNames(Array<String>& keyNames) const
401               {
402           	_checkRep();
403           	_rep->getKeyNames(keyNames);
404               }
405           
406 mike  1.1 private:
407           
408               CIMClass(CIMClassRep* rep) : _rep(rep)
409               {
410               }
411           
412               void _checkRep() const
413               {
414           	if (!_rep)
415           	    throw UnitializedHandle();
416               }
417           
418               CIMClassRep* _rep;
419 mike  1.8     friend class CIMConstClass;
420 mike  1.1 };
421           
422 mike  1.8 /** CIMConstClass - ATTN: define this.
423 mike  1.3 
424           */
425 mike  1.1 
426 mike  1.8 class PEGASUS_COMMON_LINKAGE CIMConstClass
427 mike  1.1 {
428           public:
429           
430 mike  1.8     CIMConstClass() : _rep(0)
431 mike  1.1     {
432           
433               }
434           
435 mike  1.8     CIMConstClass(const CIMConstClass& x)
436 mike  1.1     {
437           	Inc(_rep = x._rep);
438               }
439           
440 mike  1.8     CIMConstClass(const CIMClass& x)
441 mike  1.1     {
442           	Inc(_rep = x._rep);
443               }
444           
445 mike  1.8     CIMConstClass& operator=(const CIMConstClass& x)
446 mike  1.1     {
447           	if (x._rep != _rep)
448           	{
449           	    Dec(_rep);
450           	    Inc(_rep = x._rep);
451           	}
452           	return *this;
453               }
454           
455 mike  1.8     CIMConstClass& operator=(const CIMClass& x)
456 mike  1.1     {
457           	if (x._rep != _rep)
458           	{
459           	    Dec(_rep);
460           	    Inc(_rep = x._rep);
461           	}
462           	return *this;
463               }
464           
465               // Throws IllegalName if className argument not legal CIM identifier.
466           
467 mike  1.8     CIMConstClass(
468 karl  1.4 	const String& className,
469 mike  1.1 	const String& superClassName = String())
470               {
471           	_rep = new CIMClassRep(className, superClassName);
472               }
473           
474 mike  1.8     ~CIMConstClass()
475 mike  1.1     {
476           	Dec(_rep);
477               }
478           
479               Boolean isAssociation() const
480               {
481           	_checkRep();
482           	return _rep->isAssociation();
483               }
484           
485               Boolean isAbstract() const
486               {
487           	_checkRep();
488           	return _rep->isAbstract();
489               }
490           
491 karl  1.4     const String& getClassName() const
492               {
493 mike  1.1 	_checkRep();
494 karl  1.4 	return _rep->getClassName();
495 mike  1.1     }
496           
497 karl  1.4     const String& getSuperClassName() const
498               {
499 mike  1.1 	_checkRep();
500 karl  1.4 	return _rep->getSuperClassName();
501 mike  1.1     }
502           
503               Uint32 findQualifier(const String& name) const
504               {
505           	_checkRep();
506           	return _rep->findQualifier(name);
507               }
508           
509               CIMConstQualifier getQualifier(Uint32 pos) const
510               {
511           	_checkRep();
512           	return _rep->getQualifier(pos);
513               }
514           
515               Uint32 getQualifierCount() const
516               {
517           	_checkRep();
518           	return _rep->getQualifierCount();
519               }
520           
521               Uint32 findProperty(const String& name) const
522 mike  1.1     {
523           	_checkRep();
524           	return _rep->findProperty(name);
525               }
526           
527 mike  1.8     CIMConstProperty getProperty(Uint32 pos) const
528 mike  1.1     {
529           	_checkRep();
530           	return _rep->getProperty(pos);
531               }
532           
533               Uint32 getPropertyCount() const
534               {
535           	_checkRep();
536           	return _rep->getPropertyCount();
537               }
538           
539               Uint32 findMethod(const String& name) const
540               {
541           	_checkRep();
542           	return _rep->findMethod(name);
543               }
544           
545               CIMConstMethod getMethod(Uint32 pos) const
546               {
547           	_checkRep();
548           	return _rep->getMethod(pos);
549 mike  1.1     }
550           
551               Uint32 getMethodCount() const
552               {
553           	_checkRep();
554           	return _rep->getMethodCount();
555               }
556           
557               operator int() const { return _rep != 0; }
558           
559               void toXml(Array<Sint8>& out) const
560               {
561           	_checkRep();
562           	_rep->toXml(out);
563               }
564           
565 bob   1.5     void print(std::ostream &o=std::cout) const
566 mike  1.1     {
567           	_checkRep();
568 bob   1.5 	_rep->print(o);
569 mike  1.1     }
570           
571 mike  1.8     Boolean identical(const CIMConstClass& x) const
572 mike  1.1     {
573           	x._checkRep();
574           	_checkRep();
575           	return _rep->identical(x._rep);
576               }
577           
578               CIMClass clone() const
579               {
580           	return CIMClass(_rep->clone());
581 mike  1.3     }
582           
583               void getKeyNames(Array<String>& keyNames) const
584               {
585           	_checkRep();
586           	_rep->getKeyNames(keyNames);
587 mike  1.1     }
588           
589           private:
590           
591               void _checkRep() const
592               {
593           	if (!_rep)
594           	    throw UnitializedHandle();
595               }
596           
597               CIMClassRep* _rep;
598           
599               friend class CIMClassRep;
600               friend class CIMClass;
601               friend class CIMInstanceRep;
602           };
603           
604           PEGASUS_NAMESPACE_END
605           
606 mike  1.9 #endif /* Pegasus_CIMClass_h */

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2