(file) Return to CIMInstance.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 bob   1.7 //
 26 mike  1.9 //%/////////////////////////////////////////////////////////////////////////////
 27 mike  1.1 
 28           /*
 29           
 30           CIMInstance.h File defines the Class used to create, instantiate, and modify 
 31           CIM Instances 
 32           
 33           */
 34           #ifndef Pegasus_InstanceDecl_h
 35           #define Pegasus_InstanceDecl_h
 36           
 37           #include <Pegasus/Common/Config.h>
 38           #include <Pegasus/Common/CIMInstanceRep.h>
 39           
 40           PEGASUS_NAMESPACE_BEGIN
 41           
 42           ////////////////////////////////////////////////////////////////////////////////
 43           //
 44           // CIMInstance
 45           //
 46           ////////////////////////////////////////////////////////////////////////////////
 47           
 48 mike  1.8 class CIMConstInstance;
 49 mike  1.2 
 50 mike  1.1 /** Class CIMInstance	- The CIMInstance class represents the instance of 
 51 mike  1.2     a CIM class in Pegasus. It is used manipulate instances and the 
 52               characteristics of instances
 53 mike  1.1 */ 
 54           class PEGASUS_COMMON_LINKAGE CIMInstance
 55           {
 56           public:
 57 mike  1.2 
 58 mike  1.1     /** Constructor - Create a CIM Instance object.
 59 mike  1.2 	@return  Instance created
 60 mike  1.1     */
 61               CIMInstance() : _rep(0)
 62               {
 63           
 64               }
 65 karl  1.5     /** Constructor - Create a CIMInstance object from another Instance.
 66           	@param Instance object from which the new instance is created.
 67           	@return New instance
 68           	@example
 69 mike  1.1 	ATTN:
 70               */
 71               CIMInstance(const CIMInstance& x)
 72               {
 73           	Inc(_rep = x._rep);
 74               }
 75               /// Constructor - ATTN
 76               CIMInstance& operator=(const CIMInstance& x)
 77               {
 78           	if (x._rep != _rep)
 79           	{
 80           	    Dec(_rep);
 81           	    Inc(_rep = x._rep);
 82           	}
 83           	return *this;
 84               }
 85               /**	Constructor - Creates an Instance object with the classname
 86 karl  1.5 	from the input parameters
 87           	@param - String className to be used with new instance object
 88           	@return The new instance object
 89 karl  1.6 	@exception Throws IllegalName if className argument not legal CIM 
 90           	identifier. ATTN: Clarify the defintion	of legal CIM identifier.
 91 mike  1.1     */
 92               CIMInstance(const String& className)
 93               {
 94           	_rep = new CIMInstanceRep(className);
 95               }
 96               /// Destructor
 97               ~CIMInstance()
 98               {
 99           	Dec(_rep);
100               }
101 karl  1.5     /**	getClassName - 	Returns the class name of the instance
102           	@return String with the class name.
103 mike  1.1     */
104               const String& getClassName() const 
105               { 
106           	_checkRep();
107           	return _rep->getClassName(); 
108               }
109 karl  1.5     /**	addQualifier - Adds the CIMQualifier object to the instance.
110           	Thows an exception of the CIMQualifier already exists in the instance
111           	@param CIMQualifier object to add to instance
112           	@return ATTN:
113           	@exception Throws AlreadyExists.
114 mike  1.1     */
115               CIMInstance& addQualifier(const CIMQualifier& qualifier)
116               {
117           	_checkRep();
118           	_rep->addQualifier(qualifier);
119           	return *this;
120               }
121           
122 karl  1.5     /**	findQualifier - Searches the instance for the qualifier object
123                   defined by the inputparameter.
124           	@param String defining the qualifier to be found
125           	@return - Index of the qualifier to be used in subsequent 
126           	operations or -1 if the qualifier is not found. 
127               */ 
128 mike  1.1     Uint32 findQualifier(const String& name)
129               {
130           	_checkRep();
131           	return _rep->findQualifier(name);
132               }
133           
134 karl  1.5     /**	findQualifier - Searches the instance for the qualifier object
135                   defined by the input parameter.
136           	@param String defining the qualifier to be found
137           	@return - Index of the qualifier to be used in subsequent 
138           	operations or -1 if the qualifier is not found. 
139               */ 
140 mike  1.1     Uint32 findQualifier(const String& name) const
141               {
142           	_checkRep();
143           	return _rep->findQualifier(name);
144               }
145 karl  1.5 
146               /**	getQualifier - Retrieves the qualifier object defined by the
147           	index input parameter.  @ index for the qualifier object.
148           	The index to qualifier objects is zero-origin and continuous
149           	so that incrementing loops can be used to get all qualifier
150           	objects in a CIMInstnace.  
151 karl  1.6 	@return: Returns qualifier object defined by index.
152           	@exception Throws the OutOfBounds exception if the index
153           	is out of bounds  
154 karl  1.5     ATTN: What is effect of out of range index???
155 mike  1.1     */
156               CIMQualifier getQualifier(Uint32 pos)
157               {
158           	_checkRep();
159           	return _rep->getQualifier(pos);
160               }
161 karl  1.5 
162                /** getQualifier - Retrieves the qualifier object defined by the
163           	index input parameter.  @ index for the qualifier object.
164           	The index to qualifier objects is zero-origin and continuous
165           	so that incrementing loops can be used to get all qualifier
166           	objects in a CIMInstnace.  
167 karl  1.6 	@return: Returns qualifier object defined by index. 
168           	@exception Throws the OutOfBounds exception if the index
169           	is out of bounds  
170            
171 karl  1.5     ATTN: What is effect of out of range index???
172               ATTN: Is the above statement correct???
173 mike  1.1     */
174               CIMConstQualifier getQualifier(Uint32 pos) const
175               {
176           	_checkRep();
177           	return _rep->getQualifier(pos);
178               }
179           
180 karl  1.5     /**	getQualifierCount - Gets the numbercount of CIMQualifierobjects 
181           	defined for this CIMInstance.
182           	@return	Count of the number of CIMQalifier objects in the
183           	CIMInstance.
184 karl  1.6 	@exception Throws the OutOfBounds exception if the index
185           	is out of bounds  
186           
187 karl  1.5     */ 
188 mike  1.1     Uint32 getQualifierCount() const
189               {
190           	_checkRep();
191           	return _rep->getQualifierCount();
192               }
193           
194 karl  1.5     /**	addProperty - Adds a property object defined by the input
195           	parameter to the CIMInstance
196           	@param Property Object to be added.  See the CIM Property
197           	class for definition of the property object
198           	@return ATTN:
199 karl  1.6 	@exception Throws the exception AlreadyExists if the property 
200           	already exists.
201 mike  1.1     */
202               CIMInstance& addProperty(const CIMProperty& x)
203               {
204           	_checkRep();
205           	_rep->addProperty(x);
206           	return *this;
207               }
208           
209 karl  1.5     /**	findProperty - Searches the CIMProperty objects installed in the 
210           	CIMInstance for property objects with the name defined by the
211           	input.
212           	@param String with the name of the property object to be found
213           	@return Index in the CIM Instance to the property object if found or 
214           	-1 if no property object found with the name defined by the input. 
215 mike  1.1     */
216               Uint32 findProperty(const String& name)
217               {
218           	_checkRep();
219           	return _rep->findProperty(name);
220               }
221           
222 karl  1.5     /**	findProperty - Searches the property objects installed in the 
223           	CIMInstance for property objects with the name defined by the
224           	input
225           	@param String with the name of the property object to be found
226           	@return Index in the CIM Instance to the property object if found or 
227           	-1 if no property object found with the name defined by the input. 
228               */  
229 mike  1.1     Uint32 findProperty(const String& name) const
230               {
231           	_checkRep();
232           	return _rep->findProperty(name);
233               }
234           
235 karl  1.5     /**	getProperty - Gets the CIMproperty object in the CIMInstance defined 
236           	by the input index parameter.
237           	@param Index to the property object in the CIMInstance.
238               	The index to qualifier objects is zero-origin and continuous
239           	so that incrementing loops can be used to get all qualifier
240           	objects in a CIMInstnace. 
241 karl  1.6 	@return CIMProperty object corresponding to the index.
242           	@exception Throws the OutOfBounds exception if the index
243           	is out of bounds  
244            
245 karl  1.5 	ATTN: What is the effect of out of range?
246 mike  1.1     */
247               CIMProperty getProperty(Uint32 pos)
248               {
249           	_checkRep();
250           	return _rep->getProperty(pos);
251               }
252           
253 karl  1.5     /**	getProperty - Gets the CIMproperty object in the CIMInstance defined 
254           	by the input index parameter.
255           	@param Index to the property object in the CIMInstance.
256               	The index to qualifier objects is zero-origin and continuous
257           	so that incrementing loops can be used to get all qualifier
258           	objects in a CIMInstnace. 
259 karl  1.6 	@return CIMProperty object corresponding to the index.
260           	@exception Throws the OutOfBounds exception if the index
261           	is out of bounds  
262            
263 karl  1.5 	ATTN: What is the effect of out of range?
264 mike  1.1     */
265 mike  1.8     CIMConstProperty getProperty(Uint32 pos) const
266 mike  1.1     {
267           	_checkRep();
268           	return _rep->getProperty(pos);
269               }
270           
271 karl  1.5     /**	getPropertyCount - Gets the numbercount of CIMProperty 
272           	objects defined for this CIMInstance.
273           	@return	Count of the number of CIMProperty objects in the
274           	CIMInstance. Zero indicates that no CIMProperty objects
275           	are contained in the CIMInstance
276 karl  1.6 	@exception Throws the OutOfBounds exception if the index
277           	is out of bounds  
278           
279 mike  1.1     */
280               Uint32 getPropertyCount() const
281               {
282           	_checkRep();
283           	return _rep->getPropertyCount();
284               }
285           
286 karl  1.5     /**	operator int() - ATTN:
287 mike  1.1     
288               */
289               operator int() const { return _rep != 0; }
290           
291 karl  1.5     /**	resolve - ATTN:
292 mike  1.1     
293               */
294               void resolve(DeclContext* declContext, const String& nameSpace)
295               {
296           	_checkRep();
297           	_rep->resolve(declContext, nameSpace);
298               }
299           
300 karl  1.5     /**	toXml - Creates an XML transformation of the CIMInstance
301           	compatiblewith the DMTF CIM Operations over HTTP defintions.
302           	@return
303           	ATTN: This is incorrect and needs to be corrected.
304 mike  1.1     */
305               void toXml(Array<Sint8>& out) const
306               {
307           	_checkRep();
308           	_rep->toXml(out);
309               }
310           
311               /**	CIMMethod
312               
313               */
314 bob   1.7     void print(std::ostream &o=std::cout) const
315 mike  1.1     {
316           	_checkRep();
317 bob   1.7 	_rep->print(o);
318 mike  1.1     }
319           
320 karl  1.5     /**	identical - Compares the CIMInstance with another CIMInstance
321           	defined by the input parameter for equality of all components.
322           	@param CIMInstance to be compared
323           	@return Boolean true if they are identical
324 mike  1.1     
325               */
326 mike  1.8     Boolean identical(const CIMConstInstance& x) const;
327 mike  1.1 
328               /**	CIMMethod
329               
330               */
331               CIMInstance clone() const
332               {
333           	return CIMInstance(_rep->clone());
334               }
335           
336 karl  1.5     /** getInstnaceName - Get the instance name of this instance. The class 
337           	argument is used to determine which fields are keys. The instance
338           	name has this from:
339 mike  1.3 
340 karl  1.5 	<PRE> 
341 mike  1.3 	    ClassName.key1=value1,...,keyN=valueN
342 karl  1.5 	</PRE>
343 mike  1.3 
344           	The instance name is in standard form (the class name and key name
345           	is all lowercase; the keys-value pairs appear in sorted order by
346           	key name).
347               */
348 mike  1.8     String getInstanceName(const CIMConstClass& cimClass) const
349 mike  1.3     {
350           	_checkRep();
351           	return _rep->getInstanceName(cimClass);
352               }
353           
354 mike  1.1 private:
355           
356               CIMInstance(CIMInstanceRep* rep) : _rep(rep)
357               {
358               }
359           
360               void _checkRep() const
361               {
362           	if (!_rep)
363           	    throw UnitializedHandle();
364               }
365           
366               CIMInstanceRep* _rep;
367 mike  1.8     friend class CIMConstInstance;
368 mike  1.1 };
369           
370           ////////////////////////////////////////////////////////////////////////////////
371           //
372 mike  1.8 // CIMConstInstance
373 mike  1.1 //
374           ////////////////////////////////////////////////////////////////////////////////
375           
376 mike  1.8 class PEGASUS_COMMON_LINKAGE CIMConstInstance
377 mike  1.1 {
378           public:
379           
380 mike  1.8     CIMConstInstance() : _rep(0)
381 mike  1.1     {
382           
383               }
384           
385 mike  1.8     CIMConstInstance(const CIMConstInstance& x)
386 mike  1.1     {
387           	Inc(_rep = x._rep);
388               }
389           
390 mike  1.8     CIMConstInstance(const CIMInstance& x)
391 mike  1.1     {
392           	Inc(_rep = x._rep);
393               }
394           
395 mike  1.8     CIMConstInstance& operator=(const CIMConstInstance& x)
396 mike  1.1     {
397           	if (x._rep != _rep)
398           	{
399           	    Dec(_rep);
400           	    Inc(_rep = x._rep);
401           	}
402           	return *this;
403               }
404           
405 mike  1.8     CIMConstInstance& operator=(const CIMInstance& x)
406 mike  1.1     {
407           	if (x._rep != _rep)
408           	{
409           	    Dec(_rep);
410           	    Inc(_rep = x._rep);
411           	}
412           	return *this;
413               }
414           
415               // Throws IllegalName if className argument not legal CIM identifier.
416           
417 mike  1.8     CIMConstInstance(const String& className)
418 mike  1.1     {
419           	_rep = new CIMInstanceRep(className);
420               }
421           
422 mike  1.8     ~CIMConstInstance()
423 mike  1.1     {
424           	Dec(_rep);
425               }
426           
427               const String& getClassName() const 
428               { 
429           	_checkRep();
430           	return _rep->getClassName(); 
431               }
432           
433               Uint32 findQualifier(const String& name) const
434               {
435           	_checkRep();
436           	return _rep->findQualifier(name);
437               }
438           
439               CIMConstQualifier getQualifier(Uint32 pos) const
440               {
441           	_checkRep();
442           	return _rep->getQualifier(pos);
443               }
444 mike  1.1 
445               Uint32 getQualifierCount() const
446               {
447           	_checkRep();
448           	return _rep->getQualifierCount();
449               }
450           
451               Uint32 findProperty(const String& name) const
452               {
453           	_checkRep();
454           	return _rep->findProperty(name);
455               }
456           
457 mike  1.8     CIMConstProperty getProperty(Uint32 pos) const
458 mike  1.1     {
459           	_checkRep();
460           	return _rep->getProperty(pos);
461               }
462           
463               Uint32 getPropertyCount() const
464               {
465           	_checkRep();
466           	return _rep->getPropertyCount();
467               }
468           
469               operator int() const { return _rep != 0; }
470           
471               void toXml(Array<Sint8>& out) const
472               {
473           	_checkRep();
474           	_rep->toXml(out);
475               }
476           
477 bob   1.7     void print(std::ostream &o=std::cout) const
478 mike  1.1     {
479           	_checkRep();
480 bob   1.7 	_rep->print(o);
481 mike  1.1     }
482           
483 mike  1.8     Boolean identical(const CIMConstInstance& x) const
484 mike  1.1     {
485           	x._checkRep();
486           	_checkRep();
487           	return _rep->identical(x._rep);
488               }
489           
490               CIMInstance clone() const
491               {
492           	return CIMInstance(_rep->clone());
493 mike  1.2     }
494           
495 mike  1.8     String getInstanceName(const CIMConstClass& cimClass) const
496 mike  1.2     {
497           	_checkRep();
498           	return _rep->getInstanceName(cimClass);
499 mike  1.1     }
500           
501           private:
502           
503               void _checkRep() const
504               {
505           	if (!_rep)
506           	    throw UnitializedHandle();
507               }
508           
509               CIMInstanceRep* _rep;
510               friend class CIMInstance;
511           };
512           
513           PEGASUS_NAMESPACE_END
514           
515           #endif /* Pegasus_InstanceDecl_h */

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2