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