PEP 55 Update license on source files to current license text and date
[tpot/pegasus/.git] / src / Pegasus / Common / CIMInstance.h
1 //%2003////////////////////////////////////////////////////////////////////////
2 //
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.
7 //
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:
14 // 
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.
23 //
24 //==============================================================================
25 //
26 // Author: Mike Brasher (mbrasher@bmc.com)
27 //
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)
32 //
33 //%/////////////////////////////////////////////////////////////////////////////
34
35 #ifndef Pegasus_Instance_h
36 #define Pegasus_Instance_h
37
38 #include <Pegasus/Common/Config.h>
39 #include <Pegasus/Common/Linkage.h>
40 #include <Pegasus/Common/CIMName.h>
41 #include <Pegasus/Common/CIMObject.h>
42
43 PEGASUS_NAMESPACE_BEGIN
44
45 ////////////////////////////////////////////////////////////////////////////////
46 //
47 // CIMInstance
48 //
49 ////////////////////////////////////////////////////////////////////////////////
50
51 class CIMConstInstance;
52 class CIMInstanceRep;
53 class Resolver;
54
55 /** This class represents the instance of a CIM class. It is used manipulate
56     instances and their members.
57 */
58 class PEGASUS_COMMON_LINKAGE CIMInstance
59 {
60 public:
61
62     /** Creates a CIMInstance object.
63     */
64     CIMInstance();
65
66     /** Creates a CIMInstance object from another CIMInstance object.
67         @param x - CIMInstance object from which the new instance is created.
68     */
69     CIMInstance(const CIMInstance& x);
70
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.
75     */
76     PEGASUS_EXPLICIT CIMInstance(const CIMObject& x);
77
78     /** Creates a CIMInstance object of the class specified by
79         the input parameter.
80         @param className - CIMName to be used with new instance object.
81     */
82     CIMInstance(const CIMName& className);
83
84     /** Copy Constructor. */
85     CIMInstance& operator=(const CIMInstance& x);
86
87     /** Destructor. */
88     ~CIMInstance();
89
90     /** Gets the class name of the instance.
91         @return CIMName with the class name.
92     */
93     const CIMName& getClassName() const;
94
95     ///
96     const CIMObjectPath& getPath() const;
97
98     /** Sets the object path for the instance.
99         @param  path - CIMObjectPath containing the object path.
100     */
101     void setPath (const CIMObjectPath & path);
102
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.
108     */
109     CIMInstance& addQualifier(const CIMQualifier& qualifier);
110
111     /** Searches the instance for the qualifier object defined by 
112         the input parameter.
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.
116     */
117     Uint32 findQualifier(const CIMName& name) const;
118
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
126         is out of bounds.
127     */
128     CIMQualifier getQualifier(Uint32 index);
129
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
137         is out of bounds.
138     */
139     CIMConstQualifier getQualifier(Uint32 index) const;
140
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.
145     */
146     void removeQualifier(Uint32 index);
147
148     /** Gets the count of the CIMQualifier objects defined
149         for this CIMInstance.
150         @return Count of the number of CIMQalifier objects in the
151         CIMInstance.
152     */
153     Uint32 getQualifierCount() const;
154
155     /** Adds a property object defined by the input parameter to 
156         the CIMInstance.
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.
161     */
162     CIMInstance& addProperty(const CIMProperty& x);
163
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
169         input parameter.
170     */
171     Uint32 findProperty(const CIMName& name) const;
172
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.
182     */
183     CIMProperty getProperty(Uint32 index);
184
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.
194     */
195     CIMConstProperty getProperty(Uint32 index) const;
196
197     /** Removes the property defined by the input parameter 
198         from the instance.
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.
203     */
204     void removeProperty(Uint32 index);
205
206     /** Gets the count of CIMProperty objects defined for 
207         this CIMInstance.
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.
211     */
212     Uint32 getPropertyCount() const;
213
214     /** Builds the CIM object path for this instance. The class
215         argument is used to determine which fields are keys. The instance
216         name has this form:
217
218         <PRE>
219             ClassName.key1=value1,...,keyN=valueN
220         </PRE>
221
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
224         key name).
225
226         Note that the path attribute of the CIMInstanceRep object is not 
227         modified.
228     */
229     CIMObjectPath buildPath(const CIMConstClass& cimClass) const;
230
231     /** Makes a deep copy (clone) of the CIMInstance object. */
232     CIMInstance clone() const;
233
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.
238     */
239     Boolean identical(const CIMConstInstance& x) const;
240
241     /** Determines if the object has not been initialized.
242         @return  true if the object has not been initialized,
243                  false otherwise.
244      */
245     Boolean isUninitialized() const;
246
247 private:
248
249     CIMInstanceRep* _rep;
250
251     CIMInstance(CIMInstanceRep* rep);
252
253     void _checkRep() const;
254
255     friend class CIMConstInstance;
256     friend class CIMObject;
257     friend class CIMConstObject;
258     friend class Resolver;
259     friend class XmlWriter;
260     friend class MofWriter;
261 };
262
263 ////////////////////////////////////////////////////////////////////////////////
264 //
265 // CIMConstInstance
266 //
267 ////////////////////////////////////////////////////////////////////////////////
268
269 ///
270 class PEGASUS_COMMON_LINKAGE CIMConstInstance
271 {
272 public:
273
274     ///
275     CIMConstInstance();
276
277     ///
278     CIMConstInstance(const CIMConstInstance& x);
279
280     ///
281     CIMConstInstance(const CIMInstance& x);
282
283     ///
284     PEGASUS_EXPLICIT CIMConstInstance(const CIMObject& x);
285
286     ///
287     PEGASUS_EXPLICIT CIMConstInstance(const CIMConstObject& x);
288
289     ///
290     CIMConstInstance(const CIMName& className);
291
292     ///
293     CIMConstInstance& operator=(const CIMConstInstance& x);
294
295     ///
296     CIMConstInstance& operator=(const CIMInstance& x);
297
298     ///
299     ~CIMConstInstance();
300
301     ///
302     const CIMName& getClassName() const;
303
304     ///
305     const CIMObjectPath& getPath() const;
306
307     ///
308     Uint32 findQualifier(const CIMName& name) const;
309
310     ///
311     CIMConstQualifier getQualifier(Uint32 index) const;
312
313     ///
314     Uint32 getQualifierCount() const;
315
316     ///
317     Uint32 findProperty(const CIMName& name) const;
318
319     ///
320     CIMConstProperty getProperty(Uint32 index) const;
321
322     ///
323     Uint32 getPropertyCount() const;
324
325     ///
326     CIMObjectPath buildPath(const CIMConstClass& cimClass) const;
327
328     ///
329     CIMInstance clone() const;
330
331     ///
332     Boolean identical(const CIMConstInstance& x) const;
333
334     ///
335     Boolean isUninitialized() const;
336
337 private:
338
339     CIMInstanceRep* _rep;
340
341     void _checkRep() const;
342
343     friend class CIMInstance;
344     friend class CIMObject;
345     friend class CIMConstObject;
346     friend class XmlWriter;
347     friend class MofWriter;
348 };
349
350 #define PEGASUS_ARRAY_T CIMInstance
351 # include <Pegasus/Common/ArrayInter.h>
352 #undef PEGASUS_ARRAY_T
353
354 PEGASUS_NAMESPACE_END
355
356 #endif /* Pegasus_Instance_h */