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