1 thilo.boehm 1.2 //%LICENSE////////////////////////////////////////////////////////////////
2 //
3 // Licensed to The Open Group (TOG) under one or more contributor license
4 // agreements. Refer to the OpenPegasusNOTICE.txt file distributed with
5 // this work for additional information regarding copyright ownership.
6 // Each contributor licenses this file to you under the OpenPegasus Open
7 // Source License; you may not use this file except in compliance with the
8 // License.
9 //
10 // Permission is hereby granted, free of charge, to any person obtaining a
11 // copy of this software and associated documentation files (the "Software"),
12 // to deal in the Software without restriction, including without limitation
13 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
14 // and/or sell copies of the Software, and to permit persons to whom the
15 // Software is furnished to do so, subject to the following conditions:
16 //
17 // The above copyright notice and this permission notice shall be included
18 // in all copies or substantial portions of the Software.
19 //
20 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
21 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22 thilo.boehm 1.2 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
23 // IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
24 // CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
25 // TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
26 // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27 //
28 //////////////////////////////////////////////////////////////////////////
29 //
|
35 thilo.boehm 1.2 //%/////////////////////////////////////////////////////////////////////////////
36
37 #ifndef _SCMOCLASS_H_
38 #define _SCMOCLASS_H_
39
40
41 #include <Pegasus/Common/Config.h>
42 #include <Pegasus/Common/Linkage.h>
43 #include <Pegasus/Common/SCMO.h>
44 #include <Pegasus/Common/CIMClass.h>
45 #include <Pegasus/Common/CIMClassRep.h>
46 #include <Pegasus/Common/CIMObjectRep.h>
47
48 PEGASUS_NAMESPACE_BEGIN
49
50
51 #define PEGASUS_SCMB_CLASS_MAGIC 0xF00FABCD
52
53 class PEGASUS_COMMON_LINKAGE SCMOClass
54 {
55 public:
56 thilo.boehm 1.2
57 /**
58 * Constructs a SCMOClass out of a CIMClass.
59 * @param theCIMClass The source the SCMOClass is constructed off.
60 * @param nameSpaceName The namespace for the class, optional.
61 * @return
62 */
63 SCMOClass(const CIMClass& theCIMClass, const char* altNameSpace=0 );
64
65 /**
66 * Copy constructor for the SCMO class, used to implement refcounting.
67 * @param theSCMOClass The class for which to create a copy
68 * @return
69 */
70 SCMOClass(const SCMOClass& theSCMOClass )
71 {
72 cls.hdr = theSCMOClass.cls.hdr;
73 Ref();
74 }
75
76 /**
77 thilo.boehm 1.2 * Constructs a SCMOClass from a memory object of type SCMBClass_Main.
78 * It incremets the referece counter of the memory object.
79 * @param hdr A memory object of type SCMBClass_Main.
80 **/
81 SCMOClass(SCMBClass_Main* hdr)
82 {
83 cls.hdr = hdr;
84 Ref();
85 }
86
87 /**
88 * Assignment operator for the SCMO class,
89 * @param theSCMOClass The right hand value
90 **/
91 SCMOClass& operator=(const SCMOClass& theSCMOClass)
92 {
93 if (cls.hdr != theSCMOClass.cls.hdr)
94 {
95 Unref();
96 cls.hdr = theSCMOClass.cls.hdr;
97 Ref();
98 thilo.boehm 1.2 }
99 return *this;
100 }
101
102 /**
103 * Constructs an empty SCMOClass only with name space and class name.
104 *
105 * If you construct a SCMOInstance using this class, you must mark it as
106 * compromized using SCMOInstance.markAsCompromised().
107 *
108 * @param className The name for the class.
109 * @param nameSpaceName The namespace for the class.
110 */
111 SCMOClass(const char* className, const char* nameSpaceName );
112
113
114 /**
115 * Destructor is decrementing the refcount. If refcount is zero, the
116 * singele chunk memory object is deallocated.
117 */
118 ~SCMOClass()
119 thilo.boehm 1.2 {
120 Unref();
121 }
122
123 /**
124 * Converts the SCMOClass into a CIMClass.
125 * It is a deep copy of the SCMOClass into the CIMClass.
126 * @param cimClass An empty CIMClass.
127 */
128 void getCIMClass(CIMClass& cimClass) const;
129
130 /**
131 * Gets the key property names as a string array
132 * @return An Array of String objects containing the names of the key
133 * properties.
134 */
135 void getKeyNamesAsString(Array<String>& keyNames) const;
136
137 /**
138 * Gets the super class name of the class.
139 * @retuns The super class name.
140 thilo.boehm 1.2 * If not available a NULL pointer is returned
141 */
142 const char* getSuperClassName() const;
143
144 /**
145 * Gets the super class name of the class.
146 * @param Return strlen of result string.
147 * @retuns The super class name.
148 * If not available a NULL pointer is returned
149 */
150 const char* getSuperClassName_l(Uint32 & length) const;
151
152 static StrLit qualifierNameStrLit(Uint32 num)
153 {
154 return _qualifierNameStrLit[num];
155 }
156
157 /**
158 * Determines if the SCMOClass is an empty class.
159 * A empty class is a class with no information about properties.
160 * Maybe only the class name and/or name space are available.
161 thilo.boehm 1.2 * @return True if it an empty class.
162 **/
163 Boolean isEmpty( )const
164 {
165 // The size of one indicates that only an empty string was stored.
166 return (cls.hdr->flags.isEmpty);
167 }
168
169 private:
170
171 void Ref()
172 {
173 cls.hdr->refCount++;
174 };
175
176 void Unref()
177 {
178 if (cls.hdr->refCount.decAndTestIfZero())
179 {
180 _destroyExternalReferences();
181 free(cls.base);
182 thilo.boehm 1.2 cls.base=0;
183 }
184
185 };
186
187 /**
188 * Constructs an empty SCMOClass object.
189 */
190 SCMOClass();
191
192 inline void _initSCMOClass();
193
194 void _destroyExternalReferences();
195
196 SCMO_RC _getProperyNodeIndex(Uint32& node, const char* name) const;
197 SCMO_RC _getKeyBindingNodeIndex(Uint32& node, const char* name) const;
198
199 void _setClassQualifers(const CIMQualifierList& theQualifierList);
200
201 QualifierNameEnum _setQualifier(
202 Uint64 start,
203 thilo.boehm 1.2 const CIMQualifier& theCIMQualifier);
204
205 void _setClassProperties(PropertySet& theCIMProperties);
206
207 void _setProperty(
208 Uint64 start,
209 Boolean* isKey,
210 const CIMProperty& theCIMProperty);
211
212 Boolean _setPropertyQualifiers(
213 Uint64 start,
214 const CIMQualifierList& theQualifierList);
215
216 void _setClassKeyBinding(Uint64 start, const CIMProperty& theCIMProperty);
217 void _insertPropertyIntoOrderedSet(Uint64 start, Uint32 newIndex);
218 void _insertKeyBindingIntoOrderedSet(Uint64 start, Uint32 newIndex);
219
220 void _setPropertyAsKeyInMask(Uint32 i);
221 Boolean _isPropertyKey(Uint32 i);
222
223 void _setValue(Uint64 start, const CIMValue& theCIMValue);
224 thilo.boehm 1.2
225 QualifierNameEnum _getSCMOQualifierNameEnum(const CIMName& theCIMname);
226 Boolean _isSamePropOrigin(Uint32 node, const char* origin) const;
227
228 const char* _getPropertyNameAtNode(Uint32 propNode) const;
229
230 SCMO_RC _isNodeSameType(
231 Uint32 node,
232 CIMType type,
233 Boolean isArray,
234 CIMType& realType) const;
235
236 CIMProperty _getCIMPropertyAtNodeIndex(Uint32 nodeIdx) const;
237 static void _getCIMQualifierFromSCMBQualifier(
238 CIMQualifier& theCIMQualifier,
239 const SCMBQualifier& scmbQualifier,
240 const char* base);
241
242 union{
243 // To access the class main structure
244 SCMBClass_Main *hdr;
245 thilo.boehm 1.2 // To access the memory management header
246 SCMBMgmt_Header *mem;
247 // Generic access pointer
248 char *base;
249 }cls;
250
251 static const StrLit _qualifierNameStrLit[72];
252
253 friend class SCMOInstance;
254 friend class SCMODump;
255 friend class SCMOXmlWriter;
256 friend class SCMOClassCache;
257 friend class SCMOStreamer;
258 };
259
260
261 PEGASUS_NAMESPACE_END
262
263 #endif
|