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

Diff for /pegasus/src/Pegasus/Common/SCMOClass.h between version 1.1 and 1.1.2.15

version 1.1, 2009/08/03 11:10:08 version 1.1.2.15, 2009/11/03 13:11:51
Line 0 
Line 1 
   //%LICENSE////////////////////////////////////////////////////////////////
   //
   // Licensed to The Open Group (TOG) under one or more contributor license
   // agreements.  Refer to the OpenPegasusNOTICE.txt file distributed with
   // this work for additional information regarding copyright ownership.
   // Each contributor licenses this file to you under the OpenPegasus Open
   // Source License; you may not use this file except in compliance with the
   // License.
   //
   // Permission is hereby granted, free of charge, to any person obtaining a
   // copy of this software and associated documentation files (the "Software"),
   // to deal in the Software without restriction, including without limitation
   // the rights to use, copy, modify, merge, publish, distribute, sublicense,
   // and/or sell copies of the Software, and to permit persons to whom the
   // Software is furnished to do so, subject to the following conditions:
   //
   // The above copyright notice and this permission notice shall be included
   // in all copies or substantial portions of the Software.
   //
   // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
   // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
   // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
   // IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
   // CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
   // TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
   // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
   //
   //////////////////////////////////////////////////////////////////////////
   //
   //%/////////////////////////////////////////////////////////////////////////////
   
   #ifndef _SCMOCLASS_H_
   #define _SCMOCLASS_H_
   
   
   #include <Pegasus/Common/Config.h>
   #include <Pegasus/Common/Linkage.h>
   #include <Pegasus/Common/SCMO.h>
   #include <Pegasus/Common/CIMClass.h>
   #include <Pegasus/Common/CIMClassRep.h>
   #include <Pegasus/Common/CIMObjectRep.h>
   
   PEGASUS_NAMESPACE_BEGIN
   
   
   #define PEGASUS_SCMB_CLASS_MAGIC 0xF00FABCD
   
   class PEGASUS_COMMON_LINKAGE SCMOClass
   {
   public:
   
       /**
        * Constructs a SCMOClass out of a CIMClass.
        * @param theCIMClass The source the SCMOClass is constucted off.
        * @param nameSpaceName The namespace for the class, optional.
        * @return
        */
       SCMOClass(const CIMClass& theCIMClass, const char* altNameSpace=0 );
   
       /**
        * Copy constructor for the SCMO class, used to implement refcounting.
        * @param theSCMOClass The class for which to create a copy
        * @return
        */
       SCMOClass(const SCMOClass& theSCMOClass )
       {
           cls.hdr = theSCMOClass.cls.hdr;
           Ref();
       }
   
       /**
        * Constructs an empty SCMOClass only with name space and class name.
        *
        * If you construct a SCMOInstance using this class, you must mark it as
        * compromized using SCMOInstance.markAsCompromised().
        *
        * @param className The name for the class.
        * @param nameSpaceName The namespace for the class.
        */
       SCMOClass(const char* className, const char* nameSpaceName );
   
   
       /**
        * Destructor is decrementing the refcount. If refcount is zero, the
        * singele chunk memory object is deallocated.
        */
       ~SCMOClass()
       {
           Unref();
       }
   
       /**
        * Converts the SCMOClass into a CIMClass.
        * It is a deep copy of the SCMOClass into the CIMClass.
        * @param cimClass An empty CIMClass.
        */
       void getCIMClass(CIMClass& cimClass) const;
   
       /**
        * Gets the key property names as a string array
        * @return An Array of String objects containing the names of the key
        * properties.
        */
       void getKeyNamesAsString(Array<String>& keyNames) const;
   
       /**
        * Gets the super class name of the class.
        * @retuns The super class name.
        *         If not available a NULL pointer is returned
        */
       const char* getSuperClassName() const;
   
       /**
        * Gets the super class name of the class.
        * @param Return strlen of result string.
        * @retuns The super class name.
        *         If not available a NULL pointer is returned
        */
       const char* getSuperClassName_l(Uint64 & length) const;
   
       static StrLit qualifierNameStrLit(Uint32 num)
       {
           return _qualifierNameStrLit[num];
       }
   
       /**
        * Determines if the SCMOClass is an empty class.
        * A empty class is a class with no information about properties.
        * Maybe only the class name and/or name space are available.
        * @return True if it an empty class.
        **/
       Boolean isEmpty( )const
       {
           // The size of one indicates that only an empty string was stored.
           return (cls.hdr->flags.isEmpty);
       }
   
   private:
   
       void Ref()
       {
           cls.hdr->refCount++;
           // printf("\ncls.hdr->refCount=%u\n",cls.hdr->refCount.get());
       };
   
       void Unref()
       {
           if (cls.hdr->refCount.decAndTestIfZero())
           {
               // printf("\ncls.hdr->refCount=%u\n",cls.hdr->refCount.get());
               _destroyExternalReferences();
               free(cls.base);
               cls.base=0;
           }
           else
           {
               // printf("\ncls.hdr->refCount=%u\n",cls.hdr->refCount.get());
           }
   
       };
   
       void _destroyExternalReferences();
   
       /**
        * Constructs an empty SCMOClass object.
        */
       SCMOClass();
   
       inline void _initSCMOClass();
   
       SCMO_RC _getProperyNodeIndex(Uint32& node, const char* name) const;
       SCMO_RC _getKeyBindingNodeIndex(Uint32& node, const char* name) const;
   
       void _setClassQualifers(const CIMQualifierList& theQualifierList);
   
       QualifierNameEnum  _setQualifier(
           Uint64 start,
           const CIMQualifier& theCIMQualifier);
   
       void _setClassProperties(PropertySet& theCIMProperties);
   
       void _setProperty(
           Uint64 start,
           Boolean* isKey,
           const CIMProperty& theCIMProperty);
   
       Boolean _setPropertyQualifiers(
           Uint64 start,
           const CIMQualifierList& theQualifierList);
   
       void _setClassKeyBinding(Uint64 start, const CIMProperty& theCIMProperty);
       void _insertPropertyIntoOrderedSet(Uint64 start, Uint32 newIndex);
       void _insertKeyBindingIntoOrderedSet(Uint64 start, Uint32 newIndex);
   
       void _setPropertyAsKeyInMask(Uint32 i);
       Boolean _isPropertyKey(Uint32 i);
   
       void _setValue(Uint64 start, const CIMValue& theCIMValue);
   
       QualifierNameEnum _getSCMOQualifierNameEnum(const CIMName& theCIMname);
       Boolean _isSamePropOrigin(Uint32 node, const char* origin) const;
   
       const char* _getPropertyNameAtNode(Uint32 propNode) const;
   
       SCMO_RC _isNodeSameType(
           Uint32 node,
           CIMType type,
           Boolean isArray,
           CIMType& realType) const;
   
       CIMProperty _getCIMPropertyAtNodeIndex(Uint32 nodeIdx) const;
       static void _getCIMQualifierFromSCMBQualifier(
           CIMQualifier& theCIMQualifier,
           const SCMBQualifier& scmbQualifier,
           const char* base);
   
       union{
           // To access the class main structure
           SCMBClass_Main *hdr;
           // To access the memory management header
           SCMBMgmt_Header  *mem;
           // Generic access pointer
           char *base;
       }cls;
   
       static const StrLit _qualifierNameStrLit[72];
   
       friend class SCMOInstance;
       friend class SCMODump;
       friend class SCMOXmlWriter;
       friend class SCMOClassCache;
   };
   
   
   PEGASUS_NAMESPACE_END
   
   #endif


Legend:
Removed from v.1.1  
changed lines
  Added in v.1.1.2.15

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2