1 mike 1.6 //%/////////////////////////////////////////////////////////////////////////////
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.9 // 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.6 // 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.9 //
12 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
|
13 mike 1.6 // 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.9 // 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.6 // 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.7 #ifndef Pegasus_Object_h
30 #define Pegasus_Object_h
|
31 mike 1.6
32 #include <Pegasus/Common/Config.h>
|
33 mike 1.7 #include <Pegasus/Common/CIMObjectRep.h>
|
34 mike 1.6
35 PEGASUS_NAMESPACE_BEGIN
36
|
37 mike 1.7 class CIMClass;
38 class CIMConstClass;
39 class CIMInstance;
40 class CIMConstInstance;
41
42 ////////////////////////////////////////////////////////////////////////////////
43 //
44 // CIMObject
45 //
46 ////////////////////////////////////////////////////////////////////////////////
47
48 class CIMConstObject;
49 class CIMObject;
50
|
51 chip 1.9 /** This class either refers to a CIMInstance or a CIMClass.
|
52 mike 1.7
53 The CIMObjectRep data member points to either a CIMInstanceRep or
54 CIMClassRep.
|
55 mike 1.6 */
56 class PEGASUS_COMMON_LINKAGE CIMObject
57 {
58 public:
59
|
60 mike 1.7 /** Constructor.
61 */
62 CIMObject() : _rep(0)
|
63 mike 1.6 {
64
65 }
66
|
67 mike 1.7 /** Copy constructor.
68 */
69 CIMObject(const CIMObject& x)
|
70 mike 1.6 {
71 Inc(_rep = x._rep);
72 }
73
|
74 mike 1.7 /** Construction from CIMClass.
75 */
76 CIMObject(const CIMClass& x);
|
77 mike 1.6
|
78 mike 1.7 /** Construction from CIMInstance.
79 */
80 CIMObject(const CIMInstance& x);
|
81 mike 1.6
|
82 mike 1.7 /** Assignment operator.
83 */
|
84 mike 1.6 CIMObject& operator=(const CIMObject& x)
85 {
86 if (x._rep != _rep)
87 {
|
88 kumpf 1.15 if (_rep)
89 {
90 Dec(_rep);
91 }
|
92 mike 1.6 Inc(_rep = x._rep);
93 }
94 return *this;
95 }
96
|
97 mike 1.7 /** Assignment operator.
98 */
99 CIMObject& operator=(const CIMClass& x);
100
101 /** Assignment operator.
102 */
103 CIMObject& operator=(const CIMInstance& x);
104
|
105 chip 1.9 /** Destructor.
|
106 mike 1.7 */
107 ~CIMObject()
108 {
|
109 kumpf 1.15 if (_rep)
110 {
111 Dec(_rep);
112 }
|
113 mike 1.7 }
114
|
115 karl 1.13 /** Accessor for ClassName component of the object.
116 @return - Returns the ClassName of the object in
117 a String parameter.
118 <pre>
119 String className;
120 CIMClass myclass("myclass", "superclass");
121 className = myclass.getClassName;
122 </pre>
|
123 mike 1.7 */
124 const String& getClassName() const
125 {
126 _checkRep();
127 return _rep->getClassName();
128 }
129
|
130 karl 1.14 /** equalClassName Compares ClassName with a String. This test performs
|
131 karl 1.13 a comparison of the classname component of the object
132 with a String. Note that this function was included specifically
133 because the equality compare is not just a straight comparison
134 because classnames are case independent.
135 @param classname String containing the name for comparison
136 @return True if it is the same class name (equalNoCase compare passes)
137 or false if not.
138 */
|
139 karl 1.14 const Boolean equalClassName(const String& classname) const
|
140 karl 1.13 {
141 _checkRep();
|
142 karl 1.14 return _rep->equalClassName(classname);
|
143 karl 1.13
144 }
|
145 chip 1.12 const CIMReference& getPath() const
146 {
147 _checkRep();
148 return _rep->getPath();
149 }
150
|
151 mike 1.7 /** addQualifier - Adds the CIMQualifier object to the instance.
152 Thows an exception of the CIMQualifier already exists in the instance
153 @param CIMQualifier object to add to instance
154 @return ATTN:
155 @exception Throws AlreadyExists.
156 */
157 CIMObject& addQualifier(const CIMQualifier& qualifier)
158 {
159 _checkRep();
160 _rep->addQualifier(qualifier);
161 return *this;
162 }
163
164 /** findQualifier - Searches the instance for the qualifier object
165 defined by the input parameter.
166 @param String defining the qualifier object to be found.
167 @return - Position of the qualifier to be used in subsequent
168 operations or PEG_NOT_FOUND if the qualifier is not found.
169 */
170 Uint32 findQualifier(const String& name)
171 {
172 mike 1.7 _checkRep();
173 return _rep->findQualifier(name);
174 }
175
176 Uint32 findQualifier(const String& name) const
177 {
178 _checkRep();
179 return _rep->findQualifier(name);
180 }
181
182 /** existsQualifier - Searches the instance for the qualifier object
183 defined by the input parameter.
184 @param String defining the qualifier object to be found.
185 @return - Returns True if the qualifier object exists or false
186 if the qualifier is not found.
187 */
188 Boolean existsQualifier(const String& name)
189 {
190 _checkRep();
191 return _rep->existsQualifier(name);
192 }
193 mike 1.7
194 Boolean existsQualifier(const String& name) const
195 {
196 _checkRep();
197 return _rep->existsQualifier(name);
198 }
199
200 /** getQualifier - Retrieves the qualifier object defined by the
201 index input parameter. @ index for the qualifier object.
202 The index to qualifier objects is zero-origin and continuous
203 so that incrementing loops can be used to get all qualifier
204 objects in a CIMInstnace.
205 @return: Returns qualifier object defined by index.
206 @exception Throws the OutOfBounds exception if the index
207 is out of bounds
208 */
209 CIMQualifier getQualifier(Uint32 pos)
210 {
211 _checkRep();
212 return _rep->getQualifier(pos);
213 }
214 mike 1.7
215 /** getQualifier - Retrieves the qualifier object defined by the
216 index input parameter. @ index for the qualifier object.
217 The index to qualifier objects is zero-origin and continuous
218 so that incrementing loops can be used to get all qualifier
219 objects in a CIMInstnace.
220 @return: Returns qualifier object defined by index.
221 @exception Throws the OutOfBounds exception if the index
222 is out of bounds
223 ATTN: What is effect of out of range index???
224 ATTN: Is the above statement correct???
225 */
226 CIMConstQualifier getQualifier(Uint32 pos) const
227 {
228 _checkRep();
229 return _rep->getQualifier(pos);
230 }
231
|
232 chip 1.11 void removeQualifier(Uint32 pos)
233 {
234 _checkRep();
235 _rep->removeQualifier(pos);
236 }
237
238 /** getQualifierCount - Gets the numbercount of CIMQualifierobjects
|
239 mike 1.7 defined for this CIMObject.
240 @return Count of the number of CIMQalifier objects in the
241 CIMObject.
242 @exception Throws the OutOfBounds exception if the index
243 is out of bounds
244 */
245 Uint32 getQualifierCount() const
246 {
247 _checkRep();
248 return _rep->getQualifierCount();
249 }
250
251 /** addProperty - Adds a property object defined by the input
252 parameter to the CIMObject
253 @param Property Object to be added. See the CIM Property
254 class for definition of the property object
255 @return ATTN:
256 @exception Throws the exception AlreadyExists if the property
257 already exists.
258 */
259 CIMObject& addProperty(const CIMProperty& x)
260 mike 1.7 {
261 _checkRep();
262 _rep->addProperty(x);
263 return *this;
264 }
265
266 /** findProperty - Searches the CIMProperty objects installed in the
267 CIMObject for property objects with the name defined by the
268 input.
269 @param String with the name of the property object to be found
270 @return Position in the CIM object to the property object if found or
271 PEG_NOT_FOUND if no property object found with the name defined by the
272 input.
273 */
274 Uint32 findProperty(const String& name)
275 {
276 _checkRep();
277 return _rep->findProperty(name);
278 }
279
280 Uint32 findProperty(const String& name) const
281 mike 1.7 {
282 _checkRep();
283 return _rep->findProperty(name);
284 }
285
286 /** existsPropery - Determines if a property object with the
287 name defined by the input parameter exists in the class.
288 @parm String parameter with the property name.
289 @return True if the property object exists.
290 */
291 Boolean existsProperty(const String& name)
292 {
293 _checkRep();
294 return _rep->existsProperty(name);
295 }
296
297 Boolean existsProperty(const String& name) const
298 {
299 _checkRep();
300 return _rep->existsProperty(name);
301 }
302 mike 1.7
303 /** getProperty - Gets the CIMproperty object in the CIMObject defined
304 by the input index parameter.
305 @param Index to the property object in the CIMObject.
306 The index to qualifier objects is zero-origin and continuous
307 so that incrementing loops can be used to get all qualifier
308 objects in a CIMObject.
309 @return CIMProperty object corresponding to the index.
310 @exception Throws the OutOfBounds exception if the index
311 is out of bounds
312
313 ATTN: What is the effect of out of range?
314 */
315 CIMProperty getProperty(Uint32 pos)
316 {
317 _checkRep();
318 return _rep->getProperty(pos);
319 }
320
321 /** getProperty - Gets the CIMproperty object in the CIMObject defined
322 by the input index parameter.
323 mike 1.7 @param Index to the property object in the CIMObject.
324 The index to qualifier objects is zero-origin and continuous
325 so that incrementing loops can be used to get all qualifier
326 objects in a CIMInstnace.
327 @return CIMProperty object corresponding to the index.
328 @exception Throws the OutOfBounds exception if the index
329 is out of bounds
330
331 ATTN: What is the effect of out of range?
332 */
333 CIMConstProperty getProperty(Uint32 pos) const
334 {
335 _checkRep();
336 return _rep->getProperty(pos);
337 }
338
339 /** removeProperty - Removes the property represented
340 by the position input parameter from the instance.
341 @param pos Index to the property to be removed from the
342 instance. Normally this is obtained by getProperty();
343 @exception Throws OutofBounds if index is not a property object
344 mike 1.7 */
345 void removeProperty(Uint32 pos)
346 {
347 _checkRep();
348 _rep->removeProperty(pos);
349 }
350
351 /** getPropertyCount - Gets the numbercount of CIMProperty
352 objects defined for this CIMObject.
353 @return Count of the number of CIMProperty objects in the
354 CIMObject. Zero indicates that no CIMProperty objects
355 are contained in the CIMObject
356 @exception Throws the OutOfBounds exception if the index
357 is out of bounds
358
359 */
360 Uint32 getPropertyCount() const
361 {
362 _checkRep();
363 return _rep->getPropertyCount();
364 }
365 mike 1.7
366 /** operator int() - ATTN: */
367 operator int() const { return _rep != 0; }
368
369 /** Returns true if the two classes are structurally identical.
370 */
371 Boolean identical(const CIMConstObject& x) const;
372
373 /** Convert object to XML format.
374 */
|
375 mike 1.8 void toXml(Array<Sint8>& out) const
|
376 mike 1.7 {
377 _checkRep();
378 _rep->toXml(out);
379 }
380
381 /** Clones the given object.
382 */
383 CIMObject clone() const
384 {
385 _checkRep();
386 return CIMObject(_rep->clone());
387 }
388
389 private:
390
391 CIMObject(CIMObjectRep* rep) : _rep(rep)
392 {
393
394 }
395
396 void _checkRep() const
397 mike 1.7 {
398 if (!_rep)
399 ThrowUnitializedHandle();
400 }
401
|
402 chip 1.10 CIMObjectRep* _rep;
|
403 mike 1.7
404 friend class CIMConstObject;
405 friend class CIMClass;
406 friend class CIMConstClass;
407 friend class CIMInstance;
408 friend class CIMConstInstance;
409 };
410
411 ////////////////////////////////////////////////////////////////////////////////
412 //
413 // CIMConstObject
414 //
415 ////////////////////////////////////////////////////////////////////////////////
416
417 class PEGASUS_COMMON_LINKAGE CIMConstObject
418 {
419 public:
420
421 CIMConstObject() : _rep(0)
422 {
423
424 mike 1.7 }
425
426 CIMConstObject(const CIMConstObject& x)
427 {
428 Inc(_rep = x._rep);
429 }
430
431 CIMConstObject(const CIMObject& x)
432 {
433 Inc(_rep = x._rep);
434 }
435
436 /** Construction from CIMClass.
437 */
438 CIMConstObject(const CIMClass& x);
439
440 /** Construction from CIMInstance.
441 */
442 CIMConstObject(const CIMInstance& x);
443
444 /** Construction from CIMClass.
445 mike 1.7 */
446 CIMConstObject(const CIMConstClass& x);
447
448 /** Construction from CIMInstance.
449 */
450 CIMConstObject(const CIMConstInstance& x);
451
452 CIMConstObject& operator=(const CIMConstObject& x)
|
453 mike 1.6 {
454 if (x._rep != _rep)
455 {
|
456 kumpf 1.15 if (_rep)
457 {
458 Dec(_rep);
459 }
|
460 mike 1.6 Inc(_rep = x._rep);
461 }
462 return *this;
463 }
464
|
465 mike 1.7 CIMConstObject& operator=(const CIMObject& x)
|
466 mike 1.6 {
467 if (x._rep != _rep)
468 {
|
469 kumpf 1.15 if (_rep)
470 {
471 Dec(_rep);
472 }
|
473 mike 1.6 Inc(_rep = x._rep);
474 }
475 return *this;
476 }
477
|
478 mike 1.7 CIMConstObject& operator=(const CIMClass& x);
479
480 CIMConstObject& operator=(const CIMConstClass& x);
481
482 CIMConstObject& operator=(const CIMInstance& x);
483
484 CIMConstObject& operator=(const CIMConstInstance& x);
485
486 ~CIMConstObject()
|
487 mike 1.6 {
|
488 kumpf 1.15 if (_rep)
489 {
490 Dec(_rep);
491 }
|
492 mike 1.6 }
493
|
494 mike 1.7 const String& getClassName() const
|
495 mike 1.6 {
|
496 mike 1.7 _checkRep();
497 return _rep->getClassName();
|
498 chip 1.12 }
499
500 const CIMReference& getPath() const
501 {
502 _checkRep();
503 return _rep->getPath();
|
504 mike 1.6 }
505
|
506 mike 1.7 Uint32 findQualifier(const String& name) const
|
507 mike 1.6 {
|
508 mike 1.7 _checkRep();
509 return _rep->findQualifier(name);
|
510 mike 1.6 }
511
|
512 mike 1.7 CIMConstQualifier getQualifier(Uint32 pos) const
513 {
514 _checkRep();
515 return _rep->getQualifier(pos);
516 }
517
518 Uint32 getQualifierCount() const
519 {
520 _checkRep();
521 return _rep->getQualifierCount();
522 }
523
524 Uint32 findProperty(const String& name) const
525 {
526 _checkRep();
527 return _rep->findProperty(name);
528 }
|
529 mike 1.6
|
530 mike 1.7 CIMConstProperty getProperty(Uint32 pos) const
531 {
532 _checkRep();
533 return _rep->getProperty(pos);
534 }
|
535 mike 1.6
|
536 mike 1.7 Uint32 getPropertyCount() const
537 {
538 _checkRep();
539 return _rep->getPropertyCount();
540 }
|
541 mike 1.6
|
542 mike 1.7 operator int() const { return _rep != 0; }
|
543 mike 1.6
|
544 mike 1.7 void toXml(Array<Sint8>& out) const
545 {
546 _checkRep();
547 _rep->toXml(out);
548 }
|
549 mike 1.6
|
550 mike 1.7 void print(PEGASUS_STD(ostream) &o=PEGASUS_STD(cout)) const
551 {
552 _checkRep();
553 _rep->print(o);
554 }
|
555 mike 1.6
|
556 mike 1.7 Boolean identical(const CIMConstObject& x) const
557 {
558 x._checkRep();
559 _checkRep();
560 return _rep->identical(x._rep);
|
561 mike 1.6 }
562
|
563 mike 1.7 CIMObject clone() const
564 {
565 return CIMObject(_rep->clone());
566 }
|
567 mike 1.6
568 private:
569
570 void _checkRep() const
571 {
572 if (!_rep)
573 ThrowUnitializedHandle();
574 }
575
|
576 mike 1.7 CIMObjectRep* _rep;
|
577 mike 1.6
|
578 mike 1.7 friend class CIMObject;
579 friend class CIMClass;
580 friend class CIMConstClass;
581 friend class CIMInstance;
582 friend class CIMConstInstance;
|
583 mike 1.6 };
584
585 /** The CIMObjectWithPath encapsulates a CIMReference and CIMObject.
586 Accessors are provided for getting the two parts. Constructors are
587 provided for initializing it from a CIMObject.
588 */
589 class PEGASUS_COMMON_LINKAGE CIMObjectWithPath
590 {
591 public:
592
593 /** Constructor
594 */
595 CIMObjectWithPath();
596
597 /** constructor
598 */
599 CIMObjectWithPath(const CIMReference& reference, const CIMObject& object);
600
601 /** Constructor - Constructs a CIMObjectWithPath Object from
602 another CimObjectWithPath
603 @param - ATTN
604 mike 1.6 */
605 CIMObjectWithPath(const CIMObjectWithPath& x);
606
607 ~CIMObjectWithPath();
608
609 CIMObjectWithPath& operator=(const CIMObjectWithPath& x);
610
|
611 chip 1.9 /** set -
|
612 mike 1.6 */
613 void set(const CIMReference& reference, const CIMObject& object);
614
615 /**
616 */
617 const CIMReference& getReference() const { return _reference; }
618
619 /**
620 */
621 const CIMObject& getObject() const { return _object; }
622
623 /**
624 */
625 CIMReference& getReference() { return _reference; }
626
627 /**
628 */
629 CIMObject& getObject() { return _object; }
630
631 /**
632 */
633 mike 1.6 void toXml(Array<Sint8>& out) const;
634
635 private:
636
637 CIMReference _reference;
638 CIMObject _object;
639 };
640
641 PEGASUS_NAMESPACE_END
642
|
643 mike 1.7 #endif /* Pegasus_Object_h */
|