1 //%2003////////////////////////////////////////////////////////////////////////
3 // Copyright (c) 2000, 2001, 2002 BMC Software, Hewlett-Packard Development
4 // Company, L. P., IBM Corp., The Open Group, Tivoli Systems.
5 // Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L. P.;
6 // IBM Corp.; EMC Corporation, The Open Group.
8 // Permission is hereby granted, free of charge, to any person obtaining a copy
9 // of this software and associated documentation files (the "Software"), to
10 // deal in the Software without restriction, including without limitation the
11 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
12 // sell copies of the Software, and to permit persons to whom the Software is
13 // furnished to do so, subject to the following conditions:
15 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
16 // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
17 // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
18 // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
19 // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
20 // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
21 // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 //==============================================================================
26 // Author: Mike Brasher (mbrasher@bmc.com)
28 // Modified By: Roger Kumpf, Hewlett-Packard Company (roger_kumpf@hp.com)
29 // Karl Schopmeyer, (k.schopmeyer@opengroup.org)
30 // Carol Ann Krug Graves, Hewlett-Packard Company
31 // (carolann_graves@hp.com)
33 //%/////////////////////////////////////////////////////////////////////////////
35 #ifndef Pegasus_Instance_h
36 #define Pegasus_Instance_h
38 #include <Pegasus/Common/Config.h>
39 #include <Pegasus/Common/Linkage.h>
40 #include <Pegasus/Common/CIMName.h>
41 #include <Pegasus/Common/CIMObject.h>
43 PEGASUS_NAMESPACE_BEGIN
45 ////////////////////////////////////////////////////////////////////////////////
49 ////////////////////////////////////////////////////////////////////////////////
51 class CIMConstInstance;
55 /** This class represents the instance of a CIM class. It is used manipulate
56 instances and their members.
58 class PEGASUS_COMMON_LINKAGE CIMInstance
62 /** Creates a CIMInstance object.
66 /** Creates a CIMInstance object from another CIMInstance object.
67 @param x - CIMInstance object from which the new instance is created.
69 CIMInstance(const CIMInstance& x);
71 /** Creates a CIMInstance object from the given CIMObject.
72 @param x - CIMObject from which to create the CIMInstance.
73 @exception DynamicCastFailedException If a CIMInstance can not be
74 created from the given CIMObject.
76 PEGASUS_EXPLICIT CIMInstance(const CIMObject& x);
78 /** Creates a CIMInstance object of the class specified by
80 @param className - CIMName to be used with new instance object.
82 CIMInstance(const CIMName& className);
84 /** Copy Constructor. */
85 CIMInstance& operator=(const CIMInstance& x);
90 /** Gets the class name of the instance.
91 @return CIMName with the class name.
93 const CIMName& getClassName() const;
96 const CIMObjectPath& getPath() const;
98 /** Sets the object path for the instance.
99 @param path - CIMObjectPath containing the object path.
101 void setPath (const CIMObjectPath & path);
103 /** Adds the CIMQualifier object to the instance.
104 @param qualifier - CIMQualifier object to add to instance.
105 @return the resulting CIMInstance.
106 @exception AlreadyExistsException if the CIMQualifier
107 already exists in the instance.
109 CIMInstance& addQualifier(const CIMQualifier& qualifier);
111 /** Searches the instance for the qualifier object defined by
113 @param name - CIMName defining the qualifier object to be found.
114 @return Position of the qualifier to be used in subsequent
115 operations or PEG_NOT_FOUND if the qualifier is not found.
117 Uint32 findQualifier(const CIMName& name) const;
119 /** Retrieves the qualifier object defined by the input parameter.
120 The index to qualifier objects is zero-origin and continuous
121 so that incrementing loops can be used to get all qualifier
122 objects in a CIMInstance.
123 @param index - Index for the qualifier object.
124 @return Qualifier object defined by index.
125 @exception IndexOutOfBoundsException exception if the index
128 CIMQualifier getQualifier(Uint32 index);
130 /** Retrieves the qualifier object defined by the input parameter.
131 The index to qualifier objects is zero-origin and continuous
132 so that incrementing loops can be used to get all qualifier
133 objects in a CIMInstance.
134 @param index - Index for the qualifier object.
135 @return Qualifier object defined by index.
136 @exception IndexOutOfBoundsException exception if the index
139 CIMConstQualifier getQualifier(Uint32 index) const;
141 /** Removes the qualifier defined by the index parameter.
142 @param index Defines the index of the qualifier to be removed.
143 @exception IndexOutOfBoundsException if the index is outside
144 the range of existing qualifier objects for this instance.
146 void removeQualifier(Uint32 index);
148 /** Gets the count of the CIMQualifier objects defined
149 for this CIMInstance.
150 @return Count of the number of CIMQalifier objects in the
153 Uint32 getQualifierCount() const;
155 /** Adds a property object defined by the input parameter to
157 @param x - Property Object to be added. See the CIMProperty
158 class for definition of the property object.
159 @return the resulting CIMInstance.
160 @exception AlreadyExistsException if the property already exists.
162 CIMInstance& addProperty(const CIMProperty& x);
164 /** Searches the CIMProperty objects in the CIMInstance for
165 property object with the name defined by the input parameter.
166 @param name - CIMName with the name of the property object to be found.
167 @return Position in the CIM Instance to the property object if found or
168 PEG_NOT_FOUND if no property object found with the name defined by the
171 Uint32 findProperty(const CIMName& name) const;
173 /** Gets the CIMProperty object in the CIMInstance defined
174 by the input parameter.
175 The index to qualifier objects is zero-origin and continuous
176 so that incrementing loops can be used to get all qualifier
177 objects in a CIMInstance.
178 @param index - Index to the property object in the CIMInstance.
179 @return CIMProperty object corresponding to the index.
180 @exception IndexOutOfBoundsException if index is outside the range of
181 properties in this instance.
183 CIMProperty getProperty(Uint32 index);
185 /** Gets the CIMproperty object in the CIMInstance defined
186 by the input parameter.
187 The index to qualifier objects is zero-origin and continuous
188 so that incrementing loops can be used to get all qualifier
189 objects in a CIMInstance.
190 @param index - Index to the property object in the CIMInstance.
191 @return CIMProperty object corresponding to the index.
192 @exception IndexOutOfBoundsException if index is outside the range of
193 properties in this instance.
195 CIMConstProperty getProperty(Uint32 index) const;
197 /** Removes the property defined by the input parameter
199 @param index - Index to the property to be removed from the
200 instance. Normally this is obtained by getProperty().
201 @exception IndexOutOfBoundsException if index is outside the range of
202 properties in this instance.
204 void removeProperty(Uint32 index);
206 /** Gets the count of CIMProperty objects defined for
208 @return Count of the number of CIMProperty objects in the
209 CIMInstance. Zero indicates that no CIMProperty objects
210 are contained in the CIMInstance.
212 Uint32 getPropertyCount() const;
214 /** Builds the CIM object path for this instance. The class
215 argument is used to determine which fields are keys. The instance
219 ClassName.key1=value1,...,keyN=valueN
222 The object path is in standard form (the class name and key name
223 are all lowercase; the key-value pairs appear in sorted order by
226 Note that the path attribute of the CIMInstanceRep object is not
229 CIMObjectPath buildPath(const CIMConstClass& cimClass) const;
231 /** Makes a deep copy (clone) of the CIMInstance object. */
232 CIMInstance clone() const;
234 /** Compares the CIMInstance with another CIMInstance
235 defined by the input parameter for equality of all components.
236 @param x - CIMInstance to be compared.
237 @return true if they are identical, false otherwise.
239 Boolean identical(const CIMConstInstance& x) const;
241 /** Determines if the object has not been initialized.
242 @return true if the object has not been initialized,
245 Boolean isUninitialized() const;
249 CIMInstanceRep* _rep;
251 CIMInstance(CIMInstanceRep* rep);
253 void _checkRep() const;
255 friend class CIMConstInstance;
256 friend class CIMObject;
257 friend class CIMConstObject;
258 friend class Resolver;
259 friend class XmlWriter;
260 friend class MofWriter;
263 ////////////////////////////////////////////////////////////////////////////////
267 ////////////////////////////////////////////////////////////////////////////////
270 class PEGASUS_COMMON_LINKAGE CIMConstInstance
278 CIMConstInstance(const CIMConstInstance& x);
281 CIMConstInstance(const CIMInstance& x);
284 PEGASUS_EXPLICIT CIMConstInstance(const CIMObject& x);
287 PEGASUS_EXPLICIT CIMConstInstance(const CIMConstObject& x);
290 CIMConstInstance(const CIMName& className);
293 CIMConstInstance& operator=(const CIMConstInstance& x);
296 CIMConstInstance& operator=(const CIMInstance& x);
302 const CIMName& getClassName() const;
305 const CIMObjectPath& getPath() const;
308 Uint32 findQualifier(const CIMName& name) const;
311 CIMConstQualifier getQualifier(Uint32 index) const;
314 Uint32 getQualifierCount() const;
317 Uint32 findProperty(const CIMName& name) const;
320 CIMConstProperty getProperty(Uint32 index) const;
323 Uint32 getPropertyCount() const;
326 CIMObjectPath buildPath(const CIMConstClass& cimClass) const;
329 CIMInstance clone() const;
332 Boolean identical(const CIMConstInstance& x) const;
335 Boolean isUninitialized() const;
339 CIMInstanceRep* _rep;
341 void _checkRep() const;
343 friend class CIMInstance;
344 friend class CIMObject;
345 friend class CIMConstObject;
346 friend class XmlWriter;
347 friend class MofWriter;
350 #define PEGASUS_ARRAY_T CIMInstance
351 # include <Pegasus/Common/ArrayInter.h>
352 #undef PEGASUS_ARRAY_T
354 PEGASUS_NAMESPACE_END
356 #endif /* Pegasus_Instance_h */