(file) Return to SCMOClass.h CVS log (file) (dir) Up to [Pegasus] / pegasus / src / Pegasus / Common

  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                 //
 30 marek       1.3 // This code implements part of PEP#348 - The CMPI infrastructure using SCMO
 31                 // (Single Chunk Memory Objects).
 32                 // The design document can be found on the OpenPegasus website openpegasus.org
 33                 // at https://collaboration.opengroup.org/pegasus/pp/documents/21210/PEP_348.pdf
 34                 //
 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 karl        1.4     /**
170                      * Constructs an empty SCMOClass object.
171                      * This should be private but it is used in a test in tests/SCMO
172                      * so made it public.
173                      */
174                     SCMOClass();
175                 
176 thilo.boehm 1.2 private:
177                 
178                     void Ref()
179                     {
180                         cls.hdr->refCount++;
181                     };
182                 
183                     void Unref()
184                     {
185                         if (cls.hdr->refCount.decAndTestIfZero())
186                         {
187                             _destroyExternalReferences();
188                             free(cls.base);
189                             cls.base=0;
190                         }
191                 
192                     };
193                 
194                 
195                     inline void _initSCMOClass();
196                 
197 thilo.boehm 1.2     void _destroyExternalReferences();
198                 
199 karl        1.4     SCMO_RC _getPropertyNodeIndex(Uint32& node, const char* name) const;
200 thilo.boehm 1.2     SCMO_RC _getKeyBindingNodeIndex(Uint32& node, const char* name) const;
201                 
202                     void _setClassQualifers(const CIMQualifierList& theQualifierList);
203                 
204                     QualifierNameEnum  _setQualifier(
205                         Uint64 start,
206                         const CIMQualifier& theCIMQualifier);
207                 
208                     void _setClassProperties(PropertySet& theCIMProperties);
209                 
210                     void _setProperty(
211                         Uint64 start,
212                         Boolean* isKey,
213                         const CIMProperty& theCIMProperty);
214                 
215                     Boolean _setPropertyQualifiers(
216                         Uint64 start,
217                         const CIMQualifierList& theQualifierList);
218                 
219                     void _setClassKeyBinding(Uint64 start, const CIMProperty& theCIMProperty);
220                     void _insertPropertyIntoOrderedSet(Uint64 start, Uint32 newIndex);
221 thilo.boehm 1.2     void _insertKeyBindingIntoOrderedSet(Uint64 start, Uint32 newIndex);
222                 
223                     void _setPropertyAsKeyInMask(Uint32 i);
224                     Boolean _isPropertyKey(Uint32 i);
225                 
226                     void _setValue(Uint64 start, const CIMValue& theCIMValue);
227                 
228                     QualifierNameEnum _getSCMOQualifierNameEnum(const CIMName& theCIMname);
229                     Boolean _isSamePropOrigin(Uint32 node, const char* origin) const;
230                 
231                     const char* _getPropertyNameAtNode(Uint32 propNode) const;
232                 
233                     SCMO_RC _isNodeSameType(
234                         Uint32 node,
235                         CIMType type,
236                         Boolean isArray,
237                         CIMType& realType) const;
238                 
239                     CIMProperty _getCIMPropertyAtNodeIndex(Uint32 nodeIdx) const;
240                     static void _getCIMQualifierFromSCMBQualifier(
241                         CIMQualifier& theCIMQualifier,
242 thilo.boehm 1.2         const SCMBQualifier& scmbQualifier,
243                         const char* base);
244                 
245                     union{
246                         // To access the class main structure
247                         SCMBClass_Main *hdr;
248                         // To access the memory management header
249                         SCMBMgmt_Header  *mem;
250                         // Generic access pointer
251                         char *base;
252                     }cls;
253                 
254                     static const StrLit _qualifierNameStrLit[72];
255                 
256                     friend class SCMOInstance;
257                     friend class SCMODump;
258                     friend class SCMOXmlWriter;
259                     friend class SCMOClassCache;
260                     friend class SCMOStreamer;
261                 };
262                 
263 thilo.boehm 1.2 
264                 PEGASUS_NAMESPACE_END
265                 
266                 #endif

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2