1 mike 1.1 //%/////////////////////////////////////////////////////////////////////////////
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.1 //
23 // Author: Mike Brasher (mbrasher@bmc.com)
24 //
25 // Modified By:
26 //
27 //%/////////////////////////////////////////////////////////////////////////////
28
29 #ifndef Pegasus_CIMObject_h
30 #define Pegasus_CIMObject_h
31
32 #include <Pegasus/Common/Config.h>
33 #include <Pegasus/Common/CIMClass.h>
34 #include <Pegasus/Common/CIMInstance.h>
35
36 PEGASUS_NAMESPACE_BEGIN
37
38 /** This class contains either a class or an instance (both CIM objects).
39 Initializers are provided for both CIMClass and CIMInstance. The
40 isClass() and isInstance() methods are provided for determining the
41 type of contained object. Methods are also provided for getting
42 the internal object (into a CIMClass or CIMInstance).
43 mike 1.1 */
44 class PEGASUS_COMMON_LINKAGE CIMObject
45 {
46 public:
47
48 CIMObject() : _rep(0)
49 {
50
51 }
52
53 CIMObject(const CIMObject& x)
54 {
55 Inc(_rep = x._rep);
56 }
57
58 CIMObject(const CIMClass& x)
59 {
60 Inc(_rep = x._rep);
61 }
62
63 CIMObject(const CIMInstance& x)
64 mike 1.1 {
65 Inc(_rep = x._rep);
66 }
67
68 CIMObject& operator=(const CIMObject& x)
69 {
70 if (x._rep != _rep)
71 {
72 Dec(_rep);
73 Inc(_rep = x._rep);
74 }
75 return *this;
76 }
77
78 CIMObject& operator=(const CIMClass& x)
79 {
80 if (x._rep != _rep)
81 {
82 Dec(_rep);
83 Inc(_rep = x._rep);
84 }
85 mike 1.1 return *this;
86 }
87
88 CIMObject& operator=(const CIMInstance& x)
89 {
90 if (x._rep != _rep)
91 {
92 Dec(_rep);
93 Inc(_rep = x._rep);
94 }
95 return *this;
96 }
97
98 ~CIMObject()
99 {
100 Dec(_rep);
101 }
102
103 Boolean isClass() const
104 {
105 _checkRep();
106 mike 1.1 return dynamic_cast<CIMClassRep*>(_rep) != 0;
107 }
108
109 Boolean isInstance() const
110 {
111 _checkRep();
112 return dynamic_cast<CIMInstanceRep*>(_rep) != 0;
113 }
114
115 /** Returns the class contained by this object (if an class).
116 @return CIMClass
117 @exception throws TypeMismatch if object does not contain a CIMClass.
118 */
119 CIMClass getClass();
120
|
142 mike 1.1 private:
143
144 void _checkRep() const
145 {
146 if (!_rep)
147 ThrowUnitializedHandle();
148 }
149
150 // Point to either a CIMClass or CIMInstance:
151
152 Sharable* _rep;
153 };
154
155 /** The CIMObjectWithPath encapsulates a CIMReference and CIMObject.
156 Accessors are provided for getting the two parts. Constructors are
157 provided for initializing it from a CIMObject.
158 */
159 class PEGASUS_COMMON_LINKAGE CIMObjectWithPath
160 {
161 public:
162
163 mike 1.1 CIMObjectWithPath();
164
165 CIMObjectWithPath(CIMReference& reference, CIMObject& object);
166
167 CIMObjectWithPath(const CIMObjectWithPath& x);
168
169 ~CIMObjectWithPath();
170
171 CIMObjectWithPath& operator=(const CIMObjectWithPath& x);
172
173 void set(CIMReference& reference, CIMObject& object);
174
175 const CIMReference& getReference() const { return _reference; }
176
177 const CIMObject& getObject() const { return _object; }
178
179 CIMReference& getReference() { return _reference; }
180
181 CIMObject& getObject() { return _object; }
|