(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.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            	@return Returns index of the qualifier found or -1 if not found.
185 mike  1.1      */
186                Uint32 findQualifier(const String& name)
187                {
188            	_checkRep();
189            	return _rep->findQualifier(name);
190                }
191 karl  1.11     ///
192 mike  1.1      Uint32 findQualifier(const String& name) const
193                {
194            	_checkRep();
195            	return _rep->findQualifier(name);
196                }
197 mike  1.3  
198 karl  1.11     /**	getQualifier - Gets the CIMQualifier object defined
199 mike  1.3  	by the input parameter
200            	@param pos defines the position of the qualifier in the class from the
201            	findQualifier method
202            	@return CIMQualifier object representing the qualifier found.
203            	ATTN: what is error return here?
204 mike  1.1      */
205                CIMQualifier getQualifier(Uint32 pos)
206                {
207            	_checkRep();
208            	return _rep->getQualifier(pos);
209                }
210 mike  1.3  
211 karl  1.11     /// getQualifier - ATTN:
212 mike  1.1      CIMConstQualifier getQualifier(Uint32 pos) const
213                {
214            	_checkRep();
215            	return _rep->getQualifier(pos);
216                }
217 mike  1.3  
218 karl  1.11     /** getQualifierCount - Returns the number of qualifiers
219 karl  1.4  	in the class.
220 mike  1.3  	@return ATTN:
221 mike  1.1      */
222                Uint32 getQualifierCount() const
223                {
224            	_checkRep();
225            	return _rep->getQualifierCount();
226                }
227 mike  1.3  
228 karl  1.11     /**	addProperty - Adds the specified property object to the
229 mike  1.3  	properties in the CIM class
230 mike  1.1      */
231                CIMClass& addProperty(const CIMProperty& x)
232                {
233            	_checkRep();
234            	_rep->addProperty(x);
235            	return *this;
236                }
237 mike  1.3  
238 karl  1.11     /** removeProperty - Removes the property represented
239 mike  1.3  	by the position input parameter from the class
240 karl  1.11 	@param pos Index to the property to be removed from the
241 mike  1.3  	findPropety method
242 karl  1.11 	@exception Throws OutofBounds if index is not a property object
243 mike  1.1      */
244                void removeProperty(Uint32 pos)
245                {
246            	_checkRep();
247            	_rep->removeProperty(pos);
248                }
249 mike  1.3  
250 mike  1.1      /** CIMMethod findProperty - Finds the property object with the
251 mike  1.3  	name defined by the input parameter in the class.
252            	@param String parameter with the property name.
253 karl  1.11 	@return position representing the property object found or -1 if the
254            	property is not found.
255 mike  1.1      */
256                Uint32 findProperty(const String& name)
257                {
258            	_checkRep();
259            	return _rep->findProperty(name);
260                }
261 mike  1.3  
262 mike  1.1      Uint32 findProperty(const String& name) const
263                {
264            	_checkRep();
265            	return _rep->findProperty(name);
266                }
267 mike  1.3  
268 karl  1.11     /** getProperty - Returns a property representing the property
269 mike  1.3  	defined by the input parameter
270            	@param position for this property
271            	ATTN: Should we not use something like handle for position???
272            	@return CIMProperty object
273            	ATTN: what is error return?
274 mike  1.1      */
275                CIMProperty getProperty(Uint32 pos)
276                {
277            	_checkRep();
278            	return _rep->getProperty(pos);
279                }
280 mike  1.3  
281 karl  1.11     /**getProperty Gets a property object from the CIMClass
282                	@param pos The index of the property object to get.
283                	@return Returns handle of the property object requested
284                	@exception Throws OutofBounds if the size field is greather than the
285                	bunber of properties in the class.
286                */
287 mike  1.8      CIMConstProperty getProperty(Uint32 pos) const
288 mike  1.1      {
289            	_checkRep();
290            	return _rep->getProperty(pos);
291                }
292 mike  1.3  
293 karl  1.11     /** getProperty -   Gets the count of the number of properties
294 mike  1.3  	defined in the class.
295            	@return count of number of proerties in the class
296 mike  1.1      */
297                Uint32 getPropertyCount() const
298                {
299            	_checkRep();
300            	return _rep->getPropertyCount();
301                }
302 mike  1.3  
303 karl  1.11     /** addMethod - Adds the method object defined by the input
304 karl  1.4  	parameter to the class and increments the count of the number of
305 mike  1.3  	methods in the class
306 karl  1.11 	@param method object representing the method to be added
307            	@return Returns the CIMClass object to which the method was added.
308            	@exception Throws AlreadyExists if the method already exists and throws
309            	UnitializedHandle if the handle is not initialized
310 mike  1.1      */
311                CIMClass& addMethod(const CIMMethod& x)
312                {
313            	_checkRep();
314            	_rep->addMethod(x);
315            	return *this;
316                }
317 mike  1.3  
318 karl  1.11     /** findMethod - Located the method object defined by the
319 mike  1.3  	name input
320            	@param String representing the name of the method to be found
321 karl  1.4  	@return Position of the method object in the class to be used in
322 mike  1.3  	subsequent getmethod, etc. operations
323 mike  1.1      */
324                Uint32 findMethod(const String& name)
325                {
326            	_checkRep();
327            	return _rep->findMethod(name);
328                }
329 mike  1.3  
330 mike  1.1      Uint32 findMethod(const String& name) const
331                {
332            	_checkRep();
333            	return _rep->findMethod(name);
334                }
335 mike  1.3  
336 karl  1.11     /** getMethod - Gets the method object defined by the
337 mike  1.3  	input parameter.
338 karl  1.11 	@param pos Index to the CIMMethod object to get
339            	@return Returns handle of the CIMMethod requested
340            	@exception Throws OutofBounds if the index represented by pos is greater
341            	than the number of methods defined in the class object
342 mike  1.1      */
343                CIMMethod getMethod(Uint32 pos)
344                {
345            	_checkRep();
346            	return _rep->getMethod(pos);
347                }
348 mike  1.3  
349 karl  1.11     /** getMethod Gets the method object defined by the input
350                parameter. This is the const version.
351                */
352            
353 mike  1.1      CIMConstMethod getMethod(Uint32 pos) const
354                {
355            	_checkRep();
356            	return _rep->getMethod(pos);
357                }
358 mike  1.3  
359 mike  1.1      /** CIMMethod getMethodCount - Count of the number of methods in the class
360 karl  1.11 	@return integer representing the number of methods in the class object.
361 mike  1.1      */
362                Uint32 getMethodCount() const
363                {
364            	_checkRep();
365            	return _rep->getMethodCount();
366                }
367 karl  1.4  
368 karl  1.11     /** Resolve -  Resolve the class: inherit any properties and
369 karl  1.4  	qualifiers. Make sure the superClass really exists and is consistent
370 mike  1.3  	with this class. Also set the propagated flag class-origin for each
371            	class feature.
372            	ATTN: explain why this here
373 mike  1.1      */
374                void resolve(
375            	DeclContext* declContext,
376            	const String& nameSpace)
377                {
378            	_checkRep();
379            	_rep->resolve(declContext, nameSpace);
380                }
381 mike  1.3  
382 mike  1.1      /// operator - ATTN:
383                operator int() const { return _rep != 0; }
384 mike  1.3  
385 karl  1.4      /// CIMMethod toXML
386 mike  1.1      void toXml(Array<Sint8>& out) const
387                {
388            	_checkRep();
389            	_rep->toXml(out);
390                }
391 mike  1.3  
392 karl  1.11     /// CIMMethod print
393 bob   1.5      void print(std::ostream &o=std::cout) const
394 mike  1.1      {
395            	_checkRep();
396 bob   1.5  	_rep->print(o);
397 mike  1.1      }
398 mike  1.3  
399 mike  1.1      /** CIMMethod identical -  Compares with another class
400 mike  1.3  	ATTN: Clarify exactly what identical means
401 karl  1.11 	@param Class object for the class to be compared
402 mike  1.3  	@return True if the classes are identical
403 mike  1.1      */
404 mike  1.8      Boolean identical(const CIMConstClass& x) const;
405 mike  1.3  
406 mike  1.1      /// CIMMethod clone - ATTN:
407                CIMClass clone() const
408                {
409            	return CIMClass(_rep->clone());
410                }
411            
412 mike  1.3      void getKeyNames(Array<String>& keyNames) const
413                {
414            	_checkRep();
415            	_rep->getKeyNames(keyNames);
416                }
417            
418 mike  1.1  private:
419            
420                CIMClass(CIMClassRep* rep) : _rep(rep)
421                {
422                }
423            
424                void _checkRep() const
425                {
426            	if (!_rep)
427 mike  1.12 	    ThrowUnitializedHandle();
428 mike  1.1      }
429            
430                CIMClassRep* _rep;
431 mike  1.8      friend class CIMConstClass;
432 mike  1.1  };
433            
434 mike  1.8  /** CIMConstClass - ATTN: define this.
435 mike  1.3  
436            */
437 mike  1.1  
438 mike  1.8  class PEGASUS_COMMON_LINKAGE CIMConstClass
439 mike  1.1  {
440            public:
441            
442 mike  1.8      CIMConstClass() : _rep(0)
443 mike  1.1      {
444            
445                }
446            
447 mike  1.8      CIMConstClass(const CIMConstClass& x)
448 mike  1.1      {
449            	Inc(_rep = x._rep);
450                }
451            
452 mike  1.8      CIMConstClass(const CIMClass& x)
453 mike  1.1      {
454            	Inc(_rep = x._rep);
455                }
456            
457 mike  1.8      CIMConstClass& operator=(const CIMConstClass& x)
458 mike  1.1      {
459            	if (x._rep != _rep)
460            	{
461            	    Dec(_rep);
462            	    Inc(_rep = x._rep);
463            	}
464            	return *this;
465                }
466            
467 mike  1.8      CIMConstClass& operator=(const CIMClass& x)
468 mike  1.1      {
469            	if (x._rep != _rep)
470            	{
471            	    Dec(_rep);
472            	    Inc(_rep = x._rep);
473            	}
474            	return *this;
475                }
476            
477                // Throws IllegalName if className argument not legal CIM identifier.
478            
479 mike  1.8      CIMConstClass(
480 karl  1.4  	const String& className,
481 mike  1.1  	const String& superClassName = String())
482                {
483            	_rep = new CIMClassRep(className, superClassName);
484                }
485            
486 mike  1.8      ~CIMConstClass()
487 mike  1.1      {
488            	Dec(_rep);
489                }
490            
491                Boolean isAssociation() const
492                {
493            	_checkRep();
494            	return _rep->isAssociation();
495                }
496            
497                Boolean isAbstract() const
498                {
499            	_checkRep();
500            	return _rep->isAbstract();
501                }
502            
503 karl  1.4      const String& getClassName() const
504                {
505 mike  1.1  	_checkRep();
506 karl  1.4  	return _rep->getClassName();
507 mike  1.1      }
508            
509 karl  1.4      const String& getSuperClassName() const
510                {
511 mike  1.1  	_checkRep();
512 karl  1.4  	return _rep->getSuperClassName();
513 mike  1.1      }
514            
515                Uint32 findQualifier(const String& name) const
516                {
517            	_checkRep();
518            	return _rep->findQualifier(name);
519                }
520            
521                CIMConstQualifier getQualifier(Uint32 pos) const
522                {
523            	_checkRep();
524            	return _rep->getQualifier(pos);
525                }
526            
527                Uint32 getQualifierCount() const
528                {
529            	_checkRep();
530            	return _rep->getQualifierCount();
531                }
532            
533                Uint32 findProperty(const String& name) const
534 mike  1.1      {
535            	_checkRep();
536            	return _rep->findProperty(name);
537                }
538            
539 mike  1.8      CIMConstProperty getProperty(Uint32 pos) const
540 mike  1.1      {
541            	_checkRep();
542            	return _rep->getProperty(pos);
543                }
544            
545                Uint32 getPropertyCount() const
546                {
547            	_checkRep();
548            	return _rep->getPropertyCount();
549                }
550            
551                Uint32 findMethod(const String& name) const
552                {
553            	_checkRep();
554            	return _rep->findMethod(name);
555                }
556            
557                CIMConstMethod getMethod(Uint32 pos) const
558                {
559            	_checkRep();
560            	return _rep->getMethod(pos);
561 mike  1.1      }
562            
563                Uint32 getMethodCount() const
564                {
565            	_checkRep();
566            	return _rep->getMethodCount();
567                }
568            
569                operator int() const { return _rep != 0; }
570            
571                void toXml(Array<Sint8>& out) const
572                {
573            	_checkRep();
574            	_rep->toXml(out);
575                }
576            
577 bob   1.5      void print(std::ostream &o=std::cout) const
578 mike  1.1      {
579            	_checkRep();
580 bob   1.5  	_rep->print(o);
581 mike  1.1      }
582            
583 mike  1.8      Boolean identical(const CIMConstClass& x) const
584 mike  1.1      {
585            	x._checkRep();
586            	_checkRep();
587            	return _rep->identical(x._rep);
588                }
589            
590                CIMClass clone() const
591                {
592            	return CIMClass(_rep->clone());
593 mike  1.3      }
594            
595                void getKeyNames(Array<String>& keyNames) const
596                {
597            	_checkRep();
598            	_rep->getKeyNames(keyNames);
599 mike  1.1      }
600            
601            private:
602            
603                void _checkRep() const
604                {
605            	if (!_rep)
606 mike  1.12 	    ThrowUnitializedHandle();
607 mike  1.1      }
608            
609                CIMClassRep* _rep;
610            
611                friend class CIMClassRep;
612                friend class CIMClass;
613                friend class CIMInstanceRep;
614            };
615            
616            PEGASUS_NAMESPACE_END
617            
618 mike  1.9  #endif /* Pegasus_CIMClass_h */
619 karl  1.11 
620            

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2