1 mike 1.23 //%/////////////////////////////////////////////////////////////////////////////
2 //
3 // Copyright (c) 2000, 2001 The Open group, BMC Software, Tivoli Systems, IBM
4 //
5 // Permission is hereby granted, free of charge, to any person obtaining a copy
|
6 chip 1.26 // of this software and associated documentation files (the "Software"), to
7 // deal in the Software without restriction, including without limitation the
8 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
9 mike 1.23 // sell copies of the Software, and to permit persons to whom the Software is
10 // furnished to do so, subject to the following conditions:
|
11 chip 1.26 //
12 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
|
13 mike 1.23 // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
14 // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
15 chip 1.26 // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
16 // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
17 // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
18 mike 1.23 // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
19 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20 //
21 //==============================================================================
22 //
23 // Author: Mike Brasher (mbrasher@bmc.com)
24 //
25 // Modified By:
26 //
27 //%/////////////////////////////////////////////////////////////////////////////
28
|
29 mike 1.25 #ifndef Pegasus_Instance_h
30 #define Pegasus_Instance_h
|
31 mike 1.23
32 #include <Pegasus/Common/Config.h>
|
33 mike 1.25 #include <Pegasus/Common/CIMObject.h>
|
34 mike 1.23 #include <Pegasus/Common/CIMInstanceRep.h>
35
36 PEGASUS_NAMESPACE_BEGIN
37
38 ////////////////////////////////////////////////////////////////////////////////
39 //
40 // CIMInstance
41 //
42 ////////////////////////////////////////////////////////////////////////////////
43
44 class CIMConstInstance;
45 class CIMObject;
|
46 mike 1.25 class CIMConstObject;
|
47 mike 1.23
|
48 mike 1.27 /** This class represents the instance of a CIM class. It is used manipulate
49 instances and their parts.
|
50 mike 1.23 */
51 class PEGASUS_COMMON_LINKAGE CIMInstance
52 {
53 public:
54
55 /** Constructor - Create a CIM Instance object.
56 @return Instance created
57 */
58 CIMInstance() : _rep(0)
59 {
60
61 }
62
63 /** Constructor - Create a CIMInstance object from another Instance.
64 @param Instance object from which the new instance is created.
65 @return New instance
66 */
67 CIMInstance(const CIMInstance& x)
68 {
69 Inc(_rep = x._rep);
70 }
71 mike 1.23
|
72 mike 1.25 PEGASUS_EXPLICIT CIMInstance(const CIMObject& x);
73
74 PEGASUS_EXPLICIT CIMInstance(const CIMObject& x, NoThrow&);
75
|
76 mike 1.23 /** Constructor. */
77 CIMInstance& operator=(const CIMInstance& x)
78 {
79 if (x._rep != _rep)
80 {
81 Dec(_rep);
82 Inc(_rep = x._rep);
83 }
84 return *this;
85 }
86
87 /** Constructor - Creates an Instance object with the classname
88 from the input parameters
89 @param - String className to be used with new instance object
90 @return The new instance object
91 @exception Throws IllegalName if className argument not legal CIM
92 identifier. ATTN: Clarify the defintion of legal CIM identifier.
93 */
94 CIMInstance(const String& className)
95 {
96 _rep = new CIMInstanceRep(className);
97 mike 1.23 }
98
99 /** Destructor. */
100 ~CIMInstance()
101 {
102 Dec(_rep);
103 }
104
105 /** getClassName - Returns the class name of the instance
106 @return String with the class name.
107 */
108 const String& getClassName() const
109 {
110 _checkRep();
111 return _rep->getClassName();
112 }
113
|
114 chip 1.26 const CIMReference& getPath() const
115 {
116 _checkRep();
117 return _rep->getPath();
118 }
119
|
120 mike 1.23 /** addQualifier - Adds the CIMQualifier object to the instance.
121 Thows an exception of the CIMQualifier already exists in the instance
122 @param CIMQualifier object to add to instance
123 @return ATTN:
124 @exception Throws AlreadyExists.
125 */
126 CIMInstance& addQualifier(const CIMQualifier& qualifier)
127 {
128 _checkRep();
129 _rep->addQualifier(qualifier);
130 return *this;
131 }
132
133 /** findQualifier - Searches the instance for the qualifier object
134 defined by the input parameter.
135 @param String defining the qualifier object to be found.
136 @return - Position of the qualifier to be used in subsequent
137 operations or PEG_NOT_FOUND if the qualifier is not found.
138 */
139 Uint32 findQualifier(const String& name)
140 {
141 mike 1.23 _checkRep();
142 return _rep->findQualifier(name);
143 }
144
145 Uint32 findQualifier(const String& name) const
146 {
147 _checkRep();
148 return _rep->findQualifier(name);
149 }
|
150 mike 1.24
|
151 mike 1.23 /** existsQualifier - Searches the instance for the qualifier object
152 defined by the input parameter.
153 @param String defining the qualifier object to be found.
154 @return - Returns True if the qualifier object exists or false
155 if the qualifier is not found.
156 */
|
157 mike 1.25 Boolean existsQualifier(const String& name)
|
158 mike 1.23 {
159 _checkRep();
160 return _rep->existsQualifier(name);
161 }
162
|
163 mike 1.25 Boolean existsQualifier(const String& name) const
|
164 mike 1.23 {
165 _checkRep();
166 return _rep->existsQualifier(name);
167 }
168
169 /** getQualifier - Retrieves the qualifier object defined by the
170 index input parameter. @ index for the qualifier object.
171 The index to qualifier objects is zero-origin and continuous
172 so that incrementing loops can be used to get all qualifier
173 objects in a CIMInstnace.
174 @return: Returns qualifier object defined by index.
175 @exception Throws the OutOfBounds exception if the index
176 is out of bounds
177 */
178 CIMQualifier getQualifier(Uint32 pos)
179 {
180 _checkRep();
181 return _rep->getQualifier(pos);
182 }
183
184 /** getQualifier - Retrieves the qualifier object defined by the
185 mike 1.23 index input parameter. @ index for the qualifier object.
186 The index to qualifier objects is zero-origin and continuous
187 so that incrementing loops can be used to get all qualifier
188 objects in a CIMInstnace.
189 @return: Returns qualifier object defined by index.
190 @exception Throws the OutOfBounds exception if the index
191 is out of bounds
192 ATTN: What is effect of out of range index???
193 ATTN: Is the above statement correct???
194 */
195 CIMConstQualifier getQualifier(Uint32 pos) const
196 {
197 _checkRep();
198 return _rep->getQualifier(pos);
199 }
200
201 /** getQualifierCount - Gets the numbercount of CIMQualifierobjects
202 defined for this CIMInstance.
203 @return Count of the number of CIMQalifier objects in the
204 CIMInstance.
205 @exception Throws the OutOfBounds exception if the index
206 mike 1.23 is out of bounds
207 */
208 Uint32 getQualifierCount() const
209 {
210 _checkRep();
211 return _rep->getQualifierCount();
212 }
213
214 /** addProperty - Adds a property object defined by the input
215 parameter to the CIMInstance
216 @param Property Object to be added. See the CIM Property
217 class for definition of the property object
218 @return ATTN:
219 @exception Throws the exception AlreadyExists if the property
220 already exists.
221 */
222 CIMInstance& addProperty(const CIMProperty& x)
223 {
224 _checkRep();
225 _rep->addProperty(x);
226 return *this;
227 mike 1.23 }
228
229 /** findProperty - Searches the CIMProperty objects installed in the
230 CIMInstance for property objects with the name defined by the
231 input.
232 @param String with the name of the property object to be found
233 @return Position in the CIM Instance to the property object if found or
234 PEG_NOT_FOUND if no property object found with the name defined by the
235 input.
236 */
237 Uint32 findProperty(const String& name)
238 {
239 _checkRep();
240 return _rep->findProperty(name);
241 }
242
243 Uint32 findProperty(const String& name) const
244 {
245 _checkRep();
246 return _rep->findProperty(name);
247 }
248 mike 1.23
249 /** existsPropery - Determines if a property object with the
250 name defined by the input parameter exists in the class.
251 @parm String parameter with the property name.
252 @return True if the property object exists.
253 */
254 Boolean existsProperty(const String& name)
255 {
256 _checkRep();
257 return _rep->existsProperty(name);
258 }
|
259 mike 1.24
|
260 mike 1.23 Boolean existsProperty(const String& name) const
261 {
262 _checkRep();
263 return _rep->existsProperty(name);
264 }
265
266 /** getProperty - Gets the CIMproperty object in the CIMInstance defined
267 by the input index parameter.
268 @param Index to the property object in the CIMInstance.
269 The index to qualifier objects is zero-origin and continuous
270 so that incrementing loops can be used to get all qualifier
271 objects in a CIMInstnace.
272 @return CIMProperty object corresponding to the index.
273 @exception Throws the OutOfBounds exception if the index
274 is out of bounds
275
276 ATTN: What is the effect of out of range?
277 */
278 CIMProperty getProperty(Uint32 pos)
279 {
280 _checkRep();
281 mike 1.23 return _rep->getProperty(pos);
282 }
283
284 /** getProperty - Gets the CIMproperty object in the CIMInstance defined
285 by the input index parameter.
286 @param Index to the property object in the CIMInstance.
287 The index to qualifier objects is zero-origin and continuous
288 so that incrementing loops can be used to get all qualifier
289 objects in a CIMInstnace.
290 @return CIMProperty object corresponding to the index.
291 @exception Throws the OutOfBounds exception if the index
292 is out of bounds
293
294 ATTN: What is the effect of out of range?
295 */
296 CIMConstProperty getProperty(Uint32 pos) const
297 {
298 _checkRep();
299 return _rep->getProperty(pos);
300 }
301
302 mike 1.23 /** removeProperty - Removes the property represented
303 by the position input parameter from the instance.
304 @param pos Index to the property to be removed from the
305 instance. Normally this is obtained by getProperty();
306 @exception Throws OutofBounds if index is not a property object
307 */
308 void removeProperty(Uint32 pos)
309 {
310 _checkRep();
311 _rep->removeProperty(pos);
312 }
313
314 /** getPropertyCount - Gets the numbercount of CIMProperty
315 objects defined for this CIMInstance.
316 @return Count of the number of CIMProperty objects in the
317 CIMInstance. Zero indicates that no CIMProperty objects
318 are contained in the CIMInstance
319 @exception Throws the OutOfBounds exception if the index
320 is out of bounds
321
322 */
323 mike 1.23 Uint32 getPropertyCount() const
324 {
325 _checkRep();
326 return _rep->getPropertyCount();
327 }
328
329 /** operator int() - ATTN: */
330 operator int() const { return _rep != 0; }
331
332 /** resolve - ATTN: */
|
333 mike 1.30 void resolve(
334 DeclContext* declContext,
335 const String& nameSpace,
336 Boolean propagateQualifiers);
|
337 mike 1.23
338 void resolve(
339 DeclContext* declContext,
340 const String& nameSpace,
|
341 mike 1.30 CIMConstClass& cimClassOut,
342 Boolean propagateQualifiers)
|
343 mike 1.23 {
344 _checkRep();
|
345 mike 1.30 _rep->resolve(declContext, nameSpace, cimClassOut, propagateQualifiers);
|
346 mike 1.23 }
347
348 /** toXml - Creates an XML transformation of the CIMInstance
349 compatiblewith the DMTF CIM Operations over HTTP defintions.
350 @return
351 ATTN: This is incorrect and needs to be corrected.
352 */
353 void toXml(Array<Sint8>& out) const
354 {
355 _checkRep();
356 _rep->toXml(out);
357 }
358
359 /** prints the class in XML format. */
360 void print(PEGASUS_STD(ostream) &o=PEGASUS_STD(cout)) const
361 {
362 _checkRep();
363 _rep->print(o);
364 }
365
|
366 karl 1.29 /** toMof - Creates an MOF transformation of the CIMInstance
367 compatiblewith the DMTF specification.
368 @return
369 */
370 void toMof(Array<Sint8>& out) const
371 {
372 _checkRep();
373 _rep->toMof(out);
374 }
|
375 mike 1.23 /** identical - Compares the CIMInstance with another CIMInstance
376 defined by the input parameter for equality of all components.
377 @param CIMInstance to be compared
378 @return Boolean true if they are identical
379 */
380 Boolean identical(const CIMConstInstance& x) const;
381
382 /** CIMMethod
383
384 */
385 CIMInstance clone() const
386 {
|
387 mike 1.25 return CIMInstance((CIMInstanceRep*)(_rep->clone()));
|
388 mike 1.23 }
389
|
390 sage 1.28 /** getInstanceName - Get the instance name of this instance. The class
|
391 mike 1.23 argument is used to determine which fields are keys. The instance
392 name has this from:
393
394 <PRE>
395 ClassName.key1=value1,...,keyN=valueN
396 </PRE>
397
398 The instance name is in standard form (the class name and key name
399 is all lowercase; the keys-value pairs appear in sorted order by
400 key name).
401 */
402 CIMReference getInstanceName(const CIMConstClass& cimClass) const
403 {
404 _checkRep();
405 return _rep->getInstanceName(cimClass);
406 }
407
|
408 sage 1.28 String toString() const
409 {
410 _checkRep();
411 return _rep->toString();
412 }
413
|
414 mike 1.23 private:
415
416 CIMInstance(CIMInstanceRep* rep) : _rep(rep)
417 {
418 }
419
420 void _checkRep() const
421 {
422 if (!_rep)
423 ThrowUnitializedHandle();
424 }
425
426 CIMInstanceRep* _rep;
427 friend class CIMConstInstance;
428 friend class CIMObject;
|
429 mike 1.25 friend class CIMConstObject;
|
430 mike 1.23 };
431
432 ////////////////////////////////////////////////////////////////////////////////
433 //
434 // CIMConstInstance
435 //
436 ////////////////////////////////////////////////////////////////////////////////
437
438 class PEGASUS_COMMON_LINKAGE CIMConstInstance
439 {
440 public:
441
442 CIMConstInstance() : _rep(0)
443 {
444
445 }
446
447 CIMConstInstance(const CIMConstInstance& x)
448 {
449 Inc(_rep = x._rep);
450 }
451 mike 1.23
452 CIMConstInstance(const CIMInstance& x)
453 {
454 Inc(_rep = x._rep);
455 }
456
|
457 mike 1.25 PEGASUS_EXPLICIT CIMConstInstance(const CIMObject& x);
458
459 PEGASUS_EXPLICIT CIMConstInstance(const CIMConstObject& x);
460
461 PEGASUS_EXPLICIT CIMConstInstance(const CIMObject& x, NoThrow&);
462
463 PEGASUS_EXPLICIT CIMConstInstance(const CIMConstObject& x, NoThrow&);
464
|
465 mike 1.23 CIMConstInstance& operator=(const CIMConstInstance& x)
466 {
467 if (x._rep != _rep)
468 {
469 Dec(_rep);
470 Inc(_rep = x._rep);
471 }
472 return *this;
473 }
474
475 CIMConstInstance& operator=(const CIMInstance& x)
476 {
477 if (x._rep != _rep)
478 {
479 Dec(_rep);
480 Inc(_rep = x._rep);
481 }
482 return *this;
483 }
484
485 // Throws IllegalName if className argument not legal CIM identifier.
486 mike 1.23
487 CIMConstInstance(const String& className)
488 {
489 _rep = new CIMInstanceRep(className);
490 }
491
492 ~CIMConstInstance()
493 {
494 Dec(_rep);
495 }
496
497 const String& getClassName() const
498 {
499 _checkRep();
500 return _rep->getClassName();
|
501 chip 1.26 }
502
503 const CIMReference& getPath() const
504 {
505 _checkRep();
506 return _rep->getPath();
|
507 mike 1.23 }
508
509 Uint32 findQualifier(const String& name) const
510 {
511 _checkRep();
512 return _rep->findQualifier(name);
513 }
514
515 CIMConstQualifier getQualifier(Uint32 pos) const
516 {
517 _checkRep();
518 return _rep->getQualifier(pos);
519 }
520
521 Uint32 getQualifierCount() const
522 {
523 _checkRep();
524 return _rep->getQualifierCount();
525 }
526
527 Uint32 findProperty(const String& name) const
528 mike 1.23 {
529 _checkRep();
530 return _rep->findProperty(name);
531 }
532
533 CIMConstProperty getProperty(Uint32 pos) const
534 {
535 _checkRep();
536 return _rep->getProperty(pos);
537 }
538
539 Uint32 getPropertyCount() const
540 {
541 _checkRep();
542 return _rep->getPropertyCount();
543 }
544
545 operator int() const { return _rep != 0; }
546
547 void toXml(Array<Sint8>& out) const
548 {
549 mike 1.23 _checkRep();
550 _rep->toXml(out);
551 }
552
553 void print(PEGASUS_STD(ostream) &o=PEGASUS_STD(cout)) const
554 {
555 _checkRep();
556 _rep->print(o);
557 }
558
559 Boolean identical(const CIMConstInstance& x) const
560 {
561 x._checkRep();
562 _checkRep();
563 return _rep->identical(x._rep);
564 }
565
566 CIMInstance clone() const
567 {
|
568 mike 1.25 return CIMInstance((CIMInstanceRep*)(_rep->clone()));
|
569 mike 1.23 }
570
571 CIMReference getInstanceName(const CIMConstClass& cimClass) const
572 {
573 _checkRep();
574 return _rep->getInstanceName(cimClass);
|
575 sage 1.28 }
576
577 String toString() const
578 {
579 _checkRep();
580 return _rep->toString();
|
581 mike 1.23 }
582
583 private:
584
585 void _checkRep() const
586 {
587 if (!_rep)
588 ThrowUnitializedHandle();
589 }
590
591 CIMInstanceRep* _rep;
592 friend class CIMInstance;
|
593 mike 1.25 friend class CIMObject;
594 friend class CIMConstObject;
|
595 mike 1.23 };
596
597 #define PEGASUS_ARRAY_T CIMInstance
598 # include "ArrayInter.h"
599 #undef PEGASUS_ARRAY_T
600
601 PEGASUS_NAMESPACE_END
602
|
603 mike 1.25 #endif /* Pegasus_Instance_h */
|