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

Diff for /pegasus/src/Pegasus/Common/SCMO.cpp between version 1.2.2.13 and 1.24

version 1.2.2.13, 2009/08/05 14:08:34 version 1.24, 2013/02/13 11:39:58
Line 27 
Line 27 
 // //
 ////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
 // //
   // This code implements part of PEP#348 - The CMPI infrastructure using SCMO
   // (Single Chunk Memory Objects).
   // The design document can be found on the OpenPegasus website openpegasus.org
   // at https://collaboration.opengroup.org/pegasus/pp/documents/21210/PEP_348.pdf
   //
 //%///////////////////////////////////////////////////////////////////////////// //%/////////////////////////////////////////////////////////////////////////////
  
 #include <Pegasus/Common/SCMO.h> #include <Pegasus/Common/SCMO.h>
 #include <Pegasus/Common/SCMOClass.h> #include <Pegasus/Common/SCMOClass.h>
 #include <Pegasus/Common/SCMOInstance.h> #include <Pegasus/Common/SCMOInstance.h>
 #include <Pegasus/Common/SCMODump.h> #include <Pegasus/Common/SCMODump.h>
   #include <Pegasus/Common/SCMOClassCache.h>
 #include <Pegasus/Common/CharSet.h> #include <Pegasus/Common/CharSet.h>
 #include <Pegasus/Common/CIMDateTimeRep.h> #include <Pegasus/Common/CIMDateTimeRep.h>
 #include <Pegasus/Common/CIMPropertyRep.h> #include <Pegasus/Common/CIMPropertyRep.h>
 #include <Pegasus/Common/CIMInstanceRep.h> #include <Pegasus/Common/CIMInstanceRep.h>
 #include <Pegasus/Common/CIMObjectPathRep.h> #include <Pegasus/Common/CIMObjectPathRep.h>
   #include <Pegasus/Common/CIMNameCast.h>
 #include <Pegasus/Common/CommonUTF.h> #include <Pegasus/Common/CommonUTF.h>
 #include <Pegasus/Common/StrLit.h> #include <Pegasus/Common/StrLit.h>
   #include <Pegasus/Common/Tracer.h>
 #include <Pegasus/Common/XmlWriter.h> #include <Pegasus/Common/XmlWriter.h>
 #include <Pegasus/Common/System.h> #include <Pegasus/Common/System.h>
 #include <Pegasus/Common/FileSystem.h> #include <Pegasus/Common/FileSystem.h>
 #include <Pegasus/Common/StringConversion.h> #include <Pegasus/Common/StringConversion.h>
   #include <Pegasus/Common/ArrayIterator.h>
   #include <Pegasus/Common/PegasusAssert.h>
   #include <Pegasus/Common/CIMValueRep.h>
   
   # if defined PEGASUS_OS_ZOS
   #  include <strings.h>
   # else
   #  include <string.h>
   # endif
  
 #ifdef PEGASUS_OS_ZOS #ifdef PEGASUS_OS_ZOS
   #include <Pegasus/General/SetFileDescriptorToEBCDICEncoding.h>   #include <Pegasus/General/SetFileDescriptorToEBCDICEncoding.h>
 #endif #endif
  
   #ifdef PEGASUS_HAS_ICU
   # include <unicode/platform.h>
   # include <unicode/urename.h>
   # include <unicode/ures.h>
   # include <unicode/ustring.h>
   # include <unicode/uchar.h>
   # include <unicode/ucnv.h>
   #endif
   
 PEGASUS_USING_STD; PEGASUS_USING_STD;
  
 #define SCMB_INITIAL_MEMORY_CHUNK_SIZE 4096 #define SCMB_INITIAL_MEMORY_CHUNK_SIZE 4096
Line 60 
Line 86 
  * for a string format specification, the string "(null)" is  * for a string format specification, the string "(null)" is
  * substituted. On other platforms no string "" is substituded.  * substituted. On other platforms no string "" is substituded.
  */  */
 #define NULLSTR(x) ((x) == NULL ? "" : (x))  #define NULLSTR(x) ((x) == 0 ? "" : (x))
  
 PEGASUS_NAMESPACE_BEGIN PEGASUS_NAMESPACE_BEGIN
  
 static StrLit _qualifierNameStrLit[] =  #define PEGASUS_ARRAY_T SCMOInstance
   # include "ArrayImpl.h"
   #undef PEGASUS_ARRAY_T
   
   const StrLit SCMOClass::_qualifierNameStrLit[72] =
 { {
     STRLIT(""),     STRLIT(""),
     STRLIT("ABSTRACT"),     STRLIT("ABSTRACT"),
Line 143 
Line 173 
 #define _NUM_QUALIFIER_NAMES \ #define _NUM_QUALIFIER_NAMES \
            (sizeof(_qualifierNameStrLit)/sizeof(_qualifierNameStrLit[0]))            (sizeof(_qualifierNameStrLit)/sizeof(_qualifierNameStrLit[0]))
  
   
   /*****************************************************************************
    * The static declaration of the common SCMO memory functions.
    *****************************************************************************/
   
   static Uint64 _getFreeSpace(
       SCMBDataPtr& ptr,
       Uint32 size,
       SCMBMgmt_Header** pmem);
   
   static void _setString(
       const String& theString,
       SCMBDataPtr& ptr,
       SCMBMgmt_Header** pmem);
   
   static void _setBinary(
       const void* theBuffer,
       Uint32 bufferSize,
       SCMBDataPtr& ptr,
       SCMBMgmt_Header** pmem);
   
   
   
   /*****************************************************************************
    * Internal inline functions.
    *****************************************************************************/
   
   inline String _newCimString(const SCMBDataPtr & ptr, const char * base)
   {
       if (ptr.size > 0)
       {
           return String(&(base[ptr.start]),ptr.size-1);
       }
       else
       {
           return String();
       }
   }
   
   inline void _deleteArrayExtReference(
       SCMBDataPtr& theArray,
       SCMBMgmt_Header** pmem )
   {
       SCMBUnion* ptr;
       // if the array was already set,
       // the previous references has to be deleted
       if(theArray.size != 0)
       {
           Uint32 oldArraySize=(theArray.size/sizeof(SCMBUnion));
   
           ptr = (SCMBUnion*)&(((char*)*pmem)[theArray.start]);
           for (Uint32 i = 0 ; i < oldArraySize ; i++)
           {
               delete ptr[i].extRefPtr;
               ptr[i].extRefPtr = 0;
           }
       }
   }
   
   static void _deleteExternalReferenceInternal(
       SCMBMgmt_Header* memHdr, SCMOInstance *extRefPtr)
   {
       Uint32 nuExtRef = memHdr->numberExtRef;
       char * base = ((char*)memHdr);
       Uint64* array =
           (Uint64*)&(base[memHdr->extRefIndexArray.start]);
       Uint32 extRefIndex = PEG_NOT_FOUND;
   
       for (Uint32 i = 0; i < nuExtRef; i++)
       {
            if (((SCMBUnion*)(&(base[array[i]])))->extRefPtr == extRefPtr)
            {
                extRefIndex = i;
                break;
            }
       }
       PEGASUS_ASSERT (extRefIndex != PEG_NOT_FOUND);
   
      // Shrink extRefIndexArray
   
       for (Uint32 i = extRefIndex + 1; i < nuExtRef; i++)
       {
           array[i-1] = array[i];
       }
   
       array[nuExtRef-1] = 0;
       memHdr->numberExtRef--;
   
       delete extRefPtr;
   }
   
 /***************************************************************************** /*****************************************************************************
  * The SCMOClass methods  * The SCMOClass methods
  *****************************************************************************/  *****************************************************************************/
 SCMOClass::SCMOClass() SCMOClass::SCMOClass()
 { {
     cls.mem = NULL;      _initSCMOClass();
   
       _setBinary("",1,cls.hdr->className,&cls.mem );
       _setBinary("",1,cls.hdr->nameSpace,&cls.mem );
       cls.hdr->flags.isEmpty=true;
 } }
  
 SCMOClass::SCMOClass(CIMClass& theCIMClass)  inline void SCMOClass::_initSCMOClass()
 { {
     PEGASUS_ASSERT(SCMB_INITIAL_MEMORY_CHUNK_SIZE     PEGASUS_ASSERT(SCMB_INITIAL_MEMORY_CHUNK_SIZE
         - sizeof(SCMBClass_Main)>0);         - sizeof(SCMBClass_Main)>0);
  
     cls.base = (char*)malloc(SCMB_INITIAL_MEMORY_CHUNK_SIZE);     cls.base = (char*)malloc(SCMB_INITIAL_MEMORY_CHUNK_SIZE);
     if (cls.base == NULL)      if (cls.base == 0)
     {     {
         // Not enough memory!         // Not enough memory!
         throw PEGASUS_STD(bad_alloc)();         throw PEGASUS_STD(bad_alloc)();
     }     }
  
       memset(cls.base,0,sizeof(SCMBClass_Main));
   
     // initalize eye catcher     // initalize eye catcher
     cls.hdr->header.magic=PEGASUS_SCMB_CLASS_MAGIC;     cls.hdr->header.magic=PEGASUS_SCMB_CLASS_MAGIC;
     cls.hdr->header.totalSize=SCMB_INITIAL_MEMORY_CHUNK_SIZE;     cls.hdr->header.totalSize=SCMB_INITIAL_MEMORY_CHUNK_SIZE;
Line 175 
Line 302 
  
     cls.hdr->refCount=1;     cls.hdr->refCount=1;
  
   }
   
   SCMOClass::SCMOClass(const char* className, const char* nameSpaceName )
   {
       Uint32 clsNameLen = strlen(className);
       Uint32 nsNameLen = strlen(nameSpaceName);
   
       if (0 == className )
       {
           String message("SCMOClass: Class name not set (null pointer)!");
           throw CIMException(CIM_ERR_FAILED,message );
       }
   
       if (0 == nameSpaceName)
       {
           String message("SCMOClass: Name Space not set (null pointer)!");
           throw CIMException(CIM_ERR_FAILED,message );
       }
   
       _initSCMOClass();
   
       _setBinary(className,clsNameLen+1,cls.hdr->className,&cls.mem );
   
       _setBinary(nameSpaceName,nsNameLen+1,cls.hdr->nameSpace,&cls.mem );
   
       cls.hdr->flags.isEmpty=true;
   
   }
   
   SCMOClass::SCMOClass(
       const CIMClass& theCIMClass,
       const char* nameSpaceName)
   {
   
       _initSCMOClass();
   
     try     try
     {     {
         _setString(theCIMClass.getSuperClassName().getString(),         _setString(theCIMClass.getSuperClassName().getString(),
Line 185 
Line 348 
     {     {
         // there is no Super ClassName         // there is no Super ClassName
         cls.hdr->superClassName.start=0;         cls.hdr->superClassName.start=0;
         cls.hdr->superClassName.length=0;          cls.hdr->superClassName.size=0;
     }     }
  
     CIMObjectPath theObjectPath=theCIMClass.getPath();     CIMObjectPath theObjectPath=theCIMClass.getPath();
  
     //set name space     //set name space
       if (nameSpaceName)
       {
           _setBinary(nameSpaceName,
                      strlen(nameSpaceName)+1,
                      cls.hdr->nameSpace,
                      &cls.mem );
       }
       else
       {
    _setString(theObjectPath.getNameSpace().getString(),    _setString(theObjectPath.getNameSpace().getString(),
               cls.hdr->nameSpace,               cls.hdr->nameSpace,
               &cls.mem );               &cls.mem );
       }
   
  
     //set class name     //set class name
     _setString(theObjectPath.getClassName().getString(),     _setString(theObjectPath.getClassName().getString(),
                cls.hdr->className,                cls.hdr->className,
                &cls.mem );                &cls.mem );
  
   
     //set class Qualifiers     //set class Qualifiers
     _setClassQualifers(theCIMClass);      _setClassQualifers(theCIMClass._rep->_qualifiers);
  
     //set properties     //set properties
     _setClassProperties(theCIMClass);      _setClassProperties(theCIMClass._rep->_properties);
   
   }
   
   void SCMOClass::_destroyExternalReferences()
   {
       _destroyExternalReferencesInternal(cls.mem);
   }
   
   const char* SCMOClass::getSuperClassName() const
   {
       return _getCharString(cls.hdr->superClassName,cls.base);
   }
   
   const char* SCMOClass::getSuperClassName_l(Uint32 & length) const
   {
       length = cls.hdr->superClassName.size;
       if (0 == length)
       {
           return 0;
       }
       else
       {
           length--;
       }
       return _getCharString(cls.hdr->superClassName,cls.base);
   }
   
   void  SCMOClass::getCIMClass(CIMClass& cimClass) const
   {
       CIMClass newCimClass(
           CIMNameCast(_newCimString(cls.hdr->className,cls.base)),
           CIMNameCast(_newCimString(cls.hdr->superClassName,cls.base)));
   
       // set the name space
       newCimClass._rep->_reference._rep->_nameSpace=
           CIMNamespaceNameCast(_newCimString(cls.hdr->nameSpace,cls.base));
   
       // Add class qualifier if exist
       if (0 != cls.hdr->numberOfQualifiers)
       {
           SCMBQualifier* qualiArray =
               (SCMBQualifier*)&(cls.base[cls.hdr->qualifierArray.start]);
   
           CIMQualifier theCimQualifier;
   
           Uint32 i, k = cls.hdr->numberOfQualifiers;
           for ( i = 0 ; i < k ; i++)
           {
               _getCIMQualifierFromSCMBQualifier(
                   theCimQualifier,
                   qualiArray[i],
                   cls.base);
   
               newCimClass._rep->_qualifiers.addUnchecked(theCimQualifier);
           }
       }
   
       // If properties are in that class
       if (0 != cls.hdr->propertySet.number)
       {
           Uint32 i, k = cls.hdr->propertySet.number;
           for ( i = 0 ; i < k ; i++)
           {
              newCimClass._rep->_properties.append(
                  _getCIMPropertyAtNodeIndex(i));
           }
       }
   
       cimClass = newCimClass;
   }
   
   CIMProperty SCMOClass::_getCIMPropertyAtNodeIndex(Uint32 nodeIdx) const
   {
       CIMValue theCimValue;
       CIMProperty retCimProperty;
  
       SCMBClassPropertyNode& clsProp =
           ((SCMBClassPropertyNode*)
            &(cls.base[cls.hdr->propertySet.nodeArray.start]))[nodeIdx];
   
       // get the default value
       SCMOInstance::_getCIMValueFromSCMBValue(
           theCimValue,
           clsProp.theProperty.defaultValue,
           cls.base);
   
       // have to check if there is the origin class name set.
       // An empty origin class name is differnt then a NULL class name
       if (0 != clsProp.theProperty.originClassName.start)
       {
           retCimProperty = CIMProperty(
               CIMNameCast(_newCimString(clsProp.theProperty.name,cls.base)),
               theCimValue,
               theCimValue.getArraySize(),
               CIMNameCast(
                   _newCimString(clsProp.theProperty.refClassName,cls.base)),
               CIMNameCast(
                   _newCimString(clsProp.theProperty.originClassName,cls.base)),
               clsProp.theProperty.flags.propagated);
       }
       else
       {
            retCimProperty = CIMProperty(
               CIMNameCast(_newCimString(clsProp.theProperty.name,cls.base)),
               theCimValue,
               theCimValue.getArraySize(),
               CIMNameCast(
                   _newCimString(clsProp.theProperty.refClassName,cls.base)),
               CIMName(),
               clsProp.theProperty.flags.propagated);
       }
   
       SCMBQualifier* qualiArray =
           (SCMBQualifier*)
                &(cls.base[clsProp.theProperty.qualifierArray.start]);
   
       CIMQualifier theCimQualifier;
       Uint32 i, k = clsProp.theProperty.numberOfQualifiers;
       for ( i = 0 ; i < k ; i++)
       {
           _getCIMQualifierFromSCMBQualifier(
               theCimQualifier,
               qualiArray[i],
               cls.base);
   
           retCimProperty._rep->_qualifiers.addUnchecked(theCimQualifier);
       }
   
       return retCimProperty;
   
   }
   
   void SCMOClass::_getCIMQualifierFromSCMBQualifier(
       CIMQualifier& theCimQualifier,
       const SCMBQualifier& scmbQualifier,
       const char* base)
   
   {
   
       CIMName theCimQualiName;
       CIMValue theCimValue;
   
       SCMOInstance::_getCIMValueFromSCMBValue(
           theCimValue,
           scmbQualifier.value,
           base);
   
       if (scmbQualifier.name == QUALNAME_USERDEFINED)
       {
           theCimQualiName = _newCimString(scmbQualifier.userDefName,base);
       }
       else
       {
           theCimQualiName = String(
               SCMOClass::qualifierNameStrLit(scmbQualifier.name).str,
               SCMOClass::qualifierNameStrLit(scmbQualifier.name).size);
       }
   
       theCimQualifier = CIMQualifier(
           theCimQualiName,
           theCimValue,
           scmbQualifier.flavor,
           scmbQualifier.propagated);
 } }
  
 void SCMOClass::getKeyNamesAsString(Array<String>& keyNames) const void SCMOClass::getKeyNamesAsString(Array<String>& keyNames) const
Line 218 
Line 550 
  
     keyNames.clear();     keyNames.clear();
  
     for (Uint32 i = 0, k = cls.hdr->propertySet.number; i < k; i++)      for (Uint32 i = 0, k = cls.hdr->keyBindingSet.number; i < k; i++)
     {     {
         // Append the key property name.         // Append the key property name.
         // The length has to be reduces by 1 not to copy the trailing '\0'          keyNames.append(_newCimString(nodeArray[i].name,cls.base));
         keyNames.append(  
             String((const char*)_getCharString(nodeArray[i].name,cls.base),  
                    nodeArray[i].name.length-1));  
   
     }     }
 } }
  
Line 247 
Line 575 
     tag = _generateStringTag((const char*)name, len);     tag = _generateStringTag((const char*)name, len);
     // get the node index of the hash table     // get the node index of the hash table
     hashIdx =     hashIdx =
         cls.hdr->keyBindingSet.hashTable[tag%PEGASUS_KEYBINDIG_SCMB_HASHSIZE];        cls.hdr->keyBindingSet.hashTable[tag&(PEGASUS_KEYBINDIG_SCMB_HASHSIZE-1)];
     // there is no entry in the hash table on this hash table index.     // there is no entry in the hash table on this hash table index.
     if (hashIdx == 0)     if (hashIdx == 0)
     {     {
Line 270 
Line 598 
         if (nodeArray[node].nameHashTag == tag)         if (nodeArray[node].nameHashTag == tag)
         {         {
             // Now it is worth to compare the two names             // Now it is worth to compare the two names
             if (_equalUTF8Strings(              if (_equalNoCaseUTF8Strings(nodeArray[node].name,cls.base,name,len))
                 nodeArray[node].name,cls.base,name,len))  
             {             {
                 // we found the property !                 // we found the property !
                 return SCMO_OK;                 return SCMO_OK;
Line 294 
Line 621 
  
 } }
  
   
 SCMO_RC SCMOClass::_getProperyNodeIndex(Uint32& node, const char* name) const SCMO_RC SCMOClass::_getProperyNodeIndex(Uint32& node, const char* name) const
 { {
  
Line 304 
Line 630 
     tag = _generateStringTag((const char*)name, len);     tag = _generateStringTag((const char*)name, len);
     // get the node index of the hash table     // get the node index of the hash table
     hashIdx =     hashIdx =
         cls.hdr->propertySet.hashTable[tag%PEGASUS_PROPERTY_SCMB_HASHSIZE];        cls.hdr->propertySet.hashTable[tag&(PEGASUS_PROPERTY_SCMB_HASHSIZE -1)];
     // there is no entry in the hash table on this hash table index.     // there is no entry in the hash table on this hash table index.
     if (hashIdx == 0)     if (hashIdx == 0)
     {     {
Line 327 
Line 653 
         if (nodeArray[node].theProperty.nameHashTag == tag)         if (nodeArray[node].theProperty.nameHashTag == tag)
         {         {
             // Now it is worth to compare the two names             // Now it is worth to compare the two names
             if (_equalUTF8Strings(              if (_equalNoCaseUTF8Strings(
                 nodeArray[node].theProperty.name,cls.base,name,len))                 nodeArray[node].theProperty.name,cls.base,name,len))
             {             {
                 // we found the property !                 // we found the property !
Line 347 
Line 673 
     } while ( true );     } while ( true );
  
     // this should never be reached     // this should never be reached
     return SCMO_NOT_FOUND;      PEGASUS_UNREACHABLE(return SCMO_NOT_FOUND;)
   
 } }
  
 void SCMOClass::_setClassProperties(CIMClass& theCIMClass)  void SCMOClass::_setClassProperties(PropertySet& theCIMProperties)
 { {
     Uint32 noProps = theCIMClass.getPropertyCount();      Uint32 noProps = theCIMProperties.size();
     Uint64 start, startKeyIndexList;     Uint64 start, startKeyIndexList;
     Uint32 noKeys = 0;     Uint32 noKeys = 0;
     Boolean isKey = false;     Boolean isKey = false;
  
     Uint32 keyIndex[noProps];      Array<Uint32> keyIndex(noProps);
  
     cls.hdr->propertySet.number=noProps;     cls.hdr->propertySet.number=noProps;
  
Line 366 
Line 691 
     startKeyIndexList = _getFreeSpace(     startKeyIndexList = _getFreeSpace(
         cls.hdr->keyIndexList,         cls.hdr->keyIndexList,
         noProps*sizeof(Uint32),         noProps*sizeof(Uint32),
         &cls.mem,          &cls.mem);
         true);  
  
     if(noProps != 0)     if(noProps != 0)
     {     {
Line 393 
Line 717 
                0,                0,
                PEGASUS_PROPERTY_SCMB_HASHSIZE*sizeof(Uint32));                PEGASUS_PROPERTY_SCMB_HASHSIZE*sizeof(Uint32));
  
         _clearKeyPropertyMask();  
  
         for (Uint32 i = 0; i < noProps; i++)         for (Uint32 i = 0; i < noProps; i++)
         {         {
  
             _setProperty(start,&isKey ,theCIMClass.getProperty(i));              _setProperty(start,&isKey ,theCIMProperties[i]);
             if(isKey)             if(isKey)
             {             {
                 // if the property is a key                 // if the property is a key
Line 430 
Line 753 
             // fill the key index list             // fill the key index list
             memcpy(             memcpy(
                 &(cls.base[startKeyIndexList]),                 &(cls.base[startKeyIndexList]),
                 keyIndex,                  keyIndex.getData(),
                 noKeys*sizeof(Uint32));                 noKeys*sizeof(Uint32));
  
             for (Uint32 i = 0 ; i < noKeys; i++)             for (Uint32 i = 0 ; i < noKeys; i++)
             {             {
  
                 _setClassKeyBinding(start,theCIMClass.getProperty(keyIndex[i]));                  _setClassKeyBinding(start,theCIMProperties[keyIndex[i]]);
                 // Adjust ordered set management structures.                 // Adjust ordered set management structures.
                 _insertKeyBindingIntoOrderedSet(start,i);                 _insertKeyBindingIntoOrderedSet(start,i);
  
Line 447 
Line 770 
         else         else
         {         {
             cls.hdr->keyBindingSet.nodeArray.start=0;             cls.hdr->keyBindingSet.nodeArray.start=0;
             cls.hdr->keyBindingSet.nodeArray.length=0;              cls.hdr->keyBindingSet.nodeArray.size=0;
         }         }
     }     }
     else     else
     {     {
         cls.hdr->propertySet.nodeArray.start=0;         cls.hdr->propertySet.nodeArray.start=0;
         cls.hdr->propertySet.nodeArray.length=0;          cls.hdr->propertySet.nodeArray.size=0;
         cls.hdr->keyPropertyMask.start=0;         cls.hdr->keyPropertyMask.start=0;
         cls.hdr->keyPropertyMask.length=0;          cls.hdr->keyPropertyMask.size=0;
         cls.hdr->keyBindingSet.nodeArray.start=0;         cls.hdr->keyBindingSet.nodeArray.start=0;
         cls.hdr->keyBindingSet.nodeArray.length=0;          cls.hdr->keyBindingSet.nodeArray.size=0;
     }     }
 } }
  
Line 473 
Line 796 
  
     Uint32 *hashTable = cls.hdr->keyBindingSet.hashTable;     Uint32 *hashTable = cls.hdr->keyBindingSet.hashTable;
  
     if ( newIndex >= cls.hdr->keyBindingSet.number)  
     {  
         throw IndexOutOfBoundsException();  
     }  
   
     // calculate the new hash index of the new property.     // calculate the new hash index of the new property.
     Uint32 hash = newKeyNode->nameHashTag % PEGASUS_KEYBINDIG_SCMB_HASHSIZE;      Uint32 hash = newKeyNode->nameHashTag &
           (PEGASUS_KEYBINDIG_SCMB_HASHSIZE - 1);
  
     // 0 is an invalid index in the hash table     // 0 is an invalid index in the hash table
     if (hashTable[hash] == 0)     if (hashTable[hash] == 0)
Line 529 
Line 848 
  
     Uint32 *hashTable = cls.hdr->propertySet.hashTable;     Uint32 *hashTable = cls.hdr->propertySet.hashTable;
  
     if ( newIndex >= cls.hdr->propertySet.number)  
     {  
         throw IndexOutOfBoundsException();  
     }  
   
     // calcuate the new hash index of the new property.     // calcuate the new hash index of the new property.
     Uint32 hash = newPropNode->theProperty.nameHashTag %      Uint32 hash = newPropNode->theProperty.nameHashTag &
         PEGASUS_PROPERTY_SCMB_HASHSIZE;          (PEGASUS_PROPERTY_SCMB_HASHSIZE -1);
  
     // 0 is an invalid index in the hash table     // 0 is an invalid index in the hash table
     if (hashTable[hash] == 0)     if (hashTable[hash] == 0)
Line 579 
Line 893 
     const CIMProperty& theCIMProperty)     const CIMProperty& theCIMProperty)
 { {
     CIMPropertyRep* propRep = theCIMProperty._rep;     CIMPropertyRep* propRep = theCIMProperty._rep;
     Uint64 valueStart;  
  
     // First do all _setString(). Can cause reallocation.     // First do all _setString(). Can cause reallocation.
     _setString(propRep->_name.getString(),     _setString(propRep->_name.getString(),
Line 592 
Line 905 
     // calculate the new hash tag     // calculate the new hash tag
     scmoKeyBindNode->nameHashTag =     scmoKeyBindNode->nameHashTag =
         _generateSCMOStringTag(scmoKeyBindNode->name,cls.base);         _generateSCMOStringTag(scmoKeyBindNode->name,cls.base);
     scmoKeyBindNode->type = _cimTypeToKeyBindType(propRep->_value.getType());      scmoKeyBindNode->type = propRep->_value.getType();
     scmoKeyBindNode->hasNext=false;     scmoKeyBindNode->hasNext=false;
     scmoKeyBindNode->nextNode=0;     scmoKeyBindNode->nextNode=0;
  
 } }
  
 void SCMOClass::_clearKeyPropertyMask()  
 {  
   
     Uint64 *keyMask;  
   
     // Calculate the real pointer to the Uint64 array  
     keyMask = (Uint64*)&cls.base[cls.hdr->keyPropertyMask.start];  
   
     // the number of Uint64 in the key mask is :  
     // Decrease the number of properties by 1  
     // since the array is starting at index 0!  
     // Divide with the number of bits in a Uint64.  
     // e.g. number of Properties = 68  
     // (68 - 1) / 64 = 1 --> The mask consists of 2 Uint64  
   
     memset(keyMask,0, sizeof(Uint64)*(((cls.hdr->propertySet.number-1)/64)+1));  
   
 }  
   
 void SCMOClass::_setPropertyAsKeyInMask(Uint32 i) void SCMOClass::_setPropertyAsKeyInMask(Uint32 i)
 { {
     Uint64 *keyMask;     Uint64 *keyMask;
Line 628 
Line 922 
  
     // Create a filter to set the bit.     // Create a filter to set the bit.
     // Modulo division with 64. Shift left a bit by the remainder.     // Modulo division with 64. Shift left a bit by the remainder.
     Uint64 filter = ( (Uint64)1 << (i%64));      Uint64 filter = ( (Uint64)1 << (i & 63));
  
     // Calculate the real pointer to the Uint64 array     // Calculate the real pointer to the Uint64 array
     keyMask = (Uint64*)&cls.base[cls.hdr->keyPropertyMask.start];      keyMask = (Uint64*)&(cls.base[cls.hdr->keyPropertyMask.start]);
  
     keyMask[idx] = keyMask[idx] | filter ;     keyMask[idx] = keyMask[idx] | filter ;
 } }
Line 648 
Line 942 
  
     // Create a filter to check if the bit is set:     // Create a filter to check if the bit is set:
     // Modulo division with 64. Shift left a bit by the remainder.     // Modulo division with 64. Shift left a bit by the remainder.
     Uint64 filter = ( (Uint64)1 << (i%64));      Uint64 filter = ( (Uint64)1 << (i & 63));
  
     // Calculate the real pointer to the Uint64 array     // Calculate the real pointer to the Uint64 array
     keyMask = (Uint64*)&cls.base[cls.hdr->keyPropertyMask.start];      keyMask = (Uint64*)&(cls.base[cls.hdr->keyPropertyMask.start]);
  
     return keyMask[idx] & filter ;     return keyMask[idx] & filter ;
  
Line 747 
Line 1041 
     else     else
     {     {
         scmoPropNode->theProperty.qualifierArray.start=0;         scmoPropNode->theProperty.qualifierArray.start=0;
         scmoPropNode->theProperty.qualifierArray.length=0;          scmoPropNode->theProperty.qualifierArray.size=0;
     }     }
  
     return isKey;     return isKey;
 } }
 void SCMOClass::_setClassQualifers(CIMClass& theCIMClass)  
   void SCMOClass::_setClassQualifers(const CIMQualifierList& theQualifierList)
 { {
  
     Uint32 noQuali = theCIMClass.getQualifierCount();      Uint32 noQuali = theQualifierList.getCount();
     Uint64 start;     Uint64 start;
  
     cls.hdr->numberOfQualifiers = noQuali;     cls.hdr->numberOfQualifiers = noQuali;
Line 768 
Line 1063 
                       &cls.mem);                       &cls.mem);
         for (Uint32 i = 0; i < noQuali; i++)         for (Uint32 i = 0; i < noQuali; i++)
         {         {
             _setQualifier(start,theCIMClass.getQualifier(i));              _setQualifier(start,theQualifierList.getQualifier(i));
             start = start + sizeof(SCMBQualifier);             start = start + sizeof(SCMBQualifier);
  
         }         }
Line 777 
Line 1072 
     else     else
     {     {
         cls.hdr->qualifierArray.start=0;         cls.hdr->qualifierArray.start=0;
         cls.hdr->qualifierArray.length=0;          cls.hdr->qualifierArray.size=0;
     }     }
   
   
 } }
  
 QualifierNameEnum SCMOClass::_setQualifier( QualifierNameEnum SCMOClass::_setQualifier(
Line 812 
Line 1105 
     return name;     return name;
 } }
  
 void SCMOClass::_setValue(Uint64 start, const CIMValue& theCIMValue)  void SCMOClass::_setValue(
       Uint64 start,
       const CIMValue& theCIMValue)
 { {
     Uint64 valueStart;     Uint64 valueStart;
  
Line 823 
Line 1118 
     scmoValue->valueArraySize = 0;     scmoValue->valueArraySize = 0;
     scmoValue->flags.isNull = rep->isNull;     scmoValue->flags.isNull = rep->isNull;
     scmoValue->flags.isArray = rep->isArray;     scmoValue->flags.isArray = rep->isArray;
     // Only initalized by for completeness.  
     scmoValue->flags.isSet = false;     scmoValue->flags.isSet = false;
  
     if (rep->isNull)     if (rep->isNull)
Line 835 
Line 1129 
  
     if (scmoValue->flags.isArray)     if (scmoValue->flags.isArray)
     {     {
         SCMOInstance::_setArrayValue(          SCMOInstance::_setUnionArrayValue(
             valueStart,             valueStart,
             &cls.mem,             &cls.mem,
             rep->type,             rep->type,
             // Is set to the number of array members by the function.             // Is set to the number of array members by the function.
             scmoValue->valueArraySize,             scmoValue->valueArraySize,
               cls.hdr->nameSpace.start,
               cls.hdr->nameSpace.size,
             rep->u);             rep->u);
     }     }
     else     else
Line 849 
Line 1145 
             valueStart,             valueStart,
             &cls.mem,             &cls.mem,
             rep->type,             rep->type,
               cls.hdr->nameSpace.start,
               cls.hdr->nameSpace.size,
             rep->u);             rep->u);
     }     }
 } }
Line 867 
Line 1165 
     // list.     // list.
     for (Uint32 i = 1; i < _NUM_QUALIFIER_NAMES; i++)     for (Uint32 i = 1; i < _NUM_QUALIFIER_NAMES; i++)
     {     {
         if (_qualifierNameStrLit[i].size == length)          if (qualifierNameStrLit(i).size == length)
         {         {
             // TBD: Make it more efficent...             // TBD: Make it more efficent...
             if(String::equalNoCase(             if(String::equalNoCase(
                 theCIMName.getString(),                 theCIMName.getString(),
                 _qualifierNameStrLit[i].str))                  qualifierNameStrLit(i).str))
             {             {
                 return (QualifierNameEnum)i;                 return (QualifierNameEnum)i;
             }             }
Line 890 
Line 1188 
        (SCMBClassPropertyNode*)        (SCMBClassPropertyNode*)
            &(cls.base[cls.hdr->propertySet.nodeArray.start]);            &(cls.base[cls.hdr->propertySet.nodeArray.start]);
  
    return(_equalUTF8Strings(     return(_equalNoCaseUTF8Strings(
        nodeArray[node].theProperty.originClassName,        nodeArray[node].theProperty.originClassName,
        cls.base,        cls.base,
        origin,        origin,
        len));        len));
 } }
  
 inline SCMO_RC SCMOClass::_isNodeSameType(  SCMO_RC SCMOClass::_isNodeSameType(
     Uint32 node,     Uint32 node,
     CIMType type,     CIMType type,
     Boolean isArray) const      Boolean isArray,
       CIMType& realType) const
 { {
   
     SCMBClassPropertyNode* nodeArray =     SCMBClassPropertyNode* nodeArray =
         (SCMBClassPropertyNode*)         (SCMBClassPropertyNode*)
             &(cls.base[cls.hdr->propertySet.nodeArray.start]);             &(cls.base[cls.hdr->propertySet.nodeArray.start]);
  
       // The type stored in the class information is set on realType.
       // It must be used in further calls to guaranty consistence.
       realType = nodeArray[node].theProperty.defaultValue.valueType;
  
     if(nodeArray[node].theProperty.defaultValue.valueType != type)     if(nodeArray[node].theProperty.defaultValue.valueType != type)
     {     {
           // Accept an property of type instance also
           // for an CIMTYPE_OBJECT property.
           if (!(type == CIMTYPE_INSTANCE &&
                 nodeArray[node].theProperty.defaultValue.valueType
                 == CIMTYPE_OBJECT))
           {
         return SCMO_WRONG_TYPE;         return SCMO_WRONG_TYPE;
     }     }
       }
  
     if (isArray)     if (isArray)
     {     {
Line 933 
Line 1243 
     return SCMO_OK;     return SCMO_OK;
  
 } }
   
 /***************************************************************************** /*****************************************************************************
  * The SCMOInstance methods  * The SCMOInstance methods
  *****************************************************************************/  *****************************************************************************/
  
 SCMOInstance::SCMOInstance() SCMOInstance::SCMOInstance()
 { {
     inst.base = NULL;      inst.base = 0;
 } }
  
 SCMOInstance::SCMOInstance(SCMOClass baseClass)  SCMOInstance::SCMOInstance(SCMOClass& baseClass)
 { {
     _initSCMOInstance(new SCMOClass(baseClass),false,false);      _initSCMOInstance(new SCMOClass(baseClass));
 } }
  
 SCMOInstance::SCMOInstance( SCMOInstance::SCMOInstance(
     SCMOClass baseClass,      SCMOClass& baseClass,
     Boolean includeQualifiers,     Boolean includeQualifiers,
     Boolean includeClassOrigin,      Boolean includeClassOrigin)
     const char** propertyList)  
 { {
  
     _initSCMOInstance(      _initSCMOInstance(new SCMOClass(baseClass));
         new SCMOClass(baseClass),  
         includeQualifiers,  
         includeClassOrigin);  
  
     setPropertyFilter(propertyList);      inst.hdr->flags.includeQualifiers=includeQualifiers;
       inst.hdr->flags.includeClassOrigin=includeClassOrigin;
  
 } }
  
 SCMOInstance::SCMOInstance(SCMOClass baseClass, const CIMObjectPath& cimObj)  SCMOInstance::SCMOInstance(SCMOClass& baseClass, const CIMObjectPath& cimObj)
 { {
     _initSCMOInstance(new SCMOClass(baseClass),false,false);      _initSCMOInstance(new SCMOClass(baseClass));
  
     _setCIMObjectPath(cimObj);     _setCIMObjectPath(cimObj);
   
 } }
  
 SCMOInstance::SCMOInstance(SCMOClass baseClass, const CIMInstance& cimInstance)  SCMOInstance::SCMOInstance(SCMOClass& baseClass, const CIMInstance& cimInstance)
 { {
  
     CIMPropertyRep* propRep;      _initSCMOInstance(new SCMOClass(baseClass));
     Uint32 propNode;  
     Uint64 valueStart;  
     SCMO_RC rc;  
  
     CIMInstanceRep* instRep = cimInstance._rep;      _setCIMInstance(cimInstance);
     Boolean hasQualifiers = (instRep->_qualifiers.getCount()>0);  
     Boolean hasClassOrigin = false;  
   
     _initSCMOInstance(new SCMOClass(baseClass),hasQualifiers,hasClassOrigin);  
  
     _setCIMObjectPath(instRep->_reference);  }
  
     // Copy all properties  SCMOInstance::SCMOInstance(CIMClass& theCIMClass, const char* altNameSpace)
     for (Uint32 i = 0, k = instRep->_properties.size(); i < k; i++)  
     {  
         propRep = instRep->_properties[i]._rep;  
         // if not already detected that qualifiers are specified and  
         // there are qualifers at that property.  
         if (!hasQualifiers && propRep->getQualifierCount() > 0)  
         {         {
             includeQualifiers();      _initSCMOInstance(new SCMOClass(theCIMClass,altNameSpace));
   
         }         }
         // if not already detected that class origins are specified and  
         // there is a class origin specified at that property.  SCMOInstance::SCMOInstance(
         if (!hasClassOrigin && !propRep->_classOrigin.isNull())      const CIMInstance& cimInstance,
       const char* altNameSpace,
       Uint32 altNSLen)
         {         {
             includeClassOrigins();      SCMOClass theSCMOClass = _getSCMOClass(
         }          cimInstance._rep->_reference,
           altNameSpace,
           altNSLen);
  
         // get the property node index for the property      _initSCMOInstance( new SCMOClass(theSCMOClass));
         rc = inst.hdr->theClass->_getProperyNodeIndex(  
             propNode,  
             (const char*)propRep->_name.getString().getCString());  
  
         if (rc != SCMO_OK)      if(theSCMOClass.isEmpty())
         {  
             throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NO_SUCH_PROPERTY,  
                propRep->_name.getString());  
         }  
         rc = inst.hdr->theClass->_isNodeSameType(  
                  propNode,  
                  propRep->_value._rep->type,  
                  propRep->_value._rep->isArray);  
         if (rc == SCMO_OK)  
         {         {
             _setCIMValueAtNodeIndex(propNode, propRep->_value._rep);          // flag the instance as compromized
           inst.hdr->flags.isCompromised=true;
         }         }
         else         else
         {         {
             throw PEGASUS_CIM_EXCEPTION(CIM_ERR_TYPE_MISMATCH,          _setCIMInstance(cimInstance);
                propRep->_name.getString());  
         }         }
     }     }
  
 }  SCMOInstance::SCMOInstance(
       const CIMObject& cimObject,
       const char* altNameSpace,
       Uint32 altNSLen)
   {
       if (cimObject.isClass())
       {
           CIMClass cimClass(cimObject);
  
 void SCMOInstance::_setCIMObjectPath(const CIMObjectPath& cimObj)          _initSCMOInstance(new SCMOClass(cimClass,altNameSpace));
   
           inst.hdr->flags.isClassOnly=true;
       }
       else
 { {
     CIMObjectPathRep* objRep = cimObj._rep;          CIMInstance cimInstance(cimObject);
     SCMO_RC rc;  
  
     // For better usability define pointers to SCMO Class data structures.          SCMOClass theSCMOClass = _getSCMOClass(
     SCMBClass_Main* clshdr = inst.hdr->theClass->cls.hdr;              cimInstance._rep->_reference,
     char* clsbase = inst.hdr->theClass->cls.base;              altNameSpace,
               altNSLen);
  
     CString className = objRep->_className.getString().getCString();          _initSCMOInstance( new SCMOClass(theSCMOClass));
     CString nameSpace = objRep->_nameSpace.getString().getCString();  
  
     // Is the instance from the same class and name space ?          if(theSCMOClass.isEmpty())
     if (!(_equalNoCaseUTF8Strings(  
              clshdr->className,  
              clsbase,  
              (const char*)className,  
              strlen(className)) &&  
           _equalNoCaseUTF8Strings(  
              clshdr->nameSpace,  
              clsbase,  
              (const char*)nameSpace,  
              strlen(nameSpace)))  
         )  
     {     {
         throw PEGASUS_CIM_EXCEPTION(CIM_ERR_INVALID_CLASS,              // flag the instance as compromized
            objRep->_className.getString());              inst.hdr->flags.isCompromised=true;
     }     }
           else
     //set host name  
     _setString(objRep->_host,inst.hdr->hostName,&inst.mem );  
   
     if (inst.hdr->numberKeyBindings < objRep->_keyBindings.size())  
     {     {
         String message("CIMObjectPath has more keybindings "              _setCIMInstance(cimInstance);
                        "than the associatied class key propertties.");          }
         throw CIMException(CIM_ERR_FAILED, message);      }
     }     }
  
     for (Uint32 i = 0, k = objRep->_keyBindings.size(); i < k; i++)  SCMOInstance::SCMOInstance(
       const CIMObjectPath& cimObj,
       const char* altNameSpace,
       Uint32 altNSLen)
     {     {
       SCMOClass theSCMOClass = _getSCMOClass(
           cimObj,
           altNameSpace,
           altNSLen);
  
         rc = setKeyBinding(      _initSCMOInstance( new SCMOClass(theSCMOClass));
             (const char*)  
                     objRep->_keyBindings[i].getName().getString().getCString(),  
             objRep->_keyBindings[i].getType(),  
             (const char*) objRep->_keyBindings[i].getValue().getCString());  
  
         if (rc != SCMO_OK)      if(theSCMOClass.isEmpty())
         {         {
             switch (rc)          // flag the instance as compromized
             {          inst.hdr->flags.isCompromised=true;
             case SCMO_NOT_FOUND:  
                 {  
                     String message("CIMObjectPath key binding ");  
                     message.append(  
                         objRep->_keyBindings[i].getName().getString());  
                     message.append(" not found.");  
                     throw CIMException(CIM_ERR_FAILED, message);  
                 }                 }
             default:      else
                 {                 {
                     String message("CIMObjectPath key binding ");          _setCIMObjectPath(cimObj);
                     message.append(  
                         objRep->_keyBindings[i].getName().getString());  
                     message.append(" does not match class definition!");  
                     throw CIMException(CIM_ERR_FAILED, message);  
                 }  
             }  
         }         }
     }     }
  
 }  void SCMOInstance::_destroyExternalReferences()
 void SCMOInstance::_setCIMValueAtNodeIndex(Uint32 node, CIMValueRep* valRep)  
 { {
     SCMBValue* theInstPropNodeArray =      _destroyExternalReferencesInternal(inst.mem);
         (SCMBValue*)&inst.base[inst.hdr->propertyArray.start];  }
   
   
     SCMBValue& theInstProp = theInstPropNodeArray[node];  
  
     theInstProp.valueType=valRep->type;  SCMOClass SCMOInstance::_getSCMOClass(
     theInstProp.flags.isNull=valRep->isNull;      const CIMObjectPath& theCIMObj,
     theInstProp.flags.isArray=valRep->isArray;      const char* altNS,
     theInstProp.flags.isSet=true;      Uint32 altNSlength)
     theInstProp.valueArraySize=0;  {
       SCMOClass theClass;
  
     if (valRep->isNull)      if (theCIMObj.getClassName().isNull())
     {     {
         return;          return SCMOClass();
     }     }
  
     Uint64 start = ((const char*)&(theInstProp.value))-inst.base;      if (theCIMObj.getNameSpace().isNull())
   
     if (valRep->isArray)  
     {     {
         _setArrayValue(          // the name space of the object path is empty,
             start,          // use alternative name space.
             &inst.mem,          CString clsName = theCIMObj.getClassName().getString().getCString();
             valRep->type,  
             // Is set to the number of array members by the function.          SCMOClassCache* theCache = SCMOClassCache::getInstance();
             theInstProp.valueArraySize,          theClass = theCache->getSCMOClass(
             valRep->u);              altNS,
               altNSlength,
               (const char*)clsName,
               strlen(clsName));
     }     }
     else     else
     {     {
         _setUnionValue(start,&inst.mem,valRep->type,valRep->u);          CString nameSpace = theCIMObj.getNameSpace().getString().getCString();
           CString clsName = theCIMObj.getClassName().getString().getCString();
   
           SCMOClassCache* theCache = SCMOClassCache::getInstance();
           theClass = theCache->getSCMOClass(
               (const char*)nameSpace,
               strlen(nameSpace),
               (const char*)clsName,
               strlen(clsName));
     }     }
   
       return theClass;
 } }
  
   #define PEGASUS_SIZE_REFERENCE_INDEX_ARRAY 8
  
 Boolean SCMOInstance::isSame(SCMOInstance& theInstance) const  void SCMOInstance::_setExtRefIndex(SCMBUnion* pInst, SCMBMgmt_Header** pmem)
 { {
     return inst.base == theInstance.inst.base;  
 }  
  
 const char* SCMOInstance::getHostName() const      Uint64 refPtr =(((char *)pInst) - (char *)(*pmem));
 {      SCMBMgmt_Header* memHdr = (*pmem);
   return _getCharString(inst.hdr->hostName,inst.base);      // Save the number of external references in the array
 }      Uint32 noExtRef = memHdr->numberExtRef;
  
 void SCMOInstance::buildKeyBindingsFromProperties()      // Allocate the external reflerence array
       // if it is full or empty ( 0 == 0 ).
       if (noExtRef == memHdr->sizeExtRefIndexArray)
 { {
           Uint64 oldArrayStart = memHdr->extRefIndexArray.start;
           Uint32 newSize =
               memHdr->sizeExtRefIndexArray + PEGASUS_SIZE_REFERENCE_INDEX_ARRAY;
  
     Uint32* theClassKeyPropList =          // Allocate the external reference index array
         (Uint32*) &((inst.hdr->theClass->cls.base)          _getFreeSpace(
                           [(inst.hdr->theClass->cls.hdr->keyIndexList.start)]);                memHdr->extRefIndexArray,
                 sizeof(Uint64)*newSize,
     SCMBDataPtr* theInstKeyBindNodeArray;                pmem);
     SCMBValue* theInstPropNodeArray;  
  
     Uint32 propNode;          // reset the pointer. It could be changed due to reallocation !
           memHdr = (*pmem);
  
     for (Uint32 i = 0, k = inst.hdr->numberKeyBindings; i < k; i++)          // Assign new size.
     {          memHdr->sizeExtRefIndexArray=newSize;
         // the instance pointers has to be reinitialized eache time,  
         // because in _setKeyBindingFromSCMBUnion()  
         // a reallocation can take place.  
         theInstKeyBindNodeArray =  
             (SCMBDataPtr*)&inst.base[inst.hdr->keyBindingArray.start];  
  
         theInstPropNodeArray =          // Get absolute pointer to old index array.
             (SCMBValue*)&inst.base[inst.hdr->propertyArray.start];          Uint64* oldArray = (Uint64*)&(((char*)(*pmem))[oldArrayStart]);
           // Get absolute pointer to new index array
           Uint64* newArray =
               (Uint64*)&(((char*)(*pmem))[memHdr->extRefIndexArray.start]);
  
         // If the keybinding is not set.          // Copy all elements of the old array to the new.
         if (theInstKeyBindNodeArray[i].start == 0)          // If noExtRef = 0, no elements are copied.
           for (Uint32 i = 0 ; i < noExtRef ; i++)
         {         {
             // get the node index for this key binding form class              newArray[i] = oldArray[i];
             propNode = theClassKeyPropList[i];  
   
             // if property was not set by the provider or it is null.  
             if (!theInstPropNodeArray[propNode].flags.isSet ||  
                  theInstPropNodeArray[propNode].flags.isNull)  
             {  
                 const char * propName =  
                     inst.hdr->theClass->_getPropertyNameAtNode(propNode);  
                 throw NoSuchProperty(String(propName));  
             }             }
   
             _setKeyBindingFromSCMBUnion(  
                 theInstPropNodeArray[propNode].valueType,  
                 theInstPropNodeArray[propNode].value,  
                 theInstKeyBindNodeArray[i]);  
         }         }
     }  
 }  
   
 void SCMOInstance::_setKeyBindingFromSCMBUnion(  
     CIMType type,  
     SCMBUnion& u,  
     SCMBDataPtr& keyNode)  
 {  
     Uint32 outputLength=0;  
     const char * output;  
  
     switch (type)      // Get absolute pointer to the array
       Uint64* array =
           (Uint64*)&(((char*)(*pmem))[memHdr->extRefIndexArray.start]);
       // look in the table if the index is already in the array
       for (Uint32 i = 0 ; i < noExtRef ; i++)
     {     {
     case CIMTYPE_UINT8:          // is the index already part of the array
           if (array[i] == refPtr)
         {         {
             char buffer[22];              // leave.
             output = Uint8ToString(buffer, u._uint8Value, outputLength);              return;
             // including trailing '\0' !  
             _setBinary(output,outputLength+1,keyNode,&inst.mem);  
             break;  
         }         }
       }
       // It is not part of the array -> set the new index.
       array[noExtRef] = refPtr;
       // increment the nuber of external references of this instance.
       memHdr->numberExtRef++;
  
     case CIMTYPE_UINT16:  
         {  
             char buffer[22];  
             output = Uint16ToString(buffer, u._uint16Value, outputLength);  
             // including trailing '\0' !  
             _setBinary(output,outputLength+1,keyNode,&inst.mem);  
             break;  
         }         }
  
     case CIMTYPE_UINT32:  SCMOInstance* SCMOInstance::getExtRef(Uint32 idx) const
         {         {
             char buffer[22];      Uint64* array =
             output = Uint32ToString(buffer, u._uint32Value, outputLength);          (Uint64*)&(inst.base[inst.mem->extRefIndexArray.start]);
             // including trailing '\0' !      SCMBUnion* pUnion;
             _setBinary(output,outputLength+1,keyNode,&inst.mem);      pUnion = (SCMBUnion*)(&(inst.base[array[idx]]));
             break;      return pUnion->extRefPtr;
         }         }
  
     case CIMTYPE_UINT64:  void SCMOInstance::putExtRef(Uint32 idx,SCMOInstance* ptr)
         {         {
             char buffer[22];      Uint64* array =
             output = Uint64ToString(buffer, u._uint64Value, outputLength);          (Uint64*)&(inst.base[inst.mem->extRefIndexArray.start]);
             // including trailing '\0' !      SCMBUnion* pUnion;
             _setBinary(output,outputLength+1,keyNode,&inst.mem);      pUnion = (SCMBUnion*)(&(inst.base[array[idx]]));
             break;      pUnion->extRefPtr = ptr;
         }         }
  
     case CIMTYPE_SINT8:  void SCMOInstance::_copyExternalReferences()
         {         {
             char buffer[22];      Uint32 number = inst.mem->numberExtRef;
             output = Sint8ToString(buffer, u._sint8Value, outputLength);  
             // including trailing '\0' !  
             _setBinary(output,outputLength+1,keyNode,&inst.mem);  
             break;  
         }  
  
     case CIMTYPE_SINT16:      if (0 != number)
         {         {
             char buffer[22];          SCMBUnion* pUnion;
             output = Sint16ToString(buffer, u._sint16Value, outputLength);          Uint64* array =
             // including trailing '\0' !              (Uint64*)&(inst.base[inst.mem->extRefIndexArray.start]);
             _setBinary(output,outputLength+1,keyNode,&inst.mem);          for (Uint32 i = 0; i < number; i++)
             break;          {
               pUnion = (SCMBUnion*)(&(inst.base[array[i]]));
               if (0 != pUnion)
               {
                   pUnion->extRefPtr = new SCMOInstance(*(pUnion->extRefPtr));
               }
         }         }
  
     case CIMTYPE_SINT32:  
         {  
             char buffer[22];  
             output = Sint32ToString(buffer, u._sint32Value, outputLength);  
             // including trailing '\0' !  
             _setBinary(output,outputLength+1,keyNode,&inst.mem);  
             break;  
         }         }
  
     case CIMTYPE_SINT64:  
         {  
             char buffer[22];  
             output = Sint64ToString(buffer, u._sint64Value, outputLength);  
             // including trailing '\0' !  
             _setBinary(output,outputLength+1,keyNode,&inst.mem);  
             break;  
         }         }
  
     case CIMTYPE_REAL32:  void SCMOInstance::_destroyExternalKeyBindings()
         {         {
             char buffer[128];      // Create a pointer to keybinding node array of the class.
             output = Real32ToString(buffer, u._real32Value, outputLength);      Uint64 idx = inst.hdr->theClass.ptr->cls.hdr->keyBindingSet.nodeArray.start;
             // including trailing '\0' !      SCMBKeyBindingNode* theClassKeyBindNodeArray =
             _setBinary(output,outputLength+1,keyNode,&inst.mem);          (SCMBKeyBindingNode*)&((inst.hdr->theClass.ptr->cls.base)[idx]);
             break;  
         }  
  
     case CIMTYPE_REAL64:      // create a pointer to instanc key binding array.
       SCMBKeyBindingValue* theInstanceKeyBindingNodeArray =
           (SCMBKeyBindingValue*)&(inst.base[inst.hdr->keyBindingArray.start]);
   
       for (Uint32 i = 0; i < inst.hdr->numberKeyBindings; i++)
         {         {
             char buffer[128];          if (theInstanceKeyBindingNodeArray[i].isSet)
             output = Real64ToString(buffer, u._real64Value, outputLength);          {
             // including trailing '\0' !              // only references can be a key binding
             _setBinary(output,outputLength+1,keyNode,&inst.mem);              if (theClassKeyBindNodeArray[i].type == CIMTYPE_REFERENCE)
             break;              {
             break;                 _deleteExternalReferenceInternal(
                      inst.mem,
                      theInstanceKeyBindingNodeArray[i].data.extRefPtr);
         }         }
           }
       }// for all key bindings
  
     case CIMTYPE_CHAR16:      // Are there user defined key bindings ?
       if (0 != inst.hdr->numberUserKeyBindings)
         {         {
             Buffer out;          SCMBUserKeyBindingElement* theUserDefKBElement =
             _toString(out,u._char16Value);              (SCMBUserKeyBindingElement*)
             // including trailing '\0' !                   &(inst.base[inst.hdr->userKeyBindingElement.start]);
             _setBinary(out.getData(),out.size()+1,keyNode,&inst.mem);  
             break;  
         }  
  
     case CIMTYPE_BOOLEAN:          for(Uint32 i = 0; i < inst.hdr->numberUserKeyBindings; i++)
         {         {
             if (u._booleanValue)              if (theUserDefKBElement->value.isSet)
             {             {
                 _setBinary("TRUE",strlen("TRUE")+1,keyNode,&inst.mem);                  // only references can be a key binding.
             }                  if (theUserDefKBElement->type == CIMTYPE_REFERENCE)
             else  
             {             {
                 _setBinary("FALSE",strlen("FLASE")+1,keyNode,&inst.mem);                     _deleteExternalReferenceInternal(
                          inst.mem,
                          theUserDefKBElement->value.data.extRefPtr);
             }             }
             break;  
         }         }
  
     case CIMTYPE_STRING:              theUserDefKBElement =
         {                  (SCMBUserKeyBindingElement*)
             _setBinary(                       &(inst.base[theUserDefKBElement->nextElement.start]);
                 &inst.base[u._stringValue.start],          } // for all user def. key bindings.
                 u._stringValue.length,      }
                 keyNode,  
                 &inst.mem);  
             break;  
         }         }
  
     case CIMTYPE_DATETIME:  SCMO_RC SCMOInstance::getCIMInstance(CIMInstance& cimInstance) const
         {         {
             _setString(  
                 CIMDateTime(&u._dateTimeValue).toString(),  
                 keyNode,  
                 &inst.mem);  
             break;  
         }  
  
         case CIMTYPE_REFERENCE:      SCMO_RC rc = SCMO_OK;
       CIMObjectPath objPath;
  
             break;      // For better usability define pointers to SCMO Class data structures.
       SCMBClass_Main* clshdr = inst.hdr->theClass.ptr->cls.hdr;
       char* clsbase = inst.hdr->theClass.ptr->cls.base;
  
         case CIMTYPE_OBJECT:      getCIMObjectPath(objPath);
  
             break;      CIMInstance newInstance;
         case CIMTYPE_INSTANCE:      newInstance._rep = new CIMInstanceRep(objPath);
   
       if (inst.hdr->flags.includeQualifiers)
       {
           SCMBQualifier* qualiArray =
               (SCMBQualifier*)&(clsbase[clshdr->qualifierArray.start]);
  
             break;  
     }  
  
           CIMQualifier theCimQualifier;
           Uint32 i, k = clshdr->numberOfQualifiers;
  
           for ( i = 0 ; i < k ; i++)
           {
               SCMOClass::_getCIMQualifierFromSCMBQualifier(
                   theCimQualifier,
                   qualiArray[i],
                   clsbase);
  
               newInstance._rep->_qualifiers.addUnchecked(theCimQualifier);
           }
 } }
  
 void SCMOInstance::setHostName(const char* hostName)      if (inst.hdr->flags.exportSetOnly)
 { {
     Uint32 len;          for(Uint32 i = 0, k = inst.hdr->numberProperties; i<k; i++)
   
     if (hostName!=NULL)  
     {     {
               SCMBValue* theInstPropArray =
                   (SCMBValue*)&(inst.base[inst.hdr->propertyArray.start]);
  
         len = strlen((const char*)hostName);              // was the property set by the provider ?
         if(len != 0)              if(theInstPropArray[i].flags.isSet)
         {         {
                   // no filtering. Counter is node index
                   CIMProperty theProperty=_getCIMPropertyAtNodeIndex(i);
  
             // copy including trailing '\0'                  newInstance._rep->_properties.append(theProperty);
             _setBinary(hostName,len+1,inst.hdr->hostName,&inst.mem);  
             return;  
         }         }
   
     }     }
     inst.hdr->hostName.start=0;  
     inst.hdr->hostName.length=0;  
 } }
       else
 const char* SCMOInstance::getClassName() const      {
           for(Uint32 i = 0, k = inst.hdr->numberProperties; i<k; i++)
 { {
     return _getCharString(              // Set all properties in the CIMInstance gegarding they
         inst.hdr->theClass->cls.hdr->className,              // are part of the SCMOInstance or the SCMOClass.
         inst.hdr->theClass->cls.base);              CIMProperty theProperty=_getCIMPropertyAtNodeIndex(i);
   
               newInstance._rep->_properties.append(theProperty);
           }
 } }
  
 const char* SCMOInstance::getNameSpace() const      cimInstance = newInstance;
 {  
     return _getCharString(      return rc;
         inst.hdr->theClass->cls.hdr->nameSpace,  
         inst.hdr->theClass->cls.base);  
 } }
  
 void SCMOInstance::_initSCMOInstance(  void SCMOInstance::getCIMObjectPath(CIMObjectPath& cimObj) const
     SCMOClass* pClass,  
     Boolean inclQual,  
     Boolean inclOrigin)  
 { {
     PEGASUS_ASSERT(SCMB_INITIAL_MEMORY_CHUNK_SIZE      Array<CIMKeyBinding> keys;
         - sizeof(SCMBInstance_Main)>0);  
  
       // For better usability define pointers to SCMO Class data structures.
       SCMBClass_Main* clshdr = inst.hdr->theClass.ptr->cls.hdr;
       char* clsbase = inst.hdr->theClass.ptr->cls.base;
  
     inst.base = (char*)malloc(SCMB_INITIAL_MEMORY_CHUNK_SIZE);      // Address the class keybinding information
     if (inst.base == NULL)      SCMBKeyBindingNode* scmoClassArray =
           (SCMBKeyBindingNode*)&(clsbase[clshdr->keyBindingSet.nodeArray.start]);
   
       // Address the instance keybinding information
       SCMBKeyBindingValue* scmoInstArray =
           (SCMBKeyBindingValue*)&(inst.base[inst.hdr->keyBindingArray.start]);
   
       Uint32 numberKeyBindings = inst.hdr->numberKeyBindings;
   
       CIMValue theKeyBindingValue;
   
       for (Uint32 i = 0; i < numberKeyBindings; i ++)
     {     {
         // Not enough memory!          if (scmoInstArray[i].isSet)
         throw PEGASUS_STD(bad_alloc)();          {
               _getCIMValueFromSCMBUnion(
                   theKeyBindingValue,
                   scmoClassArray[i].type,
                   false, // can never be a null value
                   false, // can never be an array
                   0,
                   scmoInstArray[i].data,
                   inst.base);
               keys.append(
                   CIMKeyBinding(
                       CIMNameCast(_newCimString(scmoClassArray[i].name,clsbase)),
                       theKeyBindingValue
                       ));
           }
     }     }
  
     // initalize eye catcher      // Are there user defined key bindings ?
     inst.hdr->header.magic=PEGASUS_SCMB_INSTANCE_MAGIC;      if (0 != inst.hdr->numberUserKeyBindings)
     inst.hdr->header.totalSize=SCMB_INITIAL_MEMORY_CHUNK_SIZE;      {
     // The # of bytes free          SCMBUserKeyBindingElement* theUserDefKBElement =
     inst.hdr->header.freeBytes=              (SCMBUserKeyBindingElement*)
         SCMB_INITIAL_MEMORY_CHUNK_SIZE-sizeof(SCMBInstance_Main);                   &(inst.base[inst.hdr->userKeyBindingElement.start]);
     // Index to the start of the free space in this instance  
     inst.hdr->header.startOfFreeSpace=sizeof(SCMBInstance_Main);  
  
     inst.hdr->refCount=1;          for(Uint32 i = 0; i < inst.hdr->numberUserKeyBindings; i++)
           {
               if (theUserDefKBElement->value.isSet)
               {
                   _getCIMValueFromSCMBUnion(
                       theKeyBindingValue,
                       theUserDefKBElement->type,
                       false, // can never be a null value
                       false, // can never be an array
                       0,
                       theUserDefKBElement->value.data,
                       inst.base);
  
     //Assign the SCMBClass structure this instance based on.                  keys.append(
     inst.hdr->theClass = pClass;                      CIMKeyBinding(
                           CIMNameCast(
                               _newCimString(theUserDefKBElement->name,inst.base)),
                       theKeyBindingValue));
               }
               theUserDefKBElement =
                   (SCMBUserKeyBindingElement*)
                        &(inst.base[theUserDefKBElement->nextElement.start]);
           } // for all user def. key bindings.
       }
  
     // Init flags      String host = _newCimString(inst.hdr->hostName,inst.base);
     inst.hdr->flags.includeQualifiers=inclQual;  
     inst.hdr->flags.includeClassOrigin=inclOrigin;  
     inst.hdr->flags.isFiltered=false;  
  
     inst.hdr->hostName.start=0;      // Use name space and class name of the instance
     inst.hdr->hostName.length=0;      CIMNamespaceName nameSpace =
           CIMNamespaceNameCast(_newCimString(inst.hdr->instNameSpace,inst.base));
  
     // Number of key bindings      CIMName className =
     inst.hdr->numberKeyBindings =          CIMNameCast(_newCimString(inst.hdr->instClassName,inst.base));
         inst.hdr->theClass->cls.hdr->keyBindingSet.number;  
  
     // Number of properties      cimObj.set(host,nameSpace,className,keys);
     inst.hdr->numberProperties =  }
         inst.hdr->theClass->cls.hdr->propertySet.number;  
  
     // Allocate the SCMOInstanceKeyBindingArray  CIMProperty SCMOInstance::_getCIMPropertyAtNodeIndex(Uint32 nodeIdx) const
     _getFreeSpace(  {
           inst.hdr->keyBindingArray,      CIMValue theValue;
           sizeof(SCMBDataPtr)*inst.hdr->numberKeyBindings,      CIMProperty retProperty;
           &inst.mem,  
           true);  
  
     // Allocate the SCMBInstancePropertyArray      // For better usability define pointers to SCMO Class data structures.
     _getFreeSpace(      SCMBClass_Main* clshdr = inst.hdr->theClass.ptr->cls.hdr;
         inst.hdr->propertyArray,      char* clsbase = inst.hdr->theClass.ptr->cls.base;
         sizeof(SCMBValue)*inst.hdr->numberProperties,  
         &inst.mem,  
         true);  
  
     inst.hdr->propertyFilter.start=0;  
     inst.hdr->propertyFilter.length=0;  
     inst.hdr->propertyFilterIndexMap.start=0;  
     inst.hdr->propertyFilterIndexMap.length=0;  
  
       SCMBClassPropertyNode& clsProp =
           ((SCMBClassPropertyNode*)
            &(clsbase[clshdr->propertySet.nodeArray.start]))[nodeIdx];
  
 }      SCMBValue& instValue =
           ((SCMBValue*)&(inst.base[inst.hdr->propertyArray.start]))[nodeIdx];
  
 SCMO_RC SCMOInstance::getProperty(      if (instValue.flags.isSet)
     const char* name,  
     CIMType& type,  
     const void** pvalue,  
     Boolean& isArray,  
     Uint32& size ) const  
 { {
     Uint32 node;          _getCIMValueFromSCMBValue(theValue,instValue,inst.base);
     const char* pname;      }
     SCMO_RC rc = SCMO_OK;      else
       {
           _getCIMValueFromSCMBValue(
               theValue,
               clsProp.theProperty.defaultValue,
               clsbase);
       }
  
     *pvalue = NULL;  
     isArray = false;  
     size = 0;  
  
     rc = inst.hdr->theClass->_getProperyNodeIndex(node,name);  
     if (rc != SCMO_OK)      if (inst.hdr->flags.includeClassOrigin)
     {     {
         return rc;          retProperty = CIMProperty(
               CIMNameCast(_newCimString(clsProp.theProperty.name,clsbase)),
               theValue,
               theValue.getArraySize(),
               CIMNameCast(
                   _newCimString(clsProp.theProperty.refClassName,clsbase)),
               CIMNameCast(
                   _newCimString(clsProp.theProperty.originClassName,clsbase)),
               clsProp.theProperty.flags.propagated);
       }
       else
       {
            retProperty = CIMProperty(
               CIMNameCast(_newCimString(clsProp.theProperty.name,clsbase)),
               theValue,
               theValue.getArraySize(),
               CIMNameCast(
                   _newCimString(clsProp.theProperty.refClassName,clsbase)),
               CIMName(),
               clsProp.theProperty.flags.propagated);
     }     }
  
     // is filtering on ?      if (inst.hdr->flags.includeQualifiers)
     if (inst.hdr->flags.isFiltered)  
     {     {
         // Is the property NOT in the property filter ?          SCMBQualifier* qualiArray =
         if(!_isPropertyInFilter(node))              (SCMBQualifier*)
                    &(clsbase[clsProp.theProperty.qualifierArray.start]);
   
           CIMQualifier theCimQualifier;
   
           Uint32 i, k = clsProp.theProperty.numberOfQualifiers;
           for ( i = 0 ; i < k ; i++)
         {         {
             // The named propery is not part of this instance              SCMOClass::_getCIMQualifierFromSCMBQualifier(
             // due to filtering.                  theCimQualifier,
             return SCMO_NOT_FOUND;                  qualiArray[i],
                   clsbase);
   
               retProperty._rep->_qualifiers.addUnchecked(theCimQualifier);
         }         }
     }     }
  
     return  _getPropertyAtNodeIndex(node,&pname,type,pvalue,isArray,size);      return retProperty;
 } }
  
 SCMO_RC SCMOInstance::getPropertyAt(  void SCMOInstance::_getCIMValueFromSCMBUnion(
         Uint32 idx,      CIMValue& cimV,
         const char** pname,      const CIMType type,
         CIMType& type,      const Boolean isNull,
         const void** pvalue,      const Boolean isArray,
         Boolean& isArray,      const Uint32 arraySize,
         Uint32& size ) const      const SCMBUnion& scmbUn,
       const char * base)
 { {
     *pname = NULL;  
     *pvalue = NULL;  
     isArray = false;  
     size = 0;  
     Uint32 node;  
  
     // is filtering on ?      const SCMBUnion* pscmbArrayUn = 0;
     if (inst.hdr->flags.isFiltered)  
       if (isNull)
     {     {
         // check the number of properties part of the filter          cimV.setNullValue(type,isArray,arraySize);
         if (idx >= inst.hdr->filterProperties)          return;
       }
   
       if (isArray)
         {         {
             return SCMO_INDEX_OUT_OF_BOUND;          pscmbArrayUn =(SCMBUnion*)&(base[scmbUn.arrayValue.start]);
         }         }
  
         // Get absolut pointer to property filter index map of the instance      switch (type)
         Uint32* propertyFilterIndexMap =      {
         (Uint32*)&(inst.base[inst.hdr->propertyFilterIndexMap.start]);  
  
         // get the real node index of the property.      case CIMTYPE_UINT8:
         node = propertyFilterIndexMap[idx];  
     }  
     else  
     {     {
         // the index is used as node index.              if (isArray)
         node = idx;  
         if (node >= inst.hdr->numberProperties)  
         {         {
             return SCMO_INDEX_OUT_OF_BOUND;                  Array<Uint8> x;
                   for (Uint32 i = 0, k = arraySize; i < k ; i++)
                   {
                       x.append(pscmbArrayUn[i].simple.val.u8);
         }         }
                   cimV.set(x);
     }     }
               else
     return  _getPropertyAtNodeIndex(node,pname,type,pvalue,isArray,size);              {
                   cimV.set(scmbUn.simple.val.u8);
               }
               break;
 } }
  
 SCMO_RC SCMOInstance::getPropertyNodeIndex(const char* name, Uint32& node) const      case CIMTYPE_UINT16:
 { {
     SCMO_RC rc;              if (isArray)
     if(name==NULL)  
     {     {
         return SCMO_INVALID_PARAMETER;                  Array<Uint16> x;
                   for (Uint32 i = 0, k = arraySize; i < k ; i++)
                   {
                       x.append(pscmbArrayUn[i].simple.val.u16);
     }     }
                   cimV.set(x);
     rc = inst.hdr->theClass->_getProperyNodeIndex(node,name);  
   
     return rc;  
   
 } }
 SCMO_RC SCMOInstance::setPropertyWithOrigin(              else
     const char* name,  
     CIMType type,  
     void* value,  
     Boolean isArray,  
     Uint32 size,  
     const char* origin)  
 {  
     Uint32 node;  
     SCMO_RC rc;  
   
     rc = inst.hdr->theClass->_getProperyNodeIndex(node,name);  
     if (rc != SCMO_OK)  
     {     {
         return rc;                  cimV.set(scmbUn.simple.val.u16);
     }     }
               break;
     // Is the traget type OK ?  
     rc = inst.hdr->theClass->_isNodeSameType(node,type,isArray);  
     if (rc != SCMO_OK)  
     {  
         return rc;  
     }     }
  
     // is filtering on ?      case CIMTYPE_UINT32:
     if (inst.hdr->flags.isFiltered)  
     {     {
         // Is the property NOT in the property filter ?              if (isArray)
         if(!_isPropertyInFilter(node))  
         {         {
             // The named propery is not part of this instance                  Array<Uint32> x;
             // due to filtering.                  for (Uint32 i = 0, k = arraySize; i < k ; i++)
             return SCMO_NOT_FOUND;                  {
                       x.append(pscmbArrayUn[i].simple.val.u32);
         }         }
                   cimV.set(x);
     }     }
               else
     // check class origin if set.  
     if (origin!= NULL)  
     {  
         if(!inst.hdr->theClass->_isSamePropOrigin(node,origin))  
         {         {
             return SCMO_NOT_SAME_ORIGIN;                  cimV.set(scmbUn.simple.val.u32);
         }         }
               break;
     }     }
  
       case CIMTYPE_UINT64:
     _setPropertyAtNodeIndex(node,type,value,isArray,size);  
   
     return SCMO_OK;  
 }  
   
  SCMO_RC SCMOInstance::setPropertyWithNodeIndex(  
      Uint32 node,  
      CIMType type,  
      void* value,  
      Boolean isArray,  
      Uint32 size)  
  {  
      SCMO_RC rc;  
   
      if (node >= inst.hdr->numberProperties)  
      {      {
          return SCMO_INDEX_OUT_OF_BOUND;              if (isArray)
      }  
   
      // is filtering on ?  
      if (inst.hdr->flags.isFiltered)  
      {      {
          // Is the property NOT in the property filter ?                  Array<Uint64> x;
          if(!_isPropertyInFilter(node))                  for (Uint32 i = 0, k = arraySize; i < k ; i++)
          {          {
              // The proptery of the is not set due to filtering.                      x.append(pscmbArrayUn[i].simple.val.u64);
              return SCMO_OK;  
          }          }
                   cimV.set(x);
      }      }
               else
      // Is the traget type OK ?  
      rc = inst.hdr->theClass->_isNodeSameType(node,type,isArray);  
      if (rc != SCMO_OK)  
      {      {
          return rc;                  cimV.set(scmbUn.simple.val.u64);
      }      }
               break;
      _setPropertyAtNodeIndex(node,type,value,isArray,size);  
   
      return SCMO_OK;  
  }  }
  
 void SCMOInstance::_setPropertyAtNodeIndex(      case CIMTYPE_SINT8:
     Uint32 node,  
     CIMType type,  
     void* value,  
     Boolean isArray,  
     Uint32 size)  
 { {
     SCMBValue* theInstPropNodeArray =  
         (SCMBValue*)&inst.base[inst.hdr->propertyArray.start];  
   
   
     theInstPropNodeArray[node].flags.isSet=true;  
     theInstPropNodeArray[node].valueType=type;  
     theInstPropNodeArray[node].flags.isArray=isArray;  
     if (isArray)     if (isArray)
     {     {
         theInstPropNodeArray[node].valueArraySize=size;                  Array<Sint8> x;
     }                  for (Uint32 i = 0, k = arraySize; i < k ; i++)
   
     if (value==NULL)  
     {     {
         theInstPropNodeArray[node].flags.isNull=true;                      x.append(pscmbArrayUn[i].simple.val.s8);
                   }
                   cimV.set(x);
     }     }
     else     else
     {     {
         Uint64 start =                  cimV.set(scmbUn.simple.val.s8);
             (const char*)&(theInstPropNodeArray[node].value)-inst.base;  
   
         _setSCMBUnion(value,type,isArray,size,start);  
     }     }
               break;
 } }
  
 void SCMOInstance::_setSCMBUnion(      case CIMTYPE_SINT16:
     void* value,  
     CIMType type,  
     Boolean isArray,  
     Uint32 size,  
     Uint64 start)  
 {  
     SCMBUnion* u = (SCMBUnion*)&(inst.base[start]);  
   
     switch (type)  
     {  
     case CIMTYPE_BOOLEAN:  
         {         {
             if (isArray)             if (isArray)
             {             {
                 _setBinary(value,size*sizeof(Boolean),                  Array<Sint16> x;
                            u->_arrayValue,                  for (Uint32 i = 0, k = arraySize; i < k ; i++)
                            &inst.mem );                  {
                       x.append(pscmbArrayUn[i].simple.val.s16);
                   }
                   cimV.set(x);
             }             }
             else             else
             {             {
                 u->_booleanValue = *((Boolean*)value);                  cimV.set(scmbUn.simple.val.s16);
             }             }
             break;             break;
         }         }
  
     case CIMTYPE_UINT8:      case CIMTYPE_SINT32:
         {         {
             if (isArray)             if (isArray)
             {             {
                 _setBinary(value,size*sizeof(Uint8),                  Array<Sint32> x;
                            u->_arrayValue,                  for (Uint32 i = 0, k = arraySize; i < k ; i++)
                            &inst.mem );                  {
                       x.append(pscmbArrayUn[i].simple.val.s32);
                   }
                   cimV.set(x);
             }             }
             else             else
             {             {
                 u->_uint8Value = *((Uint8*)value);                  cimV.set(scmbUn.simple.val.s32);
             }             }
             break;             break;
         }         }
  
     case CIMTYPE_SINT8:      case CIMTYPE_SINT64:
         {         {
             if (isArray)             if (isArray)
             {             {
                 _setBinary(value,size*sizeof(Sint8),                  Array<Sint64> x;
                            u->_arrayValue,                  for (Uint32 i = 0, k = arraySize; i < k ; i++)
                            &inst.mem );                  {
                       x.append(pscmbArrayUn[i].simple.val.s64);
                   }
                   cimV.set(x);
             }             }
             else             else
             {             {
                 u->_sint8Value = *((Sint8*)value);                  cimV.set(scmbUn.simple.val.s64);
             }             }
             break;             break;
         }         }
  
     case CIMTYPE_UINT16:      case CIMTYPE_REAL32:
         {         {
             if (isArray)             if (isArray)
             {             {
                 _setBinary(value,size*sizeof(Uint16),                  Array<Real32> x;
                            u->_arrayValue,                  for (Uint32 i = 0, k = arraySize; i < k ; i++)
                            &inst.mem );                  {
                       x.append(pscmbArrayUn[i].simple.val.r32);
                   }
                   cimV.set(x);
             }             }
             else             else
             {             {
                 u->_uint16Value = *((Uint16*)value);                  cimV.set(scmbUn.simple.val.r32);
             }             }
             break;             break;
         }         }
  
     case CIMTYPE_SINT16:      case CIMTYPE_REAL64:
         {         {
             if (isArray)             if (isArray)
             {             {
                 _setBinary(value,size*sizeof(Sint16),                  Array<Real64> x;
                            u->_arrayValue,                  for (Uint32 i = 0, k = arraySize; i < k ; i++)
                            &inst.mem );                  {
                       x.append(pscmbArrayUn[i].simple.val.r64);
                   }
                   cimV.set(x);
             }             }
             else             else
             {             {
                 u->_sint16Value = *((Sint16*)value);                  cimV.set(scmbUn.simple.val.r64);
             }             }
             break;             break;
         }         }
  
     case CIMTYPE_UINT32:      case CIMTYPE_CHAR16:
         {         {
             if (isArray)             if (isArray)
             {             {
                 _setBinary(value,size*sizeof(Uint32),                  Array<Char16> x;
                            u->_arrayValue,                  for (Uint32 i = 0, k = arraySize; i < k ; i++)
                            &inst.mem );                  {
                       x.append(Char16(pscmbArrayUn[i].simple.val.c16));
                   }
                   cimV.set(x);
             }             }
             else             else
             {             {
                 u->_uint32Value = *((Uint32*)value);                  cimV.set(Char16(scmbUn.simple.val.c16));
             }             }
             break;             break;
         }         }
  
     case CIMTYPE_SINT32:      case CIMTYPE_BOOLEAN:
         {         {
             if (isArray)             if (isArray)
             {             {
                 _setBinary(value,size*sizeof(Sint32),                  Array<Boolean> x;
                            u->_arrayValue,                  for (Uint32 i = 0, k = arraySize; i < k ; i++)
                            &inst.mem );                  {
                       x.append(pscmbArrayUn[i].simple.val.bin);
                   }
                   cimV.set(x);
             }             }
             else             else
             {             {
                 u->_sint32Value = *((Sint32*)value);                  cimV.set(scmbUn.simple.val.bin);
             }             }
             break;             break;
         }         }
  
     case CIMTYPE_UINT64:      case CIMTYPE_STRING:
         {         {
             if (isArray)             if (isArray)
             {             {
                 _setBinary(value,size*sizeof(Uint64),  
                            u->_arrayValue,                  Array<String> x;
                            &inst.mem );  
                   for (Uint32 i = 0, k = arraySize; i < k ; i++)
                   {
                       x.append(_newCimString(pscmbArrayUn[i].stringValue,base));
                   }
                   cimV.set(x);
             }             }
             else             else
             {             {
                 u->_uint64Value = *((Uint64*)value);                  cimV.set(_newCimString(scmbUn.stringValue,base));
             }             }
             break;             break;
         }         }
  
     case CIMTYPE_SINT64:      case CIMTYPE_DATETIME:
         {         {
             if (isArray)             if (isArray)
             {             {
                 _setBinary(value,size*sizeof(Sint64),                  Array<CIMDateTime> x;
                            u->_arrayValue,  
                            &inst.mem );                  for (Uint32 i = 0, k = arraySize; i < k ; i++)
                   {
                       x.append(CIMDateTime(&(pscmbArrayUn[i].dateTimeValue)));
                   }
                   cimV.set(x);
             }             }
             else             else
             {             {
                 u->_sint64Value = *((Sint64*)value);                  cimV.set(CIMDateTime(&scmbUn.dateTimeValue));
             }             }
             break;             break;
   
         }         }
  
     case CIMTYPE_REAL32:      case CIMTYPE_REFERENCE:
         {         {
               CIMObjectPath theObjPath;
   
             if (isArray)             if (isArray)
             {             {
                 _setBinary(value,size*sizeof(Real32),                  Array<CIMObjectPath> x;
                            u->_arrayValue,                  for (Uint32 i = 0, k = arraySize; i < k ; i++)
                            &inst.mem );                  {
                       if (0 != pscmbArrayUn[i].extRefPtr)
                       {
                           pscmbArrayUn[i].extRefPtr->getCIMObjectPath(theObjPath);
                           x.append(theObjPath);
             }             }
             else             else
             {             {
                 u->_real32Value = *((Real32*)value);                          // set an empty object
                           x.append(CIMObjectPath());
             }             }
             break;  
         }         }
                   cimV.set(x);
     case CIMTYPE_REAL64:              }
               else
         {         {
             if (isArray)  
                   if (0 != scmbUn.extRefPtr)
             {             {
                 _setBinary(value,size*sizeof(Real64),                      scmbUn.extRefPtr->getCIMObjectPath(theObjPath);
                            u->_arrayValue,                      cimV.set(theObjPath);
                            &inst.mem );  
             }             }
             else             else
             {             {
                 u->_real64Value = *((Real64*)value);                      cimV.set(CIMObjectPath());
                   }
             }             }
             break;             break;
         }         }
       case CIMTYPE_OBJECT:
     case CIMTYPE_CHAR16:  
         {         {
               CIMInstance cimInstance;
               CIMClass cimClass;
   
             if (isArray)             if (isArray)
             {             {
                 _setBinary(value,size*sizeof(Char16),                  Array<CIMObject> x;
                            u->_arrayValue,                  for (Uint32 i = 0, k = arraySize; i < k ; i++)
                            &inst.mem );                  {
                       if (0 != pscmbArrayUn[i].extRefPtr)
                       {
                           // check if the Object is an emedded instance or class
                           if(pscmbArrayUn[i].extRefPtr->
                                  inst.hdr->flags.isClassOnly)
                           {
                               pscmbArrayUn[i].extRefPtr->
                                   inst.hdr->theClass.ptr->getCIMClass(cimClass);
                               x.append(CIMObject(cimClass));
             }             }
             else             else
             {             {
                 u->_char16Value = *((Char16*)value);                              pscmbArrayUn[i].extRefPtr->
             }                                  getCIMInstance(cimInstance);
             break;                              x.append(CIMObject(cimInstance));
         }         }
   
     case CIMTYPE_DATETIME:  
         {  
             if (isArray)  
             {  
                 _setBinary(value,size*sizeof(SCMBDateTime),  
                            u->_arrayValue,  
                            &inst.mem );  
             }             }
             else             else
             {             {
                 u->_dateTimeValue = *((SCMBDateTime*)value);                          // set an empty object
                           x.append(CIMObject());
             }             }
             break;  
         }         }
                   cimV.set(x);
               }
               else
               {
  
     case CIMTYPE_STRING:                  if (0 != scmbUn.extRefPtr)
         {         {
             if (isArray)                      // check if the Object is an emedded instance or class
                       if(scmbUn.extRefPtr->inst.hdr->flags.isClassOnly)
             {             {
                 SCMBDataPtr* ptr;                          scmbUn.extRefPtr->
                 char** tmp;                              inst.hdr->theClass.ptr->getCIMClass(cimClass);
                 Uint64 startPtr;                          cimV.set(CIMObject(cimClass));
                       }
                 startPtr = _getFreeSpace(                      else
                     u->_arrayValue,  
                     size*sizeof(SCMBDataPtr),  
                     &inst.mem,false);  
                 // the value is pointer to an array of char*  
                 tmp = (char**)value;  
   
                 for (Uint32 i = 0; i < size; i++)  
                 {                 {
                     ptr = (SCMBDataPtr*)&(inst.base[startPtr]);                          scmbUn.extRefPtr->getCIMInstance(cimInstance);
                     // Copy the sting including the trailing '\0'                          cimV.set(CIMObject(cimInstance));
                     _setBinary(tmp[i],strlen(tmp[i])+1,ptr[i],&inst.mem );  
                 }                 }
             }             }
             else             else
             {             {
                 // Copy the sting including the trailing '\0'                      cimV.set(CIMObject());
                 _setBinary(  
                     value,  
                     strlen((char*)value)+1,  
                     u->_stringValue,  
                     &inst.mem );  
             }             }
             break;  
         }         }
   
         case CIMTYPE_REFERENCE:  
   
             break;             break;
           }
  
         case CIMTYPE_OBJECT:  
   
             break;  
         case CIMTYPE_INSTANCE:         case CIMTYPE_INSTANCE:
           {
               CIMInstance theInstance;
  
             break;              if(isArray)
               {
                   Array<CIMInstance> x;
                   for (Uint32 i = 0, k = arraySize; i < k ; i++)
                   {
                       if (0 != pscmbArrayUn[i].extRefPtr)
                       {
                           pscmbArrayUn[i].extRefPtr->
                               getCIMInstance(theInstance);
                           x.append(theInstance);
                       }
                       else
                       {
                           // set an empty object
                           x.append(CIMInstance());
     }     }
 } }
                   cimV.set(x);
 void SCMOInstance::_setArrayValue(              }
     Uint64 start,              else
     SCMBMgmt_Header** pmem,  
     CIMType type,  
     Uint32& n,  
     Union& u)  
 { {
     SCMBUnion* scmoUnion = (SCMBUnion*)&(((char*)*pmem)[start]);  
     Uint64 arrayStart;  
  
     switch (type)                  if (0 != scmbUn.extRefPtr)
     {     {
     case CIMTYPE_BOOLEAN:                      scmbUn.extRefPtr->getCIMInstance(theInstance);
                       cimV.set(theInstance);
                   }
                   else
         {         {
             Array<Boolean> *x = reinterpret_cast<Array<Boolean>*>(&u);                      cimV.set(CIMInstance());
             n = x->size();                  }
             arrayStart = _getFreeSpace(              }
                 scmoUnion->_arrayValue,  
                 n*sizeof(Boolean),  
                 pmem);  
             memcpy(  
                 &((char*)*pmem)[arrayStart],x->getData(),n * sizeof(Boolean));  
             break;             break;
         }         }
       default:
     case CIMTYPE_UINT8:  
         {         {
             Array<Uint8> *x = reinterpret_cast<Array<Uint8>*>(&u);              PEGASUS_ASSERT(false);
             n = x->size();  
             arrayStart = _getFreeSpace(  
                 scmoUnion->_arrayValue,  
                 n*sizeof(Uint8),  
                 pmem);  
             memcpy(&((char*)*pmem)[arrayStart],x->getData(),n * sizeof(Uint8));  
             break;             break;
         }         }
       }
   }
  
     case CIMTYPE_SINT8:  void SCMOInstance::_getCIMValueFromSCMBValue(
         {      CIMValue& cimV,
             Array<Sint8> *x = reinterpret_cast<Array<Sint8>*>(&u);      const SCMBValue& scmbV,
             n = x->size();      const char * base)
             arrayStart = _getFreeSpace(  {
                 scmoUnion->_arrayValue,      SCMOInstance::_getCIMValueFromSCMBUnion(
                 n*sizeof(Sint8),          cimV,
                 pmem);          scmbV.valueType,
             memcpy(&((char*)*pmem)[arrayStart],x->getData(),n * sizeof(Sint8));          scmbV.flags.isNull,
             break;          scmbV.flags.isArray,
           scmbV.valueArraySize,
           scmbV.value,
           base);
         }         }
  
     case CIMTYPE_UINT16:  
   void SCMOInstance::_setCIMObjectPath(const CIMObjectPath& cimObj)
         {         {
             Array<Uint16> *x = reinterpret_cast<Array<Uint16>*>(&u);      CString className = cimObj.getClassName().getString().getCString();
             n = x->size();  
             arrayStart = _getFreeSpace(  
                 scmoUnion->_arrayValue,  
                 n*sizeof(Uint16),  
                 pmem);  
             memcpy(&((char*)*pmem)[arrayStart],x->getData(),n * sizeof(Uint16));  
  
             break;      // Is the instance from the same class ?
       if (!(_equalNoCaseUTF8Strings(
                inst.hdr->instClassName,
                inst.base,
                (const char*)className,
                strlen(className))))
       {
           throw PEGASUS_CIM_EXCEPTION(CIM_ERR_INVALID_CLASS,
              cimObj.getClassName().getString());
         }         }
  
     case CIMTYPE_SINT16:      //set host name
       _setString(cimObj.getHost(),inst.hdr->hostName,&inst.mem );
   
       const Array<CIMKeyBinding> & keys=cimObj.getKeyBindings();
       for (Uint32 i = 0, k = keys.size(); i < k; i++)
         {         {
             Array<Sint16> *x = reinterpret_cast<Array<Sint16>*>(&u);          String key = keys[i].getValue();
             n = x->size();          _setKeyBindingFromString(
             arrayStart = _getFreeSpace(              (const char*) keys[i].getName().getString().getCString(),
                 scmoUnion->_arrayValue,              _CIMTypeFromKeyBindingType(
                 n*sizeof(Sint16),                  (const char*)key.getCString(),
                 pmem);                  keys[i].getType()),
             memcpy(&((char*)*pmem)[arrayStart],x->getData(),n * sizeof(Sint16));              key);
             break;      }
         }         }
  
     case CIMTYPE_UINT32:  void SCMOInstance::_setCIMValueAtNodeIndex(
       Uint32 node,
       CIMValueRep* valRep,
       CIMType realType)
         {         {
             Array<Uint32> *x = reinterpret_cast<Array<Uint32>*>(&u);      SCMBValue* theInstPropNodeArray =
             n = x->size();          (SCMBValue*)&(inst.base[inst.hdr->propertyArray.start]);
             arrayStart = _getFreeSpace(  
                 scmoUnion->_arrayValue,  
                 n*sizeof(Uint32),      SCMBValue& theInstProp = theInstPropNodeArray[node];
                 pmem);  
             memcpy(&((char*)*pmem)[arrayStart],x->getData(),n * sizeof(Uint32));      theInstProp.valueType=realType;
             break;      theInstProp.flags.isNull=valRep->isNull;
       theInstProp.flags.isArray=valRep->isArray;
       theInstProp.flags.isSet=true;
       theInstProp.valueArraySize=0;
   
       if (valRep->isNull)
       {
           return;
         }         }
  
     case CIMTYPE_SINT32:      Uint64 start = ((const char*)&(theInstProp.value))-inst.base;
   
       if (valRep->isArray)
         {         {
             Array<Sint32> *x = reinterpret_cast<Array<Sint32>*>(&u);          _setUnionArrayValue(
             n = x->size();              start,
             arrayStart = _getFreeSpace(              &inst.mem,
                 scmoUnion->_arrayValue,              realType,
                 n*sizeof(Sint32),              // Is set to the number of array members by the function.
                 pmem);              theInstProp.valueArraySize,
             memcpy(&((char*)*pmem)[arrayStart],x->getData(),n * sizeof(Sint32));              inst.hdr->instNameSpace.start,
             break;              inst.hdr->instNameSpace.size,
               valRep->u);
       }
       else
       {
           _setUnionValue(
               start,
               &inst.mem,
               realType,
               inst.hdr->instNameSpace.start,
               inst.hdr->instNameSpace.size,
               valRep->u);
       }
         }         }
  
     case CIMTYPE_UINT64:  
   Boolean SCMOInstance::isSame(SCMOInstance& theInstance) const
         {         {
             Array<Uint64> *x = reinterpret_cast<Array<Uint64>*>(&u);      return inst.base == theInstance.inst.base;
             n = x->size();  
             arrayStart = _getFreeSpace(  
                 scmoUnion->_arrayValue,  
                 n*sizeof(Uint64),  
                 pmem);  
             memcpy(&((char*)*pmem)[arrayStart],x->getData(),n * sizeof(Uint64));  
             break;  
         }         }
  
     case CIMTYPE_SINT64:  void SCMOInstance::setHostName(const char* hostName)
         {         {
             Array<Sint64> *x = reinterpret_cast<Array<Sint64>*>(&u);      Uint32 len = 0;
             n = x->size();  
             arrayStart = _getFreeSpace(      _copyOnWrite();
                 scmoUnion->_arrayValue,  
                 n*sizeof(Sint64),      if (hostName!=0)
                 pmem);      {
             memcpy(&((char*)*pmem)[arrayStart],x->getData(),n * sizeof(Sint64));  
             break;          len = strlen((const char*)hostName);
       }
       // copy including trailing '\0'
       _setBinary(hostName,len+1,inst.hdr->hostName,&inst.mem);
   }
   
   const char* SCMOInstance::getHostName() const
   {
       return _getCharString(inst.hdr->hostName,inst.base);
   }
   
   const char* SCMOInstance::getHostName_l(Uint32& length) const
   {
       length = inst.hdr->hostName.size;
       if (0 == length)
       {
           return 0;
       }
       else
       {
           length--;
       }
       return _getCharString(inst.hdr->hostName,inst.base);
   }
   
   void SCMOInstance::setClassName(const char* className)
   {
       Uint32 len=0;
   
       _copyOnWrite();
   
       // flag the instance as compromized
       inst.hdr->flags.isCompromised=true;
       if (className!=0)
       {
           len = strlen((const char*)className);
       }
       // copy including trailing '\0'
       // _setBinary also sets the name to 0 if either className==0 or len+1==1
       _setBinary(className,len+1,inst.hdr->instClassName,&inst.mem);
   }
   
   void SCMOInstance::setClassName_l(const char* className, Uint32 len)
   {
       _copyOnWrite();
   
       // flag the instance as compromised
       inst.hdr->flags.isCompromised=true;
       // copy including trailing '\0'
       // _setBinary also sets the name to 0 if either className==0 or len+1==1
       _setBinary(className,len+1,inst.hdr->instClassName,&inst.mem);
   }
   
   const char* SCMOInstance::getClassName() const
   {
       return _getCharString(inst.hdr->instClassName,inst.base);
   }
   
   const char* SCMOInstance::getClassName_l(Uint32 & length) const
   {
       length = inst.hdr->instClassName.size;
       if (0 == length)
       {
           return 0;
       }
       else
       {
           length--;
       }
       return _getCharString(inst.hdr->instClassName,inst.base);
   }
   
   void SCMOInstance::setNameSpace(const char* nameSpace)
   {
       Uint32 len = 0;
   
       _copyOnWrite();
   
       // flag the instance as compromized
       inst.hdr->flags.isCompromised=true;
   
       if (nameSpace!=0)
       {
   
           len = strlen((const char*)nameSpace);
       }
       // copy including trailing '\0'
       _setBinary(nameSpace,len+1,inst.hdr->instNameSpace,&inst.mem);
   }
   
   void SCMOInstance::setNameSpace_l(const char* nameSpace, Uint32 len)
   {
       // Copy on Write is only necessary if a realloc() becomes necessary
       if (inst.mem->freeBytes < ((len+8) & ~7))
       {
           _copyOnWrite();
       }
       // flag the instance as compromized
       inst.hdr->flags.isCompromised=true;
       // copy including trailing '\0'
       _setBinary(nameSpace,len+1,inst.hdr->instNameSpace,&inst.mem);
   }
   
   const char* SCMOInstance::getNameSpace() const
   {
       return _getCharString(inst.hdr->instNameSpace,inst.base);
   }
   
   const char* SCMOInstance::getNameSpace_l(Uint32 & length) const
   {
       length = inst.hdr->instNameSpace.size;
       if (0 == length)
       {
           return 0;
       }
       else
       {
           length--;
       }
       return _getCharString(inst.hdr->instNameSpace,inst.base);
   }
   
   void SCMOInstance::completeHostNameAndNamespace(
       const char* hn,
       Uint32 hnLen,
       const char* ns,
       Uint32 nsLen)
   {
       // hostName is Null or empty String ?
       if (0 == inst.hdr->hostName.size ||
           0 == inst.base[inst.hdr->hostName.start])
       {
           // Copy on Write is only necessary if a realloc() becomes necessary
           if (inst.mem->freeBytes < ((hnLen+8) & ~7))
           {
               _copyOnWrite();
           }
           // copy including trailing '\0'
           _setBinary(hn,hnLen+1,inst.hdr->hostName,&inst.mem);
       }
       // namespace is Null or empty String ?
       if (0 == inst.hdr->instNameSpace.size ||
           0 == inst.base[inst.hdr->instNameSpace.start])
       {
           setNameSpace_l(ns,nsLen);
       }
   }
   
   
   void SCMOInstance::buildKeyBindingsFromProperties()
   {
       Uint32 propNode;
       // The theClassKeyPropList pointer will always be valid,
       // even after a realloc() caused by copyOnWrite()
       // as this is an absolute pointer to the class which does not change
       Uint32* theClassKeyPropList =
           (Uint32*) &((inst.hdr->theClass.ptr->cls.base)
                       [(inst.hdr->theClass.ptr->cls.hdr->keyIndexList.start)]);
   
       SCMBKeyBindingValue* theKeyBindValueArray =
           (SCMBKeyBindingValue*)&(inst.base[inst.hdr->keyBindingArray.start]);
       SCMBValue* theInstPropNodeArray=
           (SCMBValue*)&inst.base[inst.hdr->propertyArray.start];
   
       inst.hdr->numberKeyBindings =
           inst.hdr->theClass.ptr->cls.hdr->keyBindingSet.number;
   
       for (Uint32 i = 0, k = inst.hdr->numberKeyBindings; i < k; i++)
       {
           // If the keybinding is not set.
           if (!theKeyBindValueArray[i].isSet)
           {
               // get the node index for this key binding form class
               propNode = theClassKeyPropList[i];
   
               // if property was set by the provider and it is not null.
               if ( theInstPropNodeArray[propNode].flags.isSet &&
                   !theInstPropNodeArray[propNode].flags.isNull)
               {
                   _copyOnWrite();
                   // the instance pointers have to be recalculated as copyOnWrite
                   // might change the absolute address of these pointers
                   theInstPropNodeArray =
                       (SCMBValue*)&inst.base[inst.hdr->propertyArray.start];
                   theKeyBindValueArray =
                       (SCMBKeyBindingValue*)
                           &(inst.base[inst.hdr->keyBindingArray.start]);
   
                   _setKeyBindingFromSCMBUnion(
                       theInstPropNodeArray[propNode].valueType,
                       theInstPropNodeArray[propNode].value,
                       inst.base,
                       theKeyBindValueArray[i]);
   
                   // the instance pointers have to be reinitialized each time,
                   // because a reallocation can take place
                   // in _setKeyBindingFromSCMBUnion()
                   theKeyBindValueArray =
                       (SCMBKeyBindingValue*)
                           &(inst.base[inst.hdr->keyBindingArray.start]);
                   theInstPropNodeArray =
                       (SCMBValue*)&inst.base[inst.hdr->propertyArray.start];
   
               }
           }
       }
         }         }
  
   void SCMOInstance::_setKeyBindingFromSCMBUnion(
       CIMType type,
       const SCMBUnion& u,
       const char * uBase,
       SCMBKeyBindingValue& keyData)
   {
       switch (type)
       {
       case CIMTYPE_UINT8:
       case CIMTYPE_UINT16:
       case CIMTYPE_UINT32:
       case CIMTYPE_UINT64:
       case CIMTYPE_SINT8:
       case CIMTYPE_SINT16:
       case CIMTYPE_SINT32:
       case CIMTYPE_SINT64:
     case CIMTYPE_REAL32:     case CIMTYPE_REAL32:
       case CIMTYPE_REAL64:
       case CIMTYPE_CHAR16:
       case CIMTYPE_BOOLEAN:
         {         {
             Array<Real32> *x = reinterpret_cast<Array<Real32>*>(&u);              memcpy(&keyData.data,&u,sizeof(SCMBUnion));
             n = x->size();              keyData.data.simple.hasValue=true;
             arrayStart = _getFreeSpace(              keyData.isSet=true;
                 scmoUnion->_arrayValue,  
                 n*sizeof(Real32),  
                 pmem);  
             memcpy(&((char*)*pmem)[arrayStart],x->getData(),n * sizeof(Real32));  
             break;             break;
         }         }
       case CIMTYPE_DATETIME:
           {
               memcpy(&keyData.data,&u,sizeof(SCMBUnion));
               keyData.isSet=true;
               break;
           }
       case CIMTYPE_STRING:
           {
               keyData.isSet=true;
               // Check if a key binding is set with in the same instance.
               // If this is the case, a reallocation can take place and the
               // uBase pointer can be invalid and cause a read in freed memory!
               if (uBase == inst.base)
               {
                   if (0 != u.stringValue.size )
                   {
                       // We are doing a in instance copy of data.
                       // We can not use the _setBinary() function because
                       // all real pointer can be in valid after
                       // the _getFreeSprace() function!
                       // We have to save all relative pointer on the stack.
                       Uint64 start;
                       SCMBDataPtr tmp;
                       tmp.size = u.stringValue.size;
                       tmp.start = u.stringValue.start;
   
                       // In this function a reallocation may take place!
                       // The keyData.data.stringValue is set
                       // before the rallocation.
                       start = _getFreeSpace(
                           keyData.data.stringValue,
                           u.stringValue.size,
                           &inst.mem);
                       // Copy the string,
                       // but using the own base pointer and the saved relative
                       // string pointer.
                       memcpy(
                           &(inst.base[start]),
                           _getCharString(tmp,inst.base),
                           tmp.size);
                   }
                   else
                   {
                      keyData.data.stringValue.size=0;
                      keyData.data.stringValue.start=0;
                   }
  
     case CIMTYPE_REAL64:              }
               else
         {         {
             Array<Real64> *x = reinterpret_cast<Array<Real64>*>(&u);                  _setBinary(
             n = x->size();                      &uBase[u.stringValue.start],
             arrayStart = _getFreeSpace(                      u.stringValue.size,
                 scmoUnion->_arrayValue,                      keyData.data.stringValue,
                 n*sizeof(Real64),                      &inst.mem);
                 pmem);              }
             memcpy(&((char*)*pmem)[arrayStart],x->getData(),n * sizeof(Real64));  
             break;             break;
         }         }
       case CIMTYPE_REFERENCE:
           {
               if(0 != keyData.data.extRefPtr)
               {
                   delete keyData.data.extRefPtr;
               }
  
     case CIMTYPE_CHAR16:              if(u.extRefPtr)
         {         {
             Array<Char16> *x = reinterpret_cast<Array<Char16>*>(&u);                  keyData.data.extRefPtr = new SCMOInstance(*u.extRefPtr);
             n = x->size();                  keyData.isSet=true;
             arrayStart = _getFreeSpace(                  // This function can cause a reallocation !
                 scmoUnion->_arrayValue,                  // Pointers can be invalid after the call.
                 n*sizeof(Char16),                  _setExtRefIndex(&(keyData.data),&inst.mem);
                 pmem);              }
             memcpy(&((char*)*pmem)[arrayStart],x->getData(),n * sizeof(Char16));              else
               {
                   keyData.isSet=true;
                   keyData.data.extRefPtr=0;
               }
               break;
           }
       case CIMTYPE_OBJECT:
       case CIMTYPE_INSTANCE:
           {
               // From PEP 194: EmbeddedObjects cannot be keys.
               throw TypeMismatchException();
               break;
           }
       default:
           {
               PEGASUS_ASSERT(false);
             break;             break;
         }         }
       }
   }
   
   void SCMOInstance::_initSCMOInstance(SCMOClass* pClass)
   {
       PEGASUS_ASSERT(SCMB_INITIAL_MEMORY_CHUNK_SIZE
           - sizeof(SCMBInstance_Main)>0);
   
   
       inst.base = (char*)malloc(SCMB_INITIAL_MEMORY_CHUNK_SIZE);
       if (inst.base == 0)
       {
           // Not enough memory!
           throw PEGASUS_STD(bad_alloc)();
       }
   
       memset(inst.base,0,sizeof(SCMBInstance_Main));
   
       // initalize eye catcher
       inst.hdr->header.magic=PEGASUS_SCMB_INSTANCE_MAGIC;
       inst.hdr->header.totalSize=SCMB_INITIAL_MEMORY_CHUNK_SIZE;
       // The # of bytes free
       inst.hdr->header.freeBytes=
           SCMB_INITIAL_MEMORY_CHUNK_SIZE-sizeof(SCMBInstance_Main);
       // Index to the start of the free space in this instance
       inst.hdr->header.startOfFreeSpace=sizeof(SCMBInstance_Main);
   
       inst.hdr->refCount=1;
   
       //Assign the SCMBClass structure this instance based on.
       inst.hdr->theClass.ptr = pClass;
   
       // Copy name space name and class name of the class
       _setBinary(
           _getCharString(inst.hdr->theClass.ptr->cls.hdr->className,
                          inst.hdr->theClass.ptr->cls.base),
           inst.hdr->theClass.ptr->cls.hdr->className.size,
           inst.hdr->instClassName,
           &inst.mem);
   
       _setBinary(
           _getCharString(inst.hdr->theClass.ptr->cls.hdr->nameSpace,
                          inst.hdr->theClass.ptr->cls.base),
           inst.hdr->theClass.ptr->cls.hdr->nameSpace.size,
           inst.hdr->instNameSpace,
           &inst.mem);
   
       // Number of key bindings
       inst.hdr->numberKeyBindings =
           inst.hdr->theClass.ptr->cls.hdr->keyBindingSet.number;
   
       // Number of properties
       inst.hdr->numberProperties =
           inst.hdr->theClass.ptr->cls.hdr->propertySet.number;
   
       // Allocate the SCMOInstanceKeyBindingArray
       _getFreeSpace(
             inst.hdr->keyBindingArray,
             sizeof(SCMBKeyBindingValue)*inst.hdr->numberKeyBindings,
             &inst.mem);
   
       // Allocate the SCMBInstancePropertyArray
       _getFreeSpace(
           inst.hdr->propertyArray,
           sizeof(SCMBValue)*inst.hdr->numberProperties,
           &inst.mem);
   
   }
   
   void SCMOInstance::_setCIMInstance(const CIMInstance& cimInstance)
   {
       CIMPropertyRep* propRep;
       Uint32 propNode;
       SCMO_RC rc;
       CIMType realType;
   
       CIMInstanceRep* instRep = cimInstance._rep;
   
       // Test if the instance has qualifiers.
       // The instance level qualifiers are stored on the associated SCMOClass.
       inst.hdr->flags.includeQualifiers=(instRep->_qualifiers.getCount()>0);
   
       // To ensure that at converting a CIMInstance to a SCMOInstance
       // and vice versa do have the same property set.
       inst.hdr->flags.exportSetOnly=true;
   
       _setCIMObjectPath(instRep->_reference);
   
       // Copy all properties
       for (Uint32 i = 0, k = instRep->_properties.size(); i < k; i++)
       {
           propRep = instRep->_properties[i]._rep;
           // if not already detected that qualifiers are specified and
           // there are qualifers at that property.
           if (!inst.hdr->flags.includeQualifiers &&
               propRep->getQualifierCount() > 0)
           {
               includeQualifiers();
           }
           // if not already detected that class origins are specified and
           // there is a class origin specified at that property.
           if (!inst.hdr->flags.includeClassOrigin &&
               !propRep->_classOrigin.isNull())
           {
               includeClassOrigins();
           }
   
           // get the property node index for the property
           rc = inst.hdr->theClass.ptr->_getProperyNodeIndex(
               propNode,
               (const char*)propRep->_name.getString().getCString());
   
           if (rc == SCMO_OK)
           {
               // The type stored in the class information is set on realType.
               // It must be used in further calls to guaranty consistence.
               rc = inst.hdr->theClass.ptr->_isNodeSameType(
                        propNode,
                        propRep->_value._rep->type,
                        propRep->_value._rep->isArray,
                        realType);
               if (rc == SCMO_OK)
               {
                   _setCIMValueAtNodeIndex(
                       propNode,
                       propRep->_value._rep,
                       realType);
               }
               else
               {
                   PEG_TRACE((TRC_DISCARDED_DATA,Tracer::LEVEL2,
                       "CIMProperty '%s' with type '%s' "
                           "can not be set at SCMOInstance."
                           "It is has not same type '%s' as defined in "
                           "class '%s' of name space '%s'",
                        cimTypeToString(propRep->_value._rep->type),
                       (const char*)propRep->_name.getString().getCString(),
                        cimTypeToString(realType),
                       (const char*)instRep->_reference._rep->
                              _className.getString().getCString(),
                       (const char*)instRep->_reference._rep->
                              _nameSpace.getString().getCString()));
               }
   
           }
           else
           {
   
               PEG_TRACE((TRC_DISCARDED_DATA,Tracer::LEVEL2,
                   "CIMProperty '%s' can not be set at SCMOInstance."
                       "It is not part of class '%s' of name space '%s'",
                   (const char*)propRep->_name.getString().getCString(),
                   (const char*)instRep->_reference._rep->
                          _className.getString().getCString(),
                   (const char*)instRep->_reference._rep->
                          _nameSpace.getString().getCString()));
           }
       }
   }
   
   SCMO_RC SCMOInstance::getProperty(
       const char* name,
       CIMType& type,
       const SCMBUnion** pOutVal,
       Boolean& isArray,
       Uint32& size ) const
   {
       Uint32 node;
       const char* pname;
       SCMO_RC rc = SCMO_OK;
   
       *pOutVal = 0;
       isArray = false;
       size = 0;
   
       rc = inst.hdr->theClass.ptr->_getProperyNodeIndex(node,name);
       if (rc != SCMO_OK)
       {
           return rc;
       }
   
       return  _getPropertyAtNodeIndex(node,&pname,type,pOutVal,isArray,size);
   }
   
   SCMO_RC SCMOInstance::getPropertyAt(
           Uint32 idx,
           const char** pname,
           CIMType& type,
           const SCMBUnion** pOutVal,
           Boolean& isArray,
           Uint32& size ) const
   {
       *pname = 0;
       *pOutVal = 0;
       isArray = false;
       size = 0;
   
       if (idx >= inst.hdr->numberProperties)
       {
           return SCMO_INDEX_OUT_OF_BOUND;
       }
   
       return  _getPropertyAtNodeIndex(idx,pname,type,pOutVal,isArray,size);
   }
   
   SCMO_RC SCMOInstance::getPropertyNodeIndex(const char* name, Uint32& node) const
   {
       SCMO_RC rc;
       if(name==0)
       {
           return SCMO_INVALID_PARAMETER;
       }
   
       rc = inst.hdr->theClass.ptr->_getProperyNodeIndex(node,name);
   
       return rc;
   
   }
   
   SCMO_RC SCMOInstance::setPropertyWithOrigin(
       const char* name,
       CIMType type,
       const SCMBUnion* pInVal,
       Boolean isArray,
       Uint32 size,
       const char* origin)
   {
       // In this function no  _copyOnWrite(), it does not change the instance.
   
       Uint32 node;
       SCMO_RC rc;
       CIMType realType;
   
       rc = inst.hdr->theClass.ptr->_getProperyNodeIndex(node,name);
       if (rc != SCMO_OK)
       {
           return rc;
       }
   
       // Is the traget type OK ?
       // The type stored in the class information is set on realType.
       // It must be used in further calls to guaranty consistence.
       rc = inst.hdr->theClass.ptr->_isNodeSameType(node,type,isArray,realType);
       if (rc != SCMO_OK)
       {
           return rc;
       }
   
       // check class origin if set.
       if (origin!= 0)
       {
           if(!inst.hdr->theClass.ptr->_isSamePropOrigin(node,origin))
           {
               return SCMO_NOT_SAME_ORIGIN;
           }
       }
   
   
       _setPropertyAtNodeIndex(node,realType,pInVal,isArray,size);
   
       return SCMO_OK;
   }
   
   SCMO_RC SCMOInstance::setPropertyWithNodeIndex(
       Uint32 node,
       CIMType type,
       const SCMBUnion* pInVal,
       Boolean isArray,
       Uint32 size)
   {
       // In this function no  _copyOnWrite(), it does not change the instance.
   
       SCMO_RC rc;
       CIMType realType;
   
       if (node >= inst.hdr->numberProperties)
       {
           return SCMO_INDEX_OUT_OF_BOUND;
       }
   
       // Is the traget type OK ?
       // The type stored in the class information is set on realType.
       // It must be used in further calls to guaranty consistence.
       rc = inst.hdr->theClass.ptr->_isNodeSameType(node,type,isArray,realType);
       if (rc != SCMO_OK)
       {
           return rc;
       }
   
       _setPropertyAtNodeIndex(node,realType,pInVal,isArray,size);
   
       return SCMO_OK;
   }
   
   void SCMOInstance::_setPropertyAtNodeIndex(
       Uint32 node,
       CIMType type,
       const SCMBUnion* pInVal,
       Boolean isArray,
       Uint32 size)
   {
   
       _copyOnWrite();
   
       SCMBValue* theInstPropNodeArray =
           (SCMBValue*)&(inst.base[inst.hdr->propertyArray.start]);
   
   
       theInstPropNodeArray[node].flags.isSet=true;
       theInstPropNodeArray[node].valueType=type;
       theInstPropNodeArray[node].flags.isArray=isArray;
       if (isArray)
       {
           theInstPropNodeArray[node].valueArraySize=size;
       }
   
       if (pInVal==0)
       {
           theInstPropNodeArray[node].flags.isNull=true;
       }
       else
       {
           theInstPropNodeArray[node].flags.isNull=false;
           _setSCMBUnion(
               pInVal,
               type,
               isArray,
               size,
               theInstPropNodeArray[node].value);
       }
   }
   
   void SCMOInstance::_setSCMBUnion(
       const SCMBUnion* pInVal,
       CIMType type,
       Boolean isArray,
       Uint32 size,
       SCMBUnion & u)
   {
   
       switch (type)
       {
       case CIMTYPE_BOOLEAN:
       case CIMTYPE_UINT8:
       case CIMTYPE_SINT8:
       case CIMTYPE_UINT16:
       case CIMTYPE_SINT16:
       case CIMTYPE_UINT32:
       case CIMTYPE_SINT32:
       case CIMTYPE_UINT64:
       case CIMTYPE_SINT64:
       case CIMTYPE_REAL32:
       case CIMTYPE_REAL64:
       case CIMTYPE_CHAR16:
           {
               if (isArray)
               {
                   _setBinary(pInVal,size*sizeof(SCMBUnion),
                              u.arrayValue,
                              &inst.mem );
               }
               else
               {
                   memcpy(&u,pInVal,sizeof(SCMBUnion));
                   u.simple.hasValue=true;
               }
               break;
           }
       case CIMTYPE_DATETIME:
           {
               if (isArray)
               {
                   _setBinary(pInVal,size*sizeof(SCMBUnion),
                              u.arrayValue,
                              &inst.mem );
               }
               else
               {
                   memcpy(&u,pInVal,sizeof(SCMBUnion));
   
               }
               break;
           }
       case CIMTYPE_STRING:
           {
               if (isArray)
               {
                   SCMBUnion* ptr;
                   Uint64 startPtr;
   
                   startPtr = _getFreeSpace(
                       u.arrayValue,
                       size*sizeof(SCMBUnion),
                       &inst.mem);
   
                   for (Uint32 i = 0; i < size; i++)
                   {
                       ptr = (SCMBUnion*)&(inst.base[startPtr]);
                       // Copy the sting including the trailing '\0'
                       _setBinary(
                           pInVal[i].extString.pchar,
                           pInVal[i].extString.length+1,
                           ptr[i].stringValue,
                           &inst.mem );
                   }
               }
               else
               {
                   // Copy the sting including the trailing '\0'
                   _setBinary(
                       pInVal->extString.pchar,
                       pInVal->extString.length+1,
                       u.stringValue,
                       &inst.mem );
               }
               break;
           }
   
       case CIMTYPE_REFERENCE:
       case CIMTYPE_OBJECT:
       case CIMTYPE_INSTANCE:
           {
               if(isArray)
               {
                   SCMBUnion* ptr;
                   Uint64 startPtr;
   
                   // if the array was previously set, delete the references !
                   _deleteArrayExtReference(u.arrayValue,&inst.mem);
   
                   // get new array
                   startPtr = _getFreeSpace(
                       u.arrayValue,
                       size*sizeof(SCMBUnion),
                       &inst.mem);
   
                   ptr = (SCMBUnion*)&(inst.base[startPtr]);
   
                   for (Uint32 i = 0 ; i < size ; i++)
                   {
                       if(pInVal[i].extRefPtr)
                       {
                           ptr[i].extRefPtr=
                               new SCMOInstance(*(pInVal[i].extRefPtr));
   
                           // This function can cause a reallocation !
                           // Pointers can be invalid after the call.
                           _setExtRefIndex(&(ptr[i]),&inst.mem);
                       }
                       else
                       {
                           ptr[i].extRefPtr = 0;
                       }
                   }
   
               }
               else
               {
                   if(0 != u.extRefPtr)
                   {
                       delete u.extRefPtr;
                   }
   
                   if(pInVal->extRefPtr)
                   {
                       u.extRefPtr = new SCMOInstance(*(pInVal->extRefPtr));
                       // This function can cause a reallocation !
                       // Pointers can be invalid after the call.
                       _setExtRefIndex(&u,&inst.mem);
   
                   }
                   else
                   {
                       u.extRefPtr = 0;
                   }
               }
               break;
           }
       default:
           {
               PEGASUS_ASSERT(false);
               break;
           }
       }
   }
   
   void SCMOInstance::_setUnionArrayValue(
       Uint64 start,
       SCMBMgmt_Header** pmem,
       CIMType type,
       Uint32& n,
       Uint64 startNS,
       Uint32 sizeNS,
       Union& u)
   {
       SCMBUnion* scmoUnion = (SCMBUnion*)&(((char*)*pmem)[start]);
       SCMBUnion* ptargetUnion;
       Uint64 arrayStart;
       Uint32 loop;
   
       switch (type)
       {
       case CIMTYPE_BOOLEAN:
           {
               Array<Boolean> *x = reinterpret_cast<Array<Boolean>*>(&u);
               // n can be invalid after re-allocation in _getFreeSpace !
               loop = n = x->size();
               arrayStart = _getFreeSpace(
                   scmoUnion->arrayValue,
                   loop*sizeof(SCMBUnion),
                   pmem);
   
               ConstArrayIterator<Boolean> iterator(*x);
   
               ptargetUnion = (SCMBUnion*)&(((char*)*pmem)[arrayStart]);
               for (Uint32 i = 0; i < loop; i++)
               {
                   ptargetUnion[i].simple.val.bin  = iterator[i];
                   ptargetUnion[i].simple.hasValue = true;
               }
               break;
           }
   
       case CIMTYPE_UINT8:
           {
               Array<Uint8> *x = reinterpret_cast<Array<Uint8>*>(&u);
               // n can be invalid after re-allocation in _getFreeSpace !
               loop = n = x->size();
               arrayStart = _getFreeSpace(
                   scmoUnion->arrayValue,
                   loop*sizeof(SCMBUnion),
                   pmem);
   
               ConstArrayIterator<Uint8> iterator(*x);
   
               ptargetUnion = (SCMBUnion*)&(((char*)*pmem)[arrayStart]);
               for (Uint32 i = 0; i < loop; i++)
               {
                   ptargetUnion[i].simple.val.u8  = iterator[i];
                   ptargetUnion[i].simple.hasValue = true;
               }
               break;
           }
   
       case CIMTYPE_SINT8:
           {
               Array<Sint8> *x = reinterpret_cast<Array<Sint8>*>(&u);
               // n can be invalid after re-allocation in _getFreeSpace !
               loop = n = x->size();
               arrayStart = _getFreeSpace(
                   scmoUnion->arrayValue,
                   loop*sizeof(SCMBUnion),
                   pmem);
   
               ConstArrayIterator<Sint8> iterator(*x);
   
               ptargetUnion = (SCMBUnion*)&(((char*)*pmem)[arrayStart]);
               for (Uint32 i = 0; i < loop; i++)
               {
                   ptargetUnion[i].simple.val.s8  = iterator[i];
                   ptargetUnion[i].simple.hasValue = true;
               }
               break;
           }
   
       case CIMTYPE_UINT16:
           {
               Array<Uint16> *x = reinterpret_cast<Array<Uint16>*>(&u);
               // n can be invalid after re-allocation in _getFreeSpace !
               loop = n = x->size();
               arrayStart = _getFreeSpace(
                   scmoUnion->arrayValue,
                   loop*sizeof(SCMBUnion),
                   pmem);
   
               ConstArrayIterator<Uint16> iterator(*x);
   
               ptargetUnion = (SCMBUnion*)&(((char*)*pmem)[arrayStart]);
               for (Uint32 i = 0; i < loop; i++)
               {
                   ptargetUnion[i].simple.val.u16  = iterator[i];
                   ptargetUnion[i].simple.hasValue = true;
               }
               break;
           }
   
       case CIMTYPE_SINT16:
           {
               Array<Sint16> *x = reinterpret_cast<Array<Sint16>*>(&u);
               // n can be invalid after re-allocation in _getFreeSpace !
               loop = n = x->size();
               arrayStart = _getFreeSpace(
                   scmoUnion->arrayValue,
                   loop*sizeof(SCMBUnion),
                   pmem);
   
               ConstArrayIterator<Sint16> iterator(*x);
   
               ptargetUnion = (SCMBUnion*)&(((char*)*pmem)[arrayStart]);
               for (Uint32 i = 0; i < loop; i++)
               {
                   ptargetUnion[i].simple.val.s16  = iterator[i];
                   ptargetUnion[i].simple.hasValue = true;
               }
               break;
           }
   
       case CIMTYPE_UINT32:
           {
               Array<Uint32> *x = reinterpret_cast<Array<Uint32>*>(&u);
               // n can be invalid after re-allocation in _getFreeSpace !
               loop = n = x->size();
               arrayStart = _getFreeSpace(
                   scmoUnion->arrayValue,
                   loop*sizeof(SCMBUnion),
                   pmem);
   
               ConstArrayIterator<Uint32> iterator(*x);
   
               ptargetUnion = (SCMBUnion*)&(((char*)*pmem)[arrayStart]);
               for (Uint32 i = 0; i < loop; i++)
               {
                   ptargetUnion[i].simple.val.u32  = iterator[i];
                   ptargetUnion[i].simple.hasValue = true;
               }
               break;
           }
   
       case CIMTYPE_SINT32:
           {
               Array<Sint32> *x = reinterpret_cast<Array<Sint32>*>(&u);
               // n can be invalid after re-allocation in _getFreeSpace !
               loop = n = x->size();
               arrayStart = _getFreeSpace(
                   scmoUnion->arrayValue,
                   loop*sizeof(SCMBUnion),
                   pmem);
   
               ConstArrayIterator<Sint32> iterator(*x);
   
               ptargetUnion = (SCMBUnion*)&(((char*)*pmem)[arrayStart]);
               for (Uint32 i = 0; i < loop; i++)
               {
                   ptargetUnion[i].simple.val.s32  = iterator[i];
                   ptargetUnion[i].simple.hasValue = true;
               }
               break;
           }
   
       case CIMTYPE_UINT64:
           {
               Array<Uint64> *x = reinterpret_cast<Array<Uint64>*>(&u);
               // n can be invalid after re-allocation in _getFreeSpace !
               loop = n = x->size();
               arrayStart = _getFreeSpace(
                   scmoUnion->arrayValue,
                   loop*sizeof(SCMBUnion),
                   pmem);
   
               ConstArrayIterator<Uint64> iterator(*x);
   
               ptargetUnion = (SCMBUnion*)&(((char*)*pmem)[arrayStart]);
               for (Uint32 i = 0; i < loop; i++)
               {
                   ptargetUnion[i].simple.val.u64  = iterator[i];
                   ptargetUnion[i].simple.hasValue = true;
               }
               break;
           }
   
       case CIMTYPE_SINT64:
           {
               Array<Sint64> *x = reinterpret_cast<Array<Sint64>*>(&u);
               // n can be invalid after re-allocation in _getFreeSpace !
               loop = n = x->size();
               arrayStart = _getFreeSpace(
                   scmoUnion->arrayValue,
                   loop*sizeof(SCMBUnion),
                   pmem);
   
               ConstArrayIterator<Sint64> iterator(*x);
   
               ptargetUnion = (SCMBUnion*)&(((char*)*pmem)[arrayStart]);
               for (Uint32 i = 0; i < loop; i++)
               {
                   ptargetUnion[i].simple.val.s64  = iterator[i];
                   ptargetUnion[i].simple.hasValue = true;
               }
               break;
           }
   
       case CIMTYPE_REAL32:
           {
               Array<Real32> *x = reinterpret_cast<Array<Real32>*>(&u);
               // n can be invalid after re-allocation in _getFreeSpace !
               loop = n = x->size();
               arrayStart = _getFreeSpace(
                   scmoUnion->arrayValue,
                   loop*sizeof(SCMBUnion),
                   pmem);
   
               ConstArrayIterator<Real32> iterator(*x);
   
               ptargetUnion = (SCMBUnion*)&(((char*)*pmem)[arrayStart]);
               for (Uint32 i = 0; i < loop; i++)
               {
                   ptargetUnion[i].simple.val.r32  = iterator[i];
                   ptargetUnion[i].simple.hasValue = true;
               }
               break;
           }
   
       case CIMTYPE_REAL64:
           {
               Array<Real64> *x = reinterpret_cast<Array<Real64>*>(&u);
               // n can be invalid after re-allocation in _getFreeSpace !
               loop = n = x->size();
               arrayStart = _getFreeSpace(
                   scmoUnion->arrayValue,
                   loop*sizeof(SCMBUnion),
                   pmem);
   
               ConstArrayIterator<Real64> iterator(*x);
   
               ptargetUnion = (SCMBUnion*)&(((char*)*pmem)[arrayStart]);
               for (Uint32 i = 0; i < loop; i++)
               {
                   ptargetUnion[i].simple.val.r64  = iterator[i];
                   ptargetUnion[i].simple.hasValue = true;
               }
               break;
           }
   
       case CIMTYPE_CHAR16:
           {
               Array<Char16> *x = reinterpret_cast<Array<Char16>*>(&u);
               // n can be invalid after re-allocation in _getFreeSpace !
               loop = n = x->size();
               arrayStart = _getFreeSpace(
                   scmoUnion->arrayValue,
                   loop*sizeof(SCMBUnion),
                   pmem);
   
               ConstArrayIterator<Char16> iterator(*x);
   
               ptargetUnion = (SCMBUnion*)&(((char*)*pmem)[arrayStart]);
               for (Uint32 i = 0; i < loop; i++)
               {
                   ptargetUnion[i].simple.val.c16  = iterator[i];
                   ptargetUnion[i].simple.hasValue = true;
               }
               break;
           }
   
       case CIMTYPE_STRING:
           {
               Array<String> *x = reinterpret_cast<Array<String>*>(&u);
               // n can be invalid after re-allocation in _getFreeSpace !
               loop = n = x->size();
   
               arrayStart = _getFreeSpace(
                   scmoUnion->arrayValue,
                   loop*sizeof(SCMBUnion),
                   pmem);
   
               ConstArrayIterator<String> iterator(*x);
   
               for (Uint32 i = 0; i < loop ; i++)
               {
                   // the pointer has to be set eache loop,
                   // because a reallocation may take place.
                   ptargetUnion = (SCMBUnion*)(&((char*)*pmem)[arrayStart]);
                   _setString( iterator[i],ptargetUnion[i].stringValue, pmem );
               }
   
               break;
           }
   
       case CIMTYPE_DATETIME:
           {
               Array<CIMDateTime> *x = reinterpret_cast<Array<CIMDateTime>*>(&u);
               // n can be invalid after reallocation in _getFreeSpace !
               loop = n = x->size();
   
               arrayStart = _getFreeSpace(
                   scmoUnion->arrayValue,
                   loop*sizeof(SCMBUnion),
                   pmem);
   
               ConstArrayIterator<CIMDateTime> iterator(*x);
   
               ptargetUnion = (SCMBUnion*)(&((char*)*pmem)[arrayStart]);
   
               for (Uint32 i = 0; i < loop ; i++)
               {
                   memcpy(
                       &(ptargetUnion[i].dateTimeValue),
                       iterator[i]._rep,
                       sizeof(SCMBDateTime));
               }
               break;
           }
   
       case CIMTYPE_REFERENCE:
           {
               Array<CIMObjectPath> *x =
                   reinterpret_cast<Array<CIMObjectPath>*>(&u);
   
               // if the array was previously set, delete the references !
               _deleteArrayExtReference(scmoUnion->arrayValue,pmem);
   
               // n can be invalid after reallocation in _getFreeSpace !
               loop = n = x->size();
   
               arrayStart = _getFreeSpace(
                   scmoUnion->arrayValue,
                   loop*sizeof(SCMBUnion),
                   pmem);
   
               ConstArrayIterator<CIMObjectPath> iterator(*x);
   
               ptargetUnion = (SCMBUnion*)(&((char*)*pmem)[arrayStart]);
   
               for (Uint32 i = 0; i < loop ; i++)
               {
   
                   ptargetUnion[i].extRefPtr =
                       new SCMOInstance(
                           iterator[i],
                           &(((const char*)*pmem)[startNS]),
                           sizeNS-1);
                   // Was the conversion successful?
                   if (ptargetUnion[i].extRefPtr->isEmpty())
                   {
                       // N0, delete the SCMOInstance.
                       delete ptargetUnion[i].extRefPtr;
                       ptargetUnion[i].extRefPtr = 0;
                   }
                   else
                   {
                       _setExtRefIndex(&(ptargetUnion[i]),pmem);
                   }
               }
   
               break;
           }
       case CIMTYPE_OBJECT:
           {
               Array<CIMObject> *x =
                   reinterpret_cast<Array<CIMObject>*>(&u);
   
               // if the array was previously set, delete the references !
               _deleteArrayExtReference(scmoUnion->arrayValue,pmem);
   
               // n can be invalid after reallocation in _getFreeSpace !
               loop = n = x->size();
   
               arrayStart = _getFreeSpace(
                   scmoUnion->arrayValue,
                   loop*sizeof(SCMBUnion),
                   pmem);
   
               ConstArrayIterator<CIMObject> iterator(*x);
   
               ptargetUnion = (SCMBUnion*)(&((char*)*pmem)[arrayStart]);
   
               for (Uint32 i = 0; i < loop ; i++)
               {
                   if (iterator[i].isUninitialized())
                   {
                       // the Object was empty.
                       ptargetUnion[i].extRefPtr = 0;
                   }
                   else
                   {
                       if (iterator[i].isClass())
                       {
                           CIMClass cimClass(iterator[i]);
   
                           ptargetUnion[i].extRefPtr =
                               new SCMOInstance(
                                   cimClass,
                                   (&((const char*)*pmem)[startNS]));
                           // marke as class only !
                           ptargetUnion[i].extRefPtr->
                               inst.hdr->flags.isClassOnly=true;
   
                           // This function can cause a reallocation !
                           // Pointers can be invalid after the call.
                           _setExtRefIndex(&(ptargetUnion[i]),pmem);
                       }
                       else
                       {
                           CIMInstance theInst(iterator[i]);
   
                           ptargetUnion[i].extRefPtr =
                               new SCMOInstance(
                                   theInst,
                                   &(((const char*)*pmem)[startNS]),
                                   sizeNS-1);
                            // Was the conversion successful?
                            if (ptargetUnion[i].extRefPtr->isEmpty())
                            {
                                // N0, delete the SCMOInstance.
                                delete ptargetUnion[i].extRefPtr;
                                ptargetUnion[i].extRefPtr = 0;
                            }
                            else
                            {
                                // This function can cause a reallocation !
                                // Pointers can be invalid after the call.
                                _setExtRefIndex(&(ptargetUnion[i]),pmem);
                            }
                       }
                   }
               }
   
               break;
           }
       case CIMTYPE_INSTANCE:
           {
               Array<CIMInstance> *x =
                   reinterpret_cast<Array<CIMInstance>*>(&u);
   
               // if the array was previously set, delete the references !
               _deleteArrayExtReference(scmoUnion->arrayValue,pmem);
   
               // n can be invalid after reallocation in _getFreeSpace !
               loop = n = x->size();
   
               arrayStart = _getFreeSpace(
                   scmoUnion->arrayValue,
                   loop*sizeof(SCMBUnion),
                   pmem);
   
               ConstArrayIterator<CIMInstance> iterator(*x);
   
               ptargetUnion = (SCMBUnion*)(&((char*)*pmem)[arrayStart]);
   
               for (Uint32 i = 0; i < loop ; i++)
               {
                   if (iterator[i].isUninitialized())
                   {
                       // the Instance was empty.
                       ptargetUnion[i].extRefPtr = 0;
                   }
                   else
                   {
                       ptargetUnion[i].extRefPtr =
                           new SCMOInstance(
                               iterator[i],
                               &(((const char*)*pmem)[startNS]),
                               sizeNS-1);
                       // Was the conversion successful?
                       if (ptargetUnion[i].extRefPtr->isEmpty())
                       {
                           // N0, delete the SCMOInstance.
                           delete ptargetUnion[i].extRefPtr;
                           ptargetUnion[i].extRefPtr = 0;
                       }
                       else
                       {
                           // This function can cause a reallocation !
                           // Pointers can be invalid after the call.
                           _setExtRefIndex(&(ptargetUnion[i]),pmem);
                       }
   
                   }
               }
   
               break;
           }
       default:
           {
               PEGASUS_ASSERT(false);
               break;
           }
       }
   }
   
   
   void SCMOInstance::_setUnionValue(
       Uint64 start,
       SCMBMgmt_Header** pmem,
       CIMType type,
       Uint64 startNS,
       Uint32 sizeNS,
       Union& u)
   {
       SCMBUnion* scmoUnion = (SCMBUnion*)&(((char*)*pmem)[start]);
   
       switch (type)
       {
       case CIMTYPE_BOOLEAN:
           {
               scmoUnion->simple.val.bin = u._booleanValue;
               scmoUnion->simple.hasValue=true;
               break;
           }
   
       case CIMTYPE_UINT8:
           {
               scmoUnion->simple.val.u8 = u._uint8Value;
               scmoUnion->simple.hasValue=true;
               break;
           }
   
       case CIMTYPE_SINT8:
           {
               scmoUnion->simple.val.s8 = u._sint8Value;
               scmoUnion->simple.hasValue=true;
               break;
           }
   
       case CIMTYPE_UINT16:
           {
               scmoUnion->simple.val.u16 = u._uint16Value;
               scmoUnion->simple.hasValue=true;
               break;
           }
   
       case CIMTYPE_SINT16:
           {
               scmoUnion->simple.val.s16 = u._sint16Value;
               scmoUnion->simple.hasValue=true;
               break;
           }
   
       case CIMTYPE_UINT32:
           {
               scmoUnion->simple.val.u32 = u._uint32Value;
               scmoUnion->simple.hasValue=true;
               break;
           }
   
       case CIMTYPE_SINT32:
           {
               scmoUnion->simple.val.s32 = u._sint32Value;
               scmoUnion->simple.hasValue=true;
               break;
           }
   
       case CIMTYPE_UINT64:
           {
               scmoUnion->simple.val.u64 = u._uint64Value;
               scmoUnion->simple.hasValue=true;
               break;
           }
   
       case CIMTYPE_SINT64:
           {
               scmoUnion->simple.val.s64 = u._sint64Value;
               scmoUnion->simple.hasValue=true;
               break;
           }
   
       case CIMTYPE_REAL32:
           {
               scmoUnion->simple.val.r32 = u._real32Value;
               scmoUnion->simple.hasValue=true;
               break;
           }
   
       case CIMTYPE_REAL64:
           {
               scmoUnion->simple.val.r64 = u._real64Value;
               scmoUnion->simple.hasValue=true;
               break;
           }
   
       case CIMTYPE_CHAR16:
           {
               scmoUnion->simple.val.c16 = u._char16Value;
               scmoUnion->simple.hasValue=true;
               break;
           }
   
       case CIMTYPE_STRING:
           {
               CString cstr = ((String*)((void*)&u))->getCString();
               const char *cptr = (const char*)cstr;
               _setBinary(
                   cptr,
                   strlen(cptr) + 1,
                   scmoUnion->stringValue,
                   pmem );
               break;
           }
   
       case CIMTYPE_DATETIME:
           {
               memcpy(
                   &scmoUnion->dateTimeValue,
                   (*((CIMDateTime*)((void*)&u)))._rep,
                   sizeof(SCMBDateTime));
               break;
           }
   
       case CIMTYPE_REFERENCE:
           {
               if (0 != scmoUnion->extRefPtr)
               {
                   delete scmoUnion->extRefPtr;
                   scmoUnion->extRefPtr = 0;
               }
   
               if (0 == u._referenceValue)
               {
                 scmoUnion->extRefPtr = 0;
                 return;
               }
   
               CIMObjectPath* theCIMObj =
                   (CIMObjectPath*)((void*)&u._referenceValue);
   
               scmoUnion->extRefPtr =
                   new SCMOInstance(
                       *theCIMObj,
                       &(((const char*)*pmem)[startNS]),
                       sizeNS-1);
   
               // Was the conversion successful?
               if (scmoUnion->extRefPtr->isEmpty())
               {
                   // N0, delete the SCMOInstance.
                   delete scmoUnion->extRefPtr;
                   scmoUnion->extRefPtr = 0;
               }
               else
               {
                   // This function can cause a reallocation !
                   // Pointers can be invalid after the call.
                   _setExtRefIndex(scmoUnion,pmem);
               }
   
               break;
           }
       case CIMTYPE_OBJECT:
           {
               if (0 != scmoUnion->extRefPtr)
               {
                   delete scmoUnion->extRefPtr;
                   scmoUnion->extRefPtr = 0;
               }
   
               if (0 == u._referenceValue)
               {
                 scmoUnion->extRefPtr=0;
                 return;
               }
   
               CIMObject* theCIMObject =(CIMObject*)((void*)&u._objectValue);
   
               if (theCIMObject->isUninitialized())
               {
                   // the Object was empty.
                   scmoUnion->extRefPtr = 0;
               }
               else
               {
                   if (theCIMObject->isClass())
                   {
                       CIMClass cimClass(*theCIMObject);
   
                       scmoUnion->extRefPtr =
                           new SCMOInstance(
                               cimClass,
                               (&((const char*)*pmem)[startNS]));
                       // marke as class only !
                       scmoUnion->extRefPtr->inst.hdr->flags.isClassOnly=true;
   
                       // This function can cause a reallocation !
                       // Pointers can be invalid after the call.
                       _setExtRefIndex(scmoUnion,pmem);
                   }
                   else
                   {
                       CIMInstance theCIMInst(*theCIMObject);
   
                       scmoUnion->extRefPtr =
                           new SCMOInstance(
                               theCIMInst,
                               &(((const char*)*pmem)[startNS]),
                               sizeNS-1);
   
                        // Was the conversion successful?
                        if (scmoUnion->extRefPtr->isEmpty())
                        {
                            // N0, delete the SCMOInstance.
                            delete scmoUnion->extRefPtr;
                            scmoUnion->extRefPtr = 0;
                        }
                        else
                        {
                            // This function can cause a reallocation !
                            // Pointers can be invalid after the call.
                            _setExtRefIndex(scmoUnion,pmem);
                        }
                   }
               }
               break;
           }
       case CIMTYPE_INSTANCE:
           {
               if (0 != scmoUnion->extRefPtr)
               {
                   delete scmoUnion->extRefPtr;
                   scmoUnion->extRefPtr = 0;
               }
   
               if (0 == u._referenceValue)
               {
                 scmoUnion->extRefPtr=0;
                 return;
               }
   
               CIMInstance* theCIMInst =
                   (CIMInstance*)((void*)&u._instanceValue);
   
               if (theCIMInst->isUninitialized())
               {
                   // the Instance was empty.
                   scmoUnion->extRefPtr = 0;
               }
               else
               {
                   scmoUnion->extRefPtr =
                       new SCMOInstance(
                           *theCIMInst,
                           &(((const char*)*pmem)[startNS]),
                           sizeNS-1);
   
                    // Was the conversion successful?
                    if (scmoUnion->extRefPtr->isEmpty())
                    {
                        // N0, delete the SCMOInstance.
                        delete scmoUnion->extRefPtr;
                        scmoUnion->extRefPtr = 0;
                    }
                    else
                    {
                        // This function can cause a reallocation !
                        // Pointers can be invalid after the call.
                        _setExtRefIndex(scmoUnion,pmem);
                    }
               }
               break;
           }
       default:
           {
               PEGASUS_ASSERT(false);
               break;
           }
       }
   }
   
   SCMO_RC SCMOInstance::_getPropertyAtNodeIndex(
           Uint32 node,
           const char** pname,
           CIMType& type,
           const SCMBUnion** pvalue,
           Boolean& isArray,
           Uint32& size ) const
   {
       SCMBValue* theInstPropNodeArray =
           (SCMBValue*)&inst.base[inst.hdr->propertyArray.start];
   
       // create a pointer to property node array of the class.
       Uint64 idx = inst.hdr->theClass.ptr->cls.hdr->propertySet.nodeArray.start;
       SCMBClassPropertyNode* theClassPropNodeArray =
           (SCMBClassPropertyNode*)&(inst.hdr->theClass.ptr->cls.base)[idx];
   
       // the property name is always from the class.
       // return the absolut pointer to the property name,
       // the caller has to copy the name!
       *pname=_getCharString(
           theClassPropNodeArray[node].theProperty.name,
           inst.hdr->theClass.ptr->cls.base);
   
       // the property was set by the provider.
       if (theInstPropNodeArray[node].flags.isSet)
       {
   
           type = theInstPropNodeArray[node].valueType;
           isArray = theInstPropNodeArray[node].flags.isArray;
           if (isArray)
           {
               size = theInstPropNodeArray[node].valueArraySize;
           }
   
           if (theInstPropNodeArray[node].flags.isNull)
           {
               return SCMO_NULL_VALUE;
           }
   
           // calculate the relative index for the value.
           Uint64 start =
               (const char*)&(theInstPropNodeArray[node].value) -
               inst.base;
   
           // the caller has to copy the value !
           *pvalue = _resolveSCMBUnion(type,isArray,size,start,inst.base);
   
           return SCMO_OK;
       }
   
       // the get the defaults out of the class.
       type = theClassPropNodeArray[node].theProperty.defaultValue.valueType;
       isArray =
           theClassPropNodeArray[node].theProperty.defaultValue.flags.isArray;
       if (isArray)
       {
           size = theClassPropNodeArray[node].
                      theProperty.defaultValue.valueArraySize;
       }
   
       if (theClassPropNodeArray[node].theProperty.defaultValue.flags.isNull)
       {
           return SCMO_NULL_VALUE;
       }
   
       // calcutate the relativ start address of the value
       Uint64 start =
           (const char*)
                  &(theClassPropNodeArray[node].theProperty.defaultValue.value) -
           (inst.hdr->theClass.ptr->cls.base);
   
       *pvalue = _resolveSCMBUnion(
           type,
           isArray,
           size,
           start,
           (inst.hdr->theClass.ptr->cls.base)
           );
   
       return SCMO_OK;
   
   }
   
   SCMOInstance SCMOInstance::clone(Boolean objectPathOnly) const
   {
       if (objectPathOnly)
       {
           // Create a new, empty SCMOInstance
           SCMOInstance newInst(*(this->inst.hdr->theClass.ptr));
   
           // Copy the host name to tha new instance-
           _setBinary(
               _resolveDataPtr(this->inst.hdr->hostName,this->inst.base),
               this->inst.hdr->hostName.size,
               newInst.inst.hdr->hostName,
               &newInst.inst.mem);
   
           newInst.inst.hdr->flags.isCompromised =
               this->inst.hdr->flags.isCompromised;
   
           // If the instance contains a user set class and/or name space name
           if (this->inst.hdr->flags.isCompromised)
           {
               // Copy the class name to tha new instance-
               _setBinary(
                   _resolveDataPtr(this->inst.hdr->instClassName,this->inst.base),
                   this->inst.hdr->instClassName.size,
                   newInst.inst.hdr->instClassName,
                   &newInst.inst.mem);
   
               // Copy the name space name to tha new instance-
               _setBinary(
                   _resolveDataPtr(this->inst.hdr->instNameSpace,this->inst.base),
                   this->inst.hdr->instNameSpace.size,
                   newInst.inst.hdr->instNameSpace,
                   &newInst.inst.mem);
           }
   
           // Copy the key bindings to that new instance.
           this->_copyKeyBindings(newInst);
   
           return newInst;
       }
   
       SCMOInstance newInst;
       newInst.inst.base = inst.base;
       newInst._clone();
   
       return newInst;
   }
   
   void SCMOInstance::_clone()
   {
       char* newBase;
       newBase = (char*)malloc((size_t)inst.mem->totalSize);
       if (0 == newBase )
       {
           throw PEGASUS_STD(bad_alloc)();
       }
   
       memcpy( newBase,inst.base,(size_t)inst.mem->totalSize);
   
       // make new new memory block to mine.
       inst.base = newBase;
       // reset the refcounter of this instance
       inst.hdr->refCount = 1;
       // keep the ref counter of the class correct !
       inst.hdr->theClass.ptr = new SCMOClass(*(inst.hdr->theClass.ptr));
       // keep the ref count for external references
       _copyExternalReferences();
   
   }
   
   void SCMOInstance::_copyKeyBindings(SCMOInstance& targetInst) const
   {
       Uint32 noBindings = inst.hdr->numberKeyBindings;
   
       SCMBKeyBindingValue* sourceArray =
           (SCMBKeyBindingValue*)&(inst.base[inst.hdr->keyBindingArray.start]);
   
       // Address the class keybinding information
       const SCMBClass_Main* clshdr = inst.hdr->theClass.ptr->cls.hdr;
       const char * clsbase = inst.hdr->theClass.ptr->cls.base;
       SCMBKeyBindingNode* scmoClassArray =
           (SCMBKeyBindingNode*)&(clsbase[clshdr->keyBindingSet.nodeArray.start]);
   
       SCMBKeyBindingValue* targetArray;
   
       for (Uint32 i = 0; i < noBindings; i++)
       {
           // hast to be set every time, because of reallocation.
           targetArray=(SCMBKeyBindingValue*)&(targetInst.inst.base)
                                [targetInst.inst.hdr->keyBindingArray.start];
           if(sourceArray[i].isSet)
           {
               // this has to be done on the target instance to keep constantness.
               targetInst._setKeyBindingFromSCMBUnion(
                   scmoClassArray[i].type,
                   sourceArray[i].data,
                   inst.base,
                   targetArray[i]);
           }
       }
   
       // Are there user defined key bindings ?
       if (0 != inst.hdr->numberUserKeyBindings)
       {
           SCMBUserKeyBindingElement* theUserDefKBElement =
               (SCMBUserKeyBindingElement*)
                    &(inst.base[inst.hdr->userKeyBindingElement.start]);
   
           for(Uint32 i = 0; i < inst.hdr->numberUserKeyBindings; i++)
           {
               if (theUserDefKBElement->value.isSet)
               {
                   targetInst._setUserDefinedKeyBinding(*theUserDefKBElement,
                                                           inst.base);
               }
   
               theUserDefKBElement =
                   (SCMBUserKeyBindingElement*)
                        &(inst.base[theUserDefKBElement->nextElement.start]);
           } // for all user def. key bindings.
       }
   }
   
   
   void SCMOInstance::_setUserDefinedKeyBinding(
           SCMBUserKeyBindingElement& theInsertElement,
           char* elementBase)
   {
   
       SCMBUserKeyBindingElement* ptrNewElement;
   
       // get an exsiting or new user defined key binding
       ptrNewElement = _getUserDefinedKeyBinding(
           _getCharString(theInsertElement.name,elementBase),
           // lenght is without the trailing '\0'
           theInsertElement.name.size-1,
           theInsertElement.type);
   
       // Copy the data
       _setKeyBindingFromSCMBUnion(
                   theInsertElement.type,
                   theInsertElement.value.data,
                   elementBase,
                   ptrNewElement->value);
   
   }
   
   
   SCMBUserKeyBindingElement* SCMOInstance::_getUserDefinedKeyBindingAt(
       Uint32 index ) const
   {
   
       // Get the start element
       SCMBUserKeyBindingElement *ptrNewElement =
           (SCMBUserKeyBindingElement*)
                &(inst.base[inst.hdr->userKeyBindingElement.start]);
   
       // calculate the index within the user defined key bindings
       index = index - inst.hdr->numberKeyBindings;
   
       // traverse trough the user defindes key binding nodes.
       for (Uint32 i = 0; i < index; i ++)
       {
           PEGASUS_ASSERT(ptrNewElement->nextElement.start != 0);
           ptrNewElement = (SCMBUserKeyBindingElement*)
                 &(inst.base[ptrNewElement->nextElement.start]);
       }
   
       return ptrNewElement;
   }
   
   SCMBUserKeyBindingElement* SCMOInstance::_getUserDefinedKeyBinding(
       const char* name,
       Uint32 nameLen,
       CIMType type)
   {
       SCMBDataPtr newElement;
       SCMBUserKeyBindingElement* ptrNewElement;
       Uint32 node;
   
       // is the key binding already stored as user defind in the instance ?
       if (SCMO_OK == _getUserKeyBindingNodeIndex(node,name))
       {
          ptrNewElement = _getUserDefinedKeyBindingAt(node);
       }
       else // Not found, create a new user defined key binding.
       {
   
           _getFreeSpace(newElement,
                         sizeof(SCMBUserKeyBindingElement),
                         &inst.mem);
   
           ptrNewElement =
               (SCMBUserKeyBindingElement*)&(inst.base[newElement.start]);
   
           // link new first user defined key binding element into chain:
           // - Assing the start point of user key binding element chain
           //   to the next element of the new element.
           ptrNewElement->nextElement.start =
               inst.hdr->userKeyBindingElement.start;
           ptrNewElement->nextElement.size =
               inst.hdr->userKeyBindingElement.size;
           // - Assing the the new element
           //   to the  start point of user key binding element chain
           inst.hdr->userKeyBindingElement.start = newElement.start;
           inst.hdr->userKeyBindingElement.size = newElement.size;
           // Adjust the couter of user defined key bindings.
           inst.hdr->numberUserKeyBindings++;
   
   
           // Copy the type
           ptrNewElement->type = type;
           ptrNewElement->value.isSet=false;
   
           // Copy the key binding name including the trailing '\0'
           _setBinary(name,nameLen+1,ptrNewElement->name,&inst.mem);
   
           // reset the pointer. May the instance was reallocated.
           ptrNewElement =
               (SCMBUserKeyBindingElement*)&(inst.base[newElement.start]);
   
       }
   
   
       return ptrNewElement;
   
   }
   
   Uint32 SCMOInstance::getPropertyCount() const
   {
       return(inst.hdr->numberProperties);
   }
   
   SCMBUnion * SCMOInstance::_resolveSCMBUnion(
       CIMType type,
       Boolean isArray,
       Uint32 size,
       Uint64 start,
       char* base) const
   {
   
       SCMBUnion* u = (SCMBUnion*)&(base[start]);
   
       SCMBUnion* av = 0;
   
       if (isArray)
       {
           if (size == 0)
           {
               return 0;
           }
           av = (SCMBUnion*)&(base[u->arrayValue.start]);
       }
   
       switch (type)
       {
       case CIMTYPE_BOOLEAN:
       case CIMTYPE_UINT8:
       case CIMTYPE_SINT8:
       case CIMTYPE_UINT16:
       case CIMTYPE_SINT16:
       case CIMTYPE_UINT32:
       case CIMTYPE_SINT32:
       case CIMTYPE_UINT64:
       case CIMTYPE_SINT64:
       case CIMTYPE_REAL32:
       case CIMTYPE_REAL64:
       case CIMTYPE_CHAR16:
       case CIMTYPE_DATETIME:
       case CIMTYPE_REFERENCE:
       case CIMTYPE_OBJECT:
       case CIMTYPE_INSTANCE:
           {
               if(isArray)
               {
                   return (av);
               }
               else
               {
                   return(u);
               }
           }
   
       case CIMTYPE_STRING:
           {
               SCMBUnion *ptr;
   
               if (isArray)
               {
   
                   ptr = (SCMBUnion*)malloc(size*sizeof(SCMBUnion));
                   if (ptr == 0 )
                   {
                       throw PEGASUS_STD(bad_alloc)();
                   }
   
                   for(Uint32 i = 0; i < size; i++)
                   {
                       // resolv relative pointer to absolute pointer
                       ptr[i].extString.pchar =
                           (char*)_getCharString(av[i].stringValue,base);
                       // lenght with out the trailing /0 !
                       ptr[i].extString.length = av[i].stringValue.size-1;
                   }
               }
               else
               {
                   ptr = (SCMBUnion*)malloc(sizeof(SCMBUnion));
                   ptr->extString.pchar =
                       (char*)_getCharString(u->stringValue,base);
                   // lenght with out the trailing /0 !
                   ptr->extString.length = u->stringValue.size-1;
               }
   
               return(ptr);
           }
       default:
           {
               PEGASUS_ASSERT(false);
               break;
           }
       }
       return 0;
   }
   
   void SCMOInstance::clearKeyBindings()
   {
       _copyOnWrite();
   
       // First destroy all external references in the key bindings
       _destroyExternalKeyBindings();
   
       // reset user keybindings
       inst.hdr->numberUserKeyBindings = 0;
       inst.hdr->userKeyBindingElement.start = 0;
       inst.hdr->userKeyBindingElement.size = 0;
   
       // Allocate a clean the SCMOInstanceKeyBindingArray
       _getFreeSpace(
             inst.hdr->keyBindingArray,
             sizeof(SCMBKeyBindingValue)*inst.hdr->numberKeyBindings,
             &inst.mem);
   
       // Clear the keybindings after the allocation. Setting the keybindings
       // later causes this value to be reinitialized.
       inst.hdr->numberKeyBindings = 0;
   
       markAsCompromised();
   }
   
   Uint32 SCMOInstance::getKeyBindingCount() const
   {
       // count of class keys + user definded keys
       return(inst.hdr->numberKeyBindings+
              inst.hdr->numberUserKeyBindings);
   }
   
   
   SCMO_RC SCMOInstance::getKeyBindingAt(
           Uint32 node,
           const char** pname,
           CIMType& type,
           const SCMBUnion** pvalue) const
   {
       SCMO_RC rc;
       const SCMBUnion* pdata=0;
       Uint32 pnameLen=0;
   
       *pname = 0;
       *pvalue = 0;
   
       // count of class keys + user definded keys
       if (node >= (inst.hdr->numberKeyBindings+
                    inst.hdr->numberUserKeyBindings))
       {
           return SCMO_INDEX_OUT_OF_BOUND;
       }
   
       rc = _getKeyBindingDataAtNodeIndex(node,pname,pnameLen,type,&pdata);
       if (rc != SCMO_OK)
       {
           return rc;
       }
   
       *pvalue = _resolveSCMBUnion(
           type,
           false,  // A key binding can never be an array.
           0,
           (char*)pdata-inst.base,
           inst.base);
   
       return SCMO_OK;
   
   }
   
   SCMO_RC SCMOInstance::getKeyBinding(
       const char* name,
       CIMType& type,
       const SCMBUnion** pvalue) const
   {
       SCMO_RC rc;
       Uint32 node;
       const char* pname=0;
       const SCMBUnion* pdata=0;
       Uint32 pnameLen=0;
   
       *pvalue = 0;
   
       rc = inst.hdr->theClass.ptr->_getKeyBindingNodeIndex(node,name);
       if (rc != SCMO_OK)
       {
           // look at the user defined key bindings.
           rc = _getUserKeyBindingNodeIndex(node,name);
           if (rc != SCMO_OK)
           {
               return rc;
           }
       }
   
       rc = _getKeyBindingDataAtNodeIndex(node,&pname,pnameLen,type,&pdata);
   
       if (rc != SCMO_OK)
       {
           return rc;
       }
   
       *pvalue = _resolveSCMBUnion(
           type,
           false,  // A key binding can never be an array.
           0,
           (char*)pdata-inst.base,
           inst.base);
   
       return SCMO_OK;
   }
  
     case CIMTYPE_STRING:  
   SCMO_RC SCMOInstance::_getKeyBindingDataAtNodeIndex(
       Uint32 node,
       const char** pname,
       Uint32 & pnameLen,
       CIMType & type,
       const SCMBUnion** pdata) const
   {
       if (node < inst.hdr->numberKeyBindings)
         {         {
             SCMBDataPtr *ptr;          SCMBKeyBindingValue* theInstKeyBindValueArray =
               (SCMBKeyBindingValue*)&(inst.base[inst.hdr->keyBindingArray.start]);
  
             Array<String> *x = reinterpret_cast<Array<String>*>(&u);          // create a pointer to key binding node array of the class.
           Uint64 idx = inst.hdr->theClass.ptr->cls.hdr->
               keyBindingSet.nodeArray.start;
           SCMBKeyBindingNode* theClassKeyBindNodeArray =
               (SCMBKeyBindingNode*)&((inst.hdr->theClass.ptr->cls.base)[idx]);
  
             n = x->size();          type = theClassKeyBindNodeArray[node].type;
             arrayStart = _getFreeSpace(  
                 scmoUnion->_arrayValue,  
                 n*sizeof(SCMBDataPtr),  
                 pmem);  
  
             for (Uint32 i = 0; i < n ; i++)          // First resolve pointer to the key binding name
           pnameLen = theClassKeyBindNodeArray[node].name.size;
           *pname = _getCharString(
               theClassKeyBindNodeArray[node].name,
               inst.hdr->theClass.ptr->cls.base);
   
           // There is no value set in the instance
           if (!theInstKeyBindValueArray[node].isSet)
             {             {
                 // the pointer has to be set eache loop,              return SCMO_NULL_VALUE;
                 // because a reallocation may take place.  
                 ptr = (SCMBDataPtr*)(&((char*)*pmem)[arrayStart]);  
                 _setString( (*x)[i],ptr[i], pmem );  
             }             }
  
             break;          *pdata = &(theInstKeyBindValueArray[node].data);
         }         }
       else // look at the user defined key bindings
     case CIMTYPE_DATETIME:  
         {         {
             SCMBDateTime *ptr;  
             Array<CIMDateTime> *x = reinterpret_cast<Array<CIMDateTime>*>(&u);  
             n = x->size();  
             arrayStart = _getFreeSpace(  
                 scmoUnion->_arrayValue,  
                 n*sizeof(SCMBDateTime),  
                 pmem);  
  
             ptr=(SCMBDateTime*)(&((char*)*pmem)[arrayStart]);          SCMBUserKeyBindingElement* theElem = _getUserDefinedKeyBindingAt(node);
   
           type = theElem->type;
  
             for (Uint32 i = 0; i < n ; i++)          pnameLen = theElem->name.size;
           *pname = _getCharString(theElem->name,inst.base);
   
           // There is no value set in the instance
           if (!theElem->value.isSet)
             {             {
                 memcpy(&(ptr[i]),(*x)[i]._rep,sizeof(SCMBDateTime));              return SCMO_NULL_VALUE;
             }             }
             break;  
           *pdata = &(theElem->value.data);
   
         }         }
  
         case CIMTYPE_REFERENCE:      return SCMO_OK;
   }
  
             break;  SCMO_RC SCMOInstance::_getUserKeyBindingNodeIndex(
       Uint32& node,
       const char* name) const
   {
  
         case CIMTYPE_OBJECT:      Uint32 len = strlen(name);
       node = 0;
  
             break;      Uint64 elementStart = inst.hdr->userKeyBindingElement.start;
  
         case CIMTYPE_INSTANCE:      while (elementStart != 0)
       {
           SCMBUserKeyBindingElement* theUserDefKBElement =
               (SCMBUserKeyBindingElement*)&(inst.base[elementStart]);
  
             break;          if (_equalNoCaseUTF8Strings(
               theUserDefKBElement->name,inst.base,name,len))
           {
               // the node index of a user defined key binding has an offset
               // by the number of key bindings defined in the class
               node = node + inst.hdr->numberKeyBindings;
               return SCMO_OK;
     }     }
           node = node + 1;
           elementStart = theUserDefKBElement->nextElement.start;
 } }
  
       return SCMO_NOT_FOUND;
  
 void SCMOInstance::_setUnionValue(  }
     Uint64 start,  
     SCMBMgmt_Header** pmem,  
     CIMType type,  
     Union& u)  
 {  
     SCMBUnion* scmoUnion = (SCMBUnion*)&(((char*)*pmem)[start]);  
  
     switch (type)  CIMType SCMOInstance::_CIMTypeFromKeyBindingType(
       const char* key,
       CIMKeyBinding::Type t)
     {     {
     case CIMTYPE_BOOLEAN:      switch( t )
         {         {
             scmoUnion->_booleanValue = u._booleanValue;          case CIMKeyBinding::NUMERIC:
             break;              {
                   if( *(key)=='-' )
                   {
                      Sint64 x;
                      // check if it is realy an integer
                      if (StringConversion::stringToSignedInteger(key, x))
                      {
                          return CIMTYPE_SINT64;
         }         }
                      else
     case CIMTYPE_UINT8:  
         {         {
             scmoUnion->_uint8Value = u._uint8Value;                         return CIMTYPE_REAL64;
             break;  
         }         }
                   }
     case CIMTYPE_SINT8:                  else
         {         {
             scmoUnion->_sint8Value = u._sint8Value;                      Uint64 x;
             break;                      // check if it is realy an integer
                       if (StringConversion::stringToUnsignedInteger(key, x))
                       {
                           return CIMTYPE_UINT64;
         }         }
                       else
     case CIMTYPE_UINT16:  
         {         {
             scmoUnion->_uint16Value = u._uint16Value;                          return CIMTYPE_REAL64;
             break;                      }
                   }
         }         }
  
     case CIMTYPE_SINT16:  
           case CIMKeyBinding::STRING:
         {         {
             scmoUnion->_sint16Value = u._sint16Value;              return CIMTYPE_STRING;
             break;  
         }         }
  
     case CIMTYPE_UINT32:          case CIMKeyBinding::BOOLEAN:
         {         {
             scmoUnion->_uint32Value = u._uint32Value;              return CIMTYPE_BOOLEAN;
             break;  
         }         }
  
     case CIMTYPE_SINT32:          case CIMKeyBinding::REFERENCE:
         {         {
             scmoUnion->_sint32Value = u._sint32Value;              return CIMTYPE_REFERENCE;
             break;  
         }         }
  
     case CIMTYPE_UINT64:          default:
         {              return CIMTYPE_UINT64;
             scmoUnion->_uint64Value = u._uint64Value;      }
             break;      return CIMTYPE_UINT64;
         }         }
  
     case CIMTYPE_SINT64:  Boolean SCMOInstance::_setCimKeyBindingStringToSCMOKeyBindingValue(
       const String& kbs,
       CIMType type,
       SCMBKeyBindingValue& scmoKBV
       )
         {         {
             scmoUnion->_sint64Value = u._sint64Value;      scmoKBV.isSet=false;
             break;      // If it not a simple value, it will be over written.
         }      scmoKBV.data.simple.hasValue=false;
  
     case CIMTYPE_REAL32:      if ( kbs.size() == 0 && type != CIMTYPE_STRING)
         {         {
             scmoUnion->_real32Value = u._real32Value;          // The string is empty ! Do nothing.
             break;          return false;
         }         }
  
     case CIMTYPE_REAL64:      CString a = kbs.getCString();
       const char* v = a;
   
       switch (type)
       {
       case CIMTYPE_UINT8:
         {         {
             scmoUnion->_real64Value = u._real64Value;              Uint64 x;
               if (StringConversion::stringToUnsignedInteger(v, x) &&
                   StringConversion::checkUintBounds(x, type))
               {
                 scmoKBV.data.simple.val.u8 = Uint8(x);
                 scmoKBV.data.simple.hasValue=true;
                 scmoKBV.isSet=true;
               }
             break;             break;
         }         }
       case CIMTYPE_UINT16:
     case CIMTYPE_CHAR16:  
         {         {
             scmoUnion->_char16Value = u._char16Value;              Uint64 x;
               if (StringConversion::stringToUnsignedInteger(v, x) &&
                   StringConversion::checkUintBounds(x, type))
               {
                 scmoKBV.data.simple.val.u16 = Uint16(x);
                 scmoKBV.data.simple.hasValue=true;
                 scmoKBV.isSet=true;
               }
             break;             break;
         }         }
  
     case CIMTYPE_STRING:      case CIMTYPE_UINT32:
         {         {
             _setString(*((String*)((void*)&u)),              Uint64 x;
                        scmoUnion->_stringValue,              if (StringConversion::stringToUnsignedInteger(v, x) &&
                        pmem );                  StringConversion::checkUintBounds(x, type))
               {
                 scmoKBV.data.simple.val.u32 = Uint32(x);
                 scmoKBV.data.simple.hasValue=true;
                 scmoKBV.isSet=true;
               }
             break;             break;
         }         }
  
     case CIMTYPE_DATETIME:      case CIMTYPE_UINT64:
         {         {
               Uint64 x;
             memcpy(              if (StringConversion::stringToUnsignedInteger(v, x))
                 &scmoUnion->_dateTimeValue,              {
                 (*((CIMDateTime*)((void*)&u)))._rep,                scmoKBV.data.simple.val.u64 = x;
                 sizeof(SCMBDateTime));                scmoKBV.data.simple.hasValue=true;
             break;                scmoKBV.isSet=true;
         }         }
   
         case CIMTYPE_REFERENCE:  
   
             break;  
   
         case CIMTYPE_OBJECT:  
   
             break;             break;
         case CIMTYPE_INSTANCE:          }
  
       case CIMTYPE_SINT8:
           {
               Sint64 x;
               if (StringConversion::stringToSignedInteger(v, x) &&
                   StringConversion::checkSintBounds(x, type))
               {
                 scmoKBV.data.simple.val.s8 = Sint8(x);
                 scmoKBV.data.simple.hasValue=true;
                 scmoKBV.isSet=true;
               }
             break;             break;
     }     }
  
       case CIMTYPE_SINT16:
           {
               Sint64 x;
               if (StringConversion::stringToSignedInteger(v, x) &&
                   StringConversion::checkSintBounds(x, type))
               {
                 scmoKBV.data.simple.val.s16 = Sint16(x);
                 scmoKBV.data.simple.hasValue=true;
                 scmoKBV.isSet=true;
               }
               break;
 } }
  
 SCMO_RC SCMOInstance::_getPropertyAtNodeIndex(      case CIMTYPE_SINT32:
         Uint32 node,  
         const char** pname,  
         CIMType& type,  
         const void** pvalue,  
         Boolean& isArray,  
         Uint32& size ) const  
 { {
     SCMBValue* theInstPropNodeArray =              Sint64 x;
         (SCMBValue*)&inst.base[inst.hdr->propertyArray.start];              if (StringConversion::stringToSignedInteger(v, x) &&
                   StringConversion::checkSintBounds(x, type))
     // create a pointer to property node array of the class.              {
     Uint64 idx = inst.hdr->theClass->cls.hdr->propertySet.nodeArray.start;                scmoKBV.data.simple.val.s32 = Sint32(x);
     SCMBClassPropertyNode* theClassPropNodeArray =                scmoKBV.data.simple.hasValue=true;
         (SCMBClassPropertyNode*)&(inst.hdr->theClass->cls.base)[idx];                scmoKBV.isSet=true;
               }
     // the property name is always from the class.              break;
     // return the absolut pointer to the property name,          }
     // the caller has to copy the name!  
     *pname=_getCharString(  
         theClassPropNodeArray[node].theProperty.name,  
         inst.hdr->theClass->cls.base);  
  
     // the property was set by the provider.      case CIMTYPE_SINT64:
     if (theInstPropNodeArray[node].flags.isSet)  
     {     {
               Sint64 x;
         type = theInstPropNodeArray[node].valueType;              if (StringConversion::stringToSignedInteger(v, x))
         isArray = theInstPropNodeArray[node].flags.isArray;  
         if (isArray)  
         {         {
             size = theInstPropNodeArray[node].valueArraySize;                scmoKBV.data.simple.val.s64 = x;
                 scmoKBV.data.simple.hasValue=true;
                 scmoKBV.isSet=true;
         }         }
               break;
         if (theInstPropNodeArray[node].flags.isNull)  
         {  
             return SCMO_NULL_VALUE;  
         }         }
  
         // calculate the relative index for the value.      case CIMTYPE_DATETIME:
         Uint64 start =          {
             (const char*)&(theInstPropNodeArray[node].value) -              CIMDateTime tmp;
             inst.base;  
   
         // the caller has to copy the value !  
         *pvalue = _getSCMBUnion(type,isArray,size,start,inst.base);  
   
         return SCMO_OK;  
     }  
  
     // the get the defaults out of the class.              try
     type = theClassPropNodeArray[node].theProperty.defaultValue.valueType;  
     isArray =  
         theClassPropNodeArray[node].theProperty.defaultValue.flags.isArray;  
     if (isArray)  
     {     {
         size = theClassPropNodeArray[node].                  tmp.set(v);
                    theProperty.defaultValue.valueArraySize;  
     }     }
               catch (InvalidDateTimeFormatException&)
     if (theClassPropNodeArray[node].theProperty.defaultValue.flags.isNull)  
     {     {
         return SCMO_NULL_VALUE;                  return false;
     }     }
  
     // calcutate the relativ start address of the value              memcpy(
     Uint64 start =                  &(scmoKBV.data.dateTimeValue),
         (const char*)                  tmp._rep,
                &(theClassPropNodeArray[node].theProperty.defaultValue.value) -                  sizeof(SCMBDateTime));
         (inst.hdr->theClass->cls.base);              scmoKBV.isSet=true;
               break;
     *pvalue = _getSCMBUnion(  
         type,  
         isArray,  
         size,  
         start,  
         (inst.hdr->theClass->cls.base)  
         );  
   
     return SCMO_OK;  
   
 } }
  
 SCMOInstance SCMOInstance::clone() const      case CIMTYPE_REAL32:
 { {
     SCMOInstance newInst;              Real64 x;
     newInst.inst.base = (char*)malloc(this->inst.mem->totalSize);  
     if (newInst.inst.base == NULL )              if (StringConversion::stringToReal64(v, x))
     {     {
         throw PEGASUS_STD(bad_alloc)();                scmoKBV.data.simple.val.r32 = Real32(x);
                 scmoKBV.data.simple.hasValue=true;
                 scmoKBV.isSet=true;
     }     }
               break;
     memcpy( newInst.inst.base,this->inst.base,this->inst.mem->totalSize);  
     // reset the refcounter of this new instance  
     newInst.inst.hdr->refCount = 1;  
     // kepp the ref counter of the class correct !  
     newInst.inst.hdr->theClass = new SCMOClass(*(this->inst.hdr->theClass));  
   
     return newInst;  
 } }
  
 Uint32 SCMOInstance::getPropertyCount() const      case CIMTYPE_REAL64:
 { {
     if (inst.hdr->flags.isFiltered)              Real64 x;
   
               if (StringConversion::stringToReal64(v, x))
     {     {
         return(inst.hdr->filterProperties);                scmoKBV.data.simple.val.r64 = x;
                 scmoKBV.data.simple.hasValue=true;
                 scmoKBV.isSet=true;
     }     }
               break;
     return(inst.hdr->numberProperties);  
 } }
  
 void* SCMOInstance::_getSCMBUnion(      case CIMTYPE_CHAR16:
     CIMType type,  
     Boolean isArray,  
     Uint32 size,  
     Uint64 start,  
     char* base) const  
 {  
   
     SCMBUnion* u = (SCMBUnion*)&(base[start]);  
   
     void* av = NULL;  
   
     if (isArray)  
     {     {
         if (size == 0)              if (kbs.size() == 1)
         {         {
             return NULL;                  scmoKBV.data.simple.val.c16 = kbs[0];
                   scmoKBV.data.simple.hasValue=true;
                   scmoKBV.isSet=true;
         }         }
         av = (void*)&base[u->_arrayValue.start];              break;
     }     }
   
   
     switch (type)  
     {  
     case CIMTYPE_BOOLEAN:     case CIMTYPE_BOOLEAN:
     case CIMTYPE_UINT8:  
     case CIMTYPE_SINT8:  
     case CIMTYPE_UINT16:  
     case CIMTYPE_SINT16:  
     case CIMTYPE_UINT32:  
     case CIMTYPE_SINT32:  
     case CIMTYPE_UINT64:  
     case CIMTYPE_SINT64:  
     case CIMTYPE_REAL32:  
     case CIMTYPE_REAL64:  
     case CIMTYPE_CHAR16:  
     case CIMTYPE_DATETIME:  
         {         {
             if(isArray)              if (String::equalNoCase(kbs,"TRUE"))
             {             {
                 return ((void*)av);                  scmoKBV.data.simple.val.bin = true;
                   scmoKBV.data.simple.hasValue=true;
                   scmoKBV.isSet=true;
             }             }
             else              else if (String::equalNoCase(kbs,"FALSE"))
             {             {
                 return((void*)u);                       scmoKBV.data.simple.val.bin = false;
                        scmoKBV.data.simple.hasValue=true;
                        scmoKBV.isSet=true;
             }             }
             break;             break;
         }         }
  
     case CIMTYPE_STRING:     case CIMTYPE_STRING:
         {         {
             SCMBDataPtr *ptr;              scmoKBV.isSet=true;
             char** tmp=NULL;              // Can cause reallocation !
               _setString(kbs,scmoKBV.data.stringValue,&inst.mem);
             if (isArray)              return true;
           }
       case CIMTYPE_REFERENCE:
             {             {
                 // allocate an array of char* pointers.              if (0 != scmoKBV.data.extRefPtr)
                 tmp = (char**)malloc(size*sizeof(char*));  
                 if (tmp == NULL )  
                 {                 {
                     throw PEGASUS_STD(bad_alloc)();                  delete scmoKBV.data.extRefPtr;
                   scmoKBV.data.extRefPtr = 0;
                   scmoKBV.isSet=false;
                 }                 }
               // TBD: Optimize parsing and SCMOInstance creation.
               CIMObjectPath theCIMObj(kbs);
  
                 // use temporary variables to avoid casting              scmoKBV.data.extRefPtr = new SCMOInstance(theCIMObj);
                 ptr = (SCMBDataPtr*)av;              scmoKBV.isSet=true;
  
                 for(Uint32 i = 0; i < size; i++)              // Was the conversion successful?
               if (scmoKBV.data.extRefPtr->isEmpty())
                 {                 {
                     // resolv relative pointer to absolute pointer                  // N0, delete the SCMOInstance.
                     tmp[i] = (char*)_getCharString(ptr[i],base);                  delete scmoKBV.data.extRefPtr;
                 }                  scmoKBV.data.extRefPtr = 0;
                   scmoKBV.isSet=false;
                 return((void*)tmp);  
             }             }
             else             else
             {             {
                 return((void*)_getCharString(u->_stringValue,base));                  // This function can cause a reallocation !
                   // Pointers can be invalid after the call.
                   _setExtRefIndex(&(scmoKBV.data),&inst.mem);
             }             }
   
   
             break;             break;
         }         }
   
     case CIMTYPE_REFERENCE:  
   
         break;  
   
     case CIMTYPE_OBJECT:     case CIMTYPE_OBJECT:
   
         break;  
   
     case CIMTYPE_INSTANCE:     case CIMTYPE_INSTANCE:
           {
         break;              // From PEP 194: EmbeddedObjects cannot be keys.
               throw TypeMismatchException();
           }
     default:     default:
           {
         PEGASUS_ASSERT(false);         PEGASUS_ASSERT(false);
         break;         break;
     }     }
     return NULL;  
 }  
   
 Uint32 SCMOInstance::getKeyBindingCount()  
 {  
     return(inst.hdr->numberKeyBindings);  
 }  
   
   
 SCMO_RC SCMOInstance::getKeyBindingAt(  
         Uint32 node,  
         const char** pname,  
         CIMKeyBinding::Type& type,  
         const char** pvalue) const  
 {  
     *pname = NULL;  
     *pvalue = NULL;  
   
     if (node >= inst.hdr->numberKeyBindings)  
     {  
         return SCMO_INDEX_OUT_OF_BOUND;  
     }     }
  
     return _getKeyBindingAtNodeIndex(node,pname,type,pvalue);      return scmoKBV.isSet;
 } }
  
 SCMO_RC SCMOInstance::getKeyBinding(  SCMO_RC SCMOInstance::_setKeyBindingFromString(
     const char* name,     const char* name,
     CIMKeyBinding::Type& type,      CIMType type,
     const char** pvalue) const      String cimKeyBinding)
 { {
     SCMO_RC rc;  
     Uint32 node;     Uint32 node;
     const char* pname=NULL;  
  
     rc = inst.hdr->theClass->_getKeyBindingNodeIndex(node,name);      if (0 == name)
     if (rc != SCMO_OK)  
     {     {
         return rc;          return SCMO_INVALID_PARAMETER;
     }  
   
     return _getKeyBindingAtNodeIndex(node,&pname,type,pvalue);  
   
 } }
  
 SCMO_RC SCMOInstance::_getKeyBindingAtNodeIndex(      if (SCMO_OK == inst.hdr->theClass.ptr->_getKeyBindingNodeIndex(node,name))
     Uint32 node,  
     const char** pname,  
     CIMKeyBinding::Type& type,  
     const char** pvalue) const  
 { {
   
     SCMBDataPtr* theInstKeyBindNodeArray =  
         (SCMBDataPtr*)&inst.base[inst.hdr->keyBindingArray.start];  
   
     // create a pointer to keybinding node array of the class.     // create a pointer to keybinding node array of the class.
     Uint64 idx = inst.hdr->theClass->cls.hdr->keyBindingSet.nodeArray.start;          Uint64 idx = inst.hdr->theClass.ptr->cls.hdr->
               keyBindingSet.nodeArray.start;
     SCMBKeyBindingNode* theClassKeyBindNodeArray =     SCMBKeyBindingNode* theClassKeyBindNodeArray =
         (SCMBKeyBindingNode*)&(inst.hdr->theClass->cls.base)[idx];              (SCMBKeyBindingNode*)&((inst.hdr->theClass.ptr->cls.base)[idx]);
  
     type = theClassKeyBindNodeArray[node].type;          // create a pointer to instance keybinding values
           SCMBKeyBindingValue* theInstKeyBindValueArray =
               (SCMBKeyBindingValue*)&(inst.base[inst.hdr->keyBindingArray.start]);
   
           // If the set was not successful, the conversion was not successful
           if ( !_setCimKeyBindingStringToSCMOKeyBindingValue(
                   cimKeyBinding,
                   theClassKeyBindNodeArray[node].type,
                   theInstKeyBindValueArray[node]))
           {
               return SCMO_TYPE_MISSMATCH;
           }
  
     *pname = _getCharString(          return SCMO_OK;
         theClassKeyBindNodeArray[node].name,      }
         inst.hdr->theClass->cls.base);  
  
     // There is no value set in the instance      // the key binig does not belong to the associated class
     // if the relative pointer has no start value.      // add/set it as user defined key binding.
     if (theInstKeyBindNodeArray[node].start==0)      SCMBUserKeyBindingElement* ptrNewElement;
   
       ptrNewElement = _getUserDefinedKeyBinding( name,strlen(name),type);
   
       // Copy the data.
       // If the set was not successful, the conversion was not successful
       if ( !_setCimKeyBindingStringToSCMOKeyBindingValue(
               cimKeyBinding,
               type,
               ptrNewElement->value))
     {     {
         *pvalue = NULL;          return SCMO_TYPE_MISSMATCH;
         return SCMO_NULL_VALUE;  
     }     }
  
     // Set the absolut pointer to the key binding value  
     *pvalue = _getCharString(theInstKeyBindNodeArray[node],inst.base);  
   
     return SCMO_OK;     return SCMO_OK;
   
 } }
  
 SCMO_RC SCMOInstance::setKeyBinding( SCMO_RC SCMOInstance::setKeyBinding(
     const char* name,     const char* name,
     CIMKeyBinding::Type type,      CIMType type,
     const char* pvalue)      const SCMBUnion* keyvalue)
 { {
     SCMO_RC rc;     SCMO_RC rc;
     Uint32 node;     Uint32 node;
  
     rc = inst.hdr->theClass->_getKeyBindingNodeIndex(node,name);      if (0 == name)
     if (rc != SCMO_OK)  
     {     {
         return rc;          return SCMO_INVALID_PARAMETER;
     }     }
  
    // create a pointer to keybinding node array of the class.      if (0 == keyvalue)
     Uint64 idx = inst.hdr->theClass->cls.hdr->keyBindingSet.nodeArray.start;  
     SCMBKeyBindingNode* theClassKeyBindNodeArray =  
         (SCMBKeyBindingNode*)&(inst.hdr->theClass->cls.base)[idx];  
   
     if (theClassKeyBindNodeArray[node].type != type)  
     {     {
         return SCMO_TYPE_MISSMATCH;          return SCMO_INVALID_PARAMETER;
     }     }
  
     SCMBDataPtr* theInstKeyBindNodeArray =      _copyOnWrite();
         (SCMBDataPtr*)&inst.base[inst.hdr->keyBindingArray.start];  
   
     // copy the value including trailing '\0'  
     _setBinary(pvalue,strlen(pvalue)+1,theInstKeyBindNodeArray[node],&inst.mem);  
   
     return SCMO_OK;  
  
       // If keybindings exists and cleared using the clearKeyBindings()
       // method, reset the value to the actual keybindings count exists
       // in the class.
       if (!inst.hdr->numberKeyBindings)
       {
           inst.hdr->numberKeyBindings =
               inst.hdr->theClass.ptr->cls.hdr->keyBindingSet.number;
 } }
  
 void SCMOInstance::setPropertyFilter(const char **propertyList)      rc = inst.hdr->theClass.ptr->_getKeyBindingNodeIndex(node,name);
       if (rc != SCMO_OK)
 { {
     SCMO_RC rc;          // the key bindig does not belong to the associated class
     Uint32 node,i = 0;          // add/set it as user defined key binding.
           SCMBUserKeyBindingElement *theNode;
  
     if (inst.hdr->propertyFilter.start == 0)          theNode = _getUserDefinedKeyBinding( name,strlen(name),type);
   
           // Is this a new node or an existing user key binding?
           if (theNode->value.isSet && (theNode->type != type))
     {     {
         // Allocate the SCMBPropertyFilter              return SCMO_TYPE_MISSMATCH;
         _getFreeSpace(  
             inst.hdr->propertyFilter,  
             sizeof(Uint64)*(((inst.hdr->numberProperties-1)/64)+1),  
             &inst.mem,  
             true);  
  
         // Allocate the SCMBPropertyFilterIndexMap  
         _getFreeSpace(  
             inst.hdr->propertyFilterIndexMap,  
             sizeof(Uint32)*inst.hdr->numberProperties,  
             &inst.mem,  
             true);  
     }     }
     // Get absolut pointer to property filter index map of the instance  
     Uint32* propertyFilterIndexMap =  
         (Uint32*)&(inst.base[inst.hdr->propertyFilterIndexMap.start]);  
   
     // All properties are accepted  
     if (propertyList == NULL)  
     {  
         // Clear filtering:  
         // Switch filtering off.  
         inst.hdr->flags.isFiltered = false;  
   
         // Clear filter index map  
         memset(  
             propertyFilterIndexMap,  
             0,  
             sizeof(Uint32)*inst.hdr->filterProperties);  
  
         //reset number filter properties to all          theNode->value.isSet=true;
         inst.hdr->filterProperties = inst.hdr->numberProperties;  
  
         return;          _setSCMBUnion(
     }              keyvalue,
               type,
               false, // a key binding can never be an array.
               0,
               theNode->value.data);
  
     // Switch filtering on.           return SCMO_OK;
     inst.hdr->flags.isFiltered = true;      }
  
     // intit the filter with the key properties      return setKeyBindingAt(node, type, keyvalue);
     inst.hdr->filterProperties=_initPropFilterWithKeys();  }
  
     // add the properties to the filter.  SCMO_RC SCMOInstance::setKeyBindingAt(
     while (propertyList[i] != NULL)          Uint32 node,
           CIMType type,
           const SCMBUnion* keyvalue)
     {     {
         // the hash index of the property if the property name is found      if (0 == keyvalue)
         rc = inst.hdr->theClass->_getProperyNodeIndex(node,propertyList[i]);  
   
         if (rc == SCMO_OK)  
         {         {
             // The property name was found. Otherwise ignore this property name.          return SCMO_INVALID_PARAMETER;
             // insert the hash index into the filter index map  
             propertyFilterIndexMap[inst.hdr->filterProperties]=node;  
             // increase number of properties in filter.  
             inst.hdr->filterProperties++;  
             // set bit in the property filter  
             _setPropertyInPropertyFilter(node);  
         }  
         // Proceed with the next property name.  
         i++;  
     }     }
  
       // count of class keys + user definded keys
       if (node >= (inst.hdr->numberKeyBindings+
                    inst.hdr->numberUserKeyBindings))
       {
           return SCMO_INDEX_OUT_OF_BOUND;
 } }
  
       _copyOnWrite();
  
 Uint32 SCMOInstance::_initPropFilterWithKeys()      // If keybindings exists and cleared using the clearKeyBindings()
       // method, reset the value to the actual keybindings count exists
       // in the class.
       if (!inst.hdr->numberKeyBindings)
 { {
           inst.hdr->numberKeyBindings =
               inst.hdr->theClass.ptr->cls.hdr->keyBindingSet.number;
       }
  
     // Get absolut pointer to the key property mask of the class.  
     Uint64 idx = inst.hdr->theClass->cls.hdr->keyPropertyMask.start;  
     Uint64* keyMask =(Uint64*)&(inst.hdr->theClass->cls.base)[idx];  
   
     // Get absolut pointer to property filter mask  
     Uint64* propertyFilterMask =  
         (Uint64*)&(inst.base[inst.hdr->propertyFilter.start]);  
  
     // copy the key mask to the property filter mask     // create a pointer to keybinding node array of the class.
     memcpy(      Uint64 idx = inst.hdr->theClass.ptr->cls.hdr->
         propertyFilterMask,          keyBindingSet.nodeArray.start;
         keyMask,      SCMBKeyBindingNode* theClassKeyBindNodeArray =
         sizeof(Uint64)*(((inst.hdr->numberProperties-1)/64)+1));          (SCMBKeyBindingNode*)&((inst.hdr->theClass.ptr->cls.base)[idx]);
  
     // Get absolut pointer to key index list of the class      // is the node a user defined key binding ?
     idx=inst.hdr->theClass->cls.hdr->keyIndexList.start;      if (node >= inst.hdr->numberKeyBindings)
     Uint32* keyIndex = (Uint32*)&(inst.hdr->theClass->cls.base)[idx];      {
           SCMBUserKeyBindingElement* theNode = _getUserDefinedKeyBindingAt(node);
  
     // Get absolut pointer to property filter index map of the instance          // Does the new value for the user defined keybinding match?
     Uint32* propertyFilterIndexMap =          if (theNode->type != type)
         (Uint32*)&(inst.base[inst.hdr->propertyFilterIndexMap.start]);          {
               return SCMO_TYPE_MISSMATCH;
           }
  
     Uint32 noKeys = inst.hdr->theClass->cls.hdr->keyBindingSet.number;          _setSCMBUnion(
     memcpy(propertyFilterIndexMap,keyIndex,sizeof(Uint32)*noKeys);              keyvalue,
               type,
               false, // a key binding can never be an array.
               0,
               theNode->value.data);
  
     // return the number of properties already in the filter index map           return SCMO_OK;
     return noKeys;  
  
 } }
  
 void SCMOInstance::_clearPropertyFilter()      SCMBKeyBindingValue* theInstKeyBindValueArray =
 {          (SCMBKeyBindingValue*)&(inst.base[inst.hdr->keyBindingArray.start]);
     Uint64 *propertyFilter;  
  
     // Calculate the real pointer to the Uint64 array  
     propertyFilter = (Uint64*)&inst.base[inst.hdr->propertyFilter.start];  
  
     // the number of Uint64 in the key mask is :      if (theClassKeyBindNodeArray[node].type == type)
     // Decrease the number of properties by 1      {
     // since the array is starting at index 0!  
     // Divide with the number of bits in a Uint64.          // Has to be set first,
     // e.g. number of Properties = 68          // because reallocaton can take place in _setSCMBUnion()
     // (68 - 1) / 64 = 1 --> The mask consists of 2 Uint64          theInstKeyBindValueArray[node].isSet=true;
  
     memset(propertyFilter,          _setSCMBUnion(
               keyvalue,
               type,
               false, // a key binding can never be an array.
            0,            0,
            sizeof(Uint64)*(((inst.hdr->numberProperties-1)/64)+1));              theInstKeyBindValueArray[node].data);
   
           return SCMO_OK;
  
 } }
 void SCMOInstance::_setPropertyInPropertyFilter(Uint32 i)  
 {  
     Uint64 *propertyFilter;  
  
     // In which Uint64 of key mask is the bit for property i ?      // The type does not match.
     // Divide with the number of bits in a Uint64.      return _setKeyBindingTypeTolerate(
     // 47 / 64 = 0 --> The key bit for property i is in in keyMask[0].          theClassKeyBindNodeArray[node].type,
     Uint32 idx = i/64 ;          type,
           keyvalue,
           theInstKeyBindValueArray[node]);
  
     // Create a filter to set the bit.  }
     // Modulo division with 64. Shift left a bit by the remainder.  
     Uint64 filter = ( (Uint64)1 << (i%64));  
  
     // Calculate the real pointer to the Uint64 array  /**
     propertyFilter = (Uint64*)&(inst.base[inst.hdr->propertyFilter.start]);   * Set a SCMO user defined key binding using the class CIM type tolerating
    * CIM key binding types converted to CIM types by fuction
    *  _CIMTypeFromKeyBindingType().
    *
    * @parm classType The type of the key binding in the class definition
    * @parm setType The type of the key binding to be set.
    * @param keyValue A pointer to the key binding to be set.
    * @param kbValue Out parameter, the SCMO keybinding to be set.
    *
    **/
   SCMO_RC SCMOInstance::_setKeyBindingTypeTolerate(
       CIMType classType,
       CIMType setType,
       const SCMBUnion* keyValue,
       SCMBKeyBindingValue& kbValue)
   {
       if (setType == CIMTYPE_UINT64 )
       {
           switch (classType)
           {
   
           case CIMTYPE_UINT8:
               {
                   kbValue.isSet=true;
                   kbValue.data.simple.hasValue=true;
                   kbValue.data.simple.val.u8=Uint8(keyValue->simple.val.u64);
                   break;
               }
           case CIMTYPE_UINT16:
               {
                   kbValue.isSet=true;
                   kbValue.data.simple.hasValue=true;
                   kbValue.data.simple.val.u16=Uint16(keyValue->simple.val.u64);
                   break;
               }
           case CIMTYPE_UINT32:
               {
                   kbValue.isSet=true;
                   kbValue.data.simple.hasValue=true;
                   kbValue.data.simple.val.u32=Uint32(keyValue->simple.val.u64);
                   break;
               }
           case CIMTYPE_UINT64:
               {
                   kbValue.isSet=true;
                   kbValue.data.simple.hasValue=true;
                   kbValue.data.simple.val.u64=keyValue->simple.val.u64;
                   break;
               }
           default:
               {
                   return SCMO_TYPE_MISSMATCH;
               }
           }
           return SCMO_OK;
  
     propertyFilter[idx] = propertyFilter[idx] | filter ;  
 } }
  
 Boolean SCMOInstance::_isPropertyInFilter(Uint32 i) const      if (setType == CIMTYPE_SINT64)
       {
           switch (classType)
 { {
     Uint64 *propertyFilter;  
  
     // In which Uint64 of key mask is the bit for property i ?          case CIMTYPE_SINT8:
     // Divide with the number of bits in a Uint64.              {
     // e.g. number of Properties = 68                  kbValue.isSet=true;
     // 47 / 64 = 0 --> The key bit for property i is in in keyMask[0].                  kbValue.data.simple.hasValue=true;
     Uint32 idx = i/64 ;                  kbValue.data.simple.val.s8=Sint8(keyValue->simple.val.s64);
                   break;
               }
           case CIMTYPE_SINT16:
               {
                   kbValue.isSet=true;
                   kbValue.data.simple.hasValue=true;
                   kbValue.data.simple.val.s16=Sint16(keyValue->simple.val.s64);
                   break;
               }
           case CIMTYPE_SINT32:
               {
                   kbValue.isSet=true;
                   kbValue.data.simple.hasValue=true;
                   kbValue.data.simple.val.s32=Sint32(keyValue->simple.val.s64);
                   break;
               }
           case CIMTYPE_SINT64:
               {
                   kbValue.isSet=true;
                   kbValue.data.simple.hasValue=true;
                   kbValue.data.simple.val.s64=keyValue->simple.val.s64;
                   break;
               }
           default:
               {
                   return SCMO_TYPE_MISSMATCH;
               }
           }
           return SCMO_OK;
       }
  
     // Create a filter to check if the bit is set:      if (setType == CIMTYPE_REAL64)
     // Modulo division with 64. Shift left a bit by the remainder.      {
     Uint64 filter = ( (Uint64)1 << (i%64));          switch (classType)
           {
           case CIMTYPE_REAL32:
               {
                   kbValue.isSet=true;
                   kbValue.data.simple.hasValue=true;
                   kbValue.data.simple.val.r32=Real32(keyValue->simple.val.r64);
                   break;
               }
           case CIMTYPE_REAL64:
               {
                   kbValue.isSet=true;
                   kbValue.data.simple.hasValue=true;
                   kbValue.data.simple.val.r64=keyValue->simple.val.r64;
                   break;
               }
           default:
               {
                   return SCMO_TYPE_MISSMATCH;
               }
           }
           return SCMO_OK;
       }
       else
       {
           // If type defined in the class and the provided type does not match
           // at this point, no convertaion can be done and the provided type
           // is handlend as type missmatch.
           if (classType != setType)
           {
               return SCMO_TYPE_MISSMATCH;
           }
  
     // Calculate the real pointer to the Uint64 array          switch (classType)
     propertyFilter = (Uint64*)&inst.base[inst.hdr->propertyFilter.start];          {
           case CIMTYPE_DATETIME:
           case CIMTYPE_BOOLEAN:
           case CIMTYPE_UINT64:
           case CIMTYPE_SINT64:
           case CIMTYPE_REAL64:
           case CIMTYPE_STRING:
           case CIMTYPE_REFERENCE:
               {
                   kbValue.isSet=true;
                   _setSCMBUnion(keyValue,classType,false, 0,kbValue.data);
                   return SCMO_OK;
               }
           default:
               {
                   return SCMO_TYPE_MISSMATCH;
               }
           }
       }
  
     // If the bit is set the property is NOT filtered.      return SCMO_TYPE_MISSMATCH;
     // So the result has to be negated!  
     return propertyFilter[idx] & filter ;  
  
 } }
  
   // class SCMODump only in debug builds available
   #ifdef PEGASUS_DEBUG
 /****************************************************************************** /******************************************************************************
  * SCMODump Print and Dump functions  * SCMODump Print and Dump functions
  *****************************************************************************/  *****************************************************************************/
 SCMODump::SCMODump() SCMODump::SCMODump()
 { {
     _out = stdout;      _out = stderr;
     _fileOpen = false;     _fileOpen = false;
  
 #ifdef PEGASUS_OS_ZOS #ifdef PEGASUS_OS_ZOS
Line 2759 
Line 5221 
  
 } }
  
 SCMODump::SCMODump(char* filename)  SCMODump::SCMODump(const char* filename)
 { {
     openFile(filename);     openFile(filename);
 } }
  
 void SCMODump::openFile(char* filename)  void SCMODump::openFile(const char* filename)
 { {
     const char* pegasusHomeDir = getenv("PEGASUS_HOME");     const char* pegasusHomeDir = getenv("PEGASUS_HOME");
  
     if (pegasusHomeDir == NULL)      if (pegasusHomeDir == 0)
     {     {
         pegasusHomeDir = ".";         pegasusHomeDir = ".";
     }     }
Line 2818 
Line 5280 
  
 Boolean SCMODump::compareFile(String master) Boolean SCMODump::compareFile(String master)
 { {
   
     if (!_fileOpen)     if (!_fileOpen)
     {     {
         return false;         return false;
     }     }
   
     closeFile();     closeFile();
  
     return (FileSystem::compareFiles(_filename, master));      ifstream isMaster;
       ifstream isDumpFile;
   
       Open(isDumpFile, _filename);
       Open(isMaster, master);
   
       String aLine;
       String bLine;
   
       while (GetLine(isDumpFile, aLine) && GetLine(isMaster, bLine))
       {
           if (aLine != bLine)
           {
               cout << "|" << aLine << "|" << endl;
               cout << "|" << bLine << "|" << endl;
               isDumpFile.close();
               isMaster.close();
               return false;
           }
       };
       isDumpFile.close();
       isMaster.close();
       return true;
 } }
  
 void SCMODump::dumpSCMOInstance(SCMOInstance& testInst) const  void SCMODump::dumpSCMOInstance(SCMOInstance& testInst, Boolean inclMemHdr)const
 { {
     SCMBInstance_Main* insthdr = testInst.inst.hdr;     SCMBInstance_Main* insthdr = testInst.inst.hdr;
     char* instbase = testInst.inst.base;     char* instbase = testInst.inst.base;
  
     fprintf(_out,"\n\nDump of SCMOInstance\n");      fprintf(_out,"\n\nDump of SCMOInstance\n");
     // The magic number for SCMO class  
     fprintf(_out,"\nheader.magic=%08X",insthdr->header.magic);      if (inclMemHdr)
     // Total size of the instance memory block( # bytes )      {
     fprintf(_out,"\nheader.totalSize=%llu",insthdr->header.totalSize);          _dumpSCMBMgmt_Header(insthdr->header,instbase);
       }
   
     // The reference counter for this c++ class     // The reference counter for this c++ class
     fprintf(_out,"\nrefCount=%i",insthdr->refCount.get());     fprintf(_out,"\nrefCount=%i",insthdr->refCount.get());
     fprintf(_out,"\ntheClass: %p",insthdr->theClass);      fprintf(_out,"\ntheClass: %p",insthdr->theClass.ptr);
     fprintf(_out,"\n\nThe Flags:");     fprintf(_out,"\n\nThe Flags:");
     fprintf(_out,"\n   includeQualifiers: %s",     fprintf(_out,"\n   includeQualifiers: %s",
            (insthdr->flags.includeQualifiers ? "True" : "False"));            (insthdr->flags.includeQualifiers ? "True" : "False"));
     fprintf(_out,"\n   includeClassOrigin: %s",     fprintf(_out,"\n   includeClassOrigin: %s",
            (insthdr->flags.includeClassOrigin ? "True" : "False"));            (insthdr->flags.includeClassOrigin ? "True" : "False"));
     fprintf(_out,"\n   isFiltered: %s",      fprintf(_out,"\n   isClassOnly: %s",
            (insthdr->flags.isFiltered ? "True" : "False"));             (insthdr->flags.isClassOnly ? "True" : "False"));
       fprintf(_out,"\n   isCompromised: %s",
              (insthdr->flags.isCompromised ? "True" : "False"));
       fprintf(_out,"\n   exportSetOnly: %s",
              (insthdr->flags.exportSetOnly ? "True" : "False"));
       fprintf(_out,"\n\ninstNameSpace: \'%s\'",
              NULLSTR(_getCharString(insthdr->instNameSpace,instbase)));
       fprintf(_out,"\n\ninstClassName: \'%s\'",
              NULLSTR(_getCharString(insthdr->instClassName,instbase)));
     fprintf(_out,"\n\nhostName: \'%s\'",     fprintf(_out,"\n\nhostName: \'%s\'",
            NULLSTR(_getCharString(insthdr->hostName,instbase)));            NULLSTR(_getCharString(insthdr->hostName,instbase)));
  
     dumpSCMOInstanceKeyBindings(testInst);     dumpSCMOInstanceKeyBindings(testInst);
  
     dumpSCMOInstancePropertyFilter(testInst);  
   
     dumpInstanceProperties(testInst);     dumpInstanceProperties(testInst);
     fprintf(_out,"\n\n");     fprintf(_out,"\n\n");
  
 } }
  
 void SCMODump::dumpSCMOInstancePropertyFilter(SCMOInstance& testInst) const  void SCMODump::dumpInstanceProperties(
 {      SCMOInstance& testInst,
     SCMBInstance_Main* insthdr = testInst.inst.hdr;      Boolean verbose) const
     char* instbase = testInst.inst.base;  
   
     if (!insthdr->flags.isFiltered)  
     {  
         fprintf(_out,"\n\nNo propterty filter!\n\n");  
         return;  
     }  
   
     fprintf(_out,"\n\nInstance Property Filter :");  
     fprintf(_out,"\n==========================");  
     fprintf(_out,"\n\nNumber of properties in the filter : %u\n"  
         ,insthdr->filterProperties);  
   
     dumpPropertyFilter(testInst);  
   
     dumpPropertyFilterIndexMap(testInst);  
   
 }  
   
 void SCMODump::dumpInstanceProperties(SCMOInstance& testInst) const  
 { {
     SCMBInstance_Main* insthdr = testInst.inst.hdr;     SCMBInstance_Main* insthdr = testInst.inst.hdr;
     char* instbase = testInst.inst.base;     char* instbase = testInst.inst.base;
Line 2899 
Line 5369 
     for (Uint32 i = 0, k = insthdr->numberProperties; i < k; i++)     for (Uint32 i = 0, k = insthdr->numberProperties; i < k; i++)
     {     {
         fprintf(_out,"\n\nInstance property (#%3u) %s\n",i,         fprintf(_out,"\n\nInstance property (#%3u) %s\n",i,
                 NULLSTR(insthdr->theClass->_getPropertyNameAtNode(i)));                  NULLSTR(insthdr->theClass.ptr->_getPropertyNameAtNode(i)));
         if(insthdr->flags.isFiltered && !testInst._isPropertyInFilter(i))  
         {          printSCMOValue(val[i],instbase,verbose);
             fprintf(_out,"\nProperty is filtered out!");  
         }  
         else  
         {  
             printSCMOValue(val[i],instbase);  
         }  
     }     }
  
 } }
  
 void SCMODump::dumpPropertyFilterIndexMap(SCMOInstance& testInst) const  
 {  
  
   void SCMODump::dumpSCMOInstanceKeyBindings(
       SCMOInstance& testInst,
       Boolean verbose) const
   {
     SCMBInstance_Main* insthdr = testInst.inst.hdr;     SCMBInstance_Main* insthdr = testInst.inst.hdr;
     char* instbase = testInst.inst.base;     char* instbase = testInst.inst.base;
  
     if (!insthdr->flags.isFiltered)      // create a pointer to keybinding node array of the class.
     {      Uint64 idx = insthdr->theClass.ptr->cls.hdr->keyBindingSet.nodeArray.start;
         fprintf(_out,"\n\nNo propterty filter!\n\n");      SCMBKeyBindingNode* theClassKeyBindNodeArray =
         return;          (SCMBKeyBindingNode*)&((insthdr->theClass.ptr->cls.base)[idx]);
     }  
   
     fprintf(_out,"\n\nProperty Filter Index Max:");  
     fprintf(_out,"\n==========================\n");  
  
     // Get absolut pointer to key index list of the class      SCMBKeyBindingValue* ptr =
     Uint32* keyIndex =          (SCMBKeyBindingValue*)
         (Uint32*)&(instbase)[insthdr->propertyFilterIndexMap.start];               _resolveDataPtr(insthdr->keyBindingArray,instbase);
  
     Uint32 line,j,i,k = insthdr->filterProperties;      fprintf(_out,"\n\nInstance Key Bindings :");
       fprintf(_out,"\n=======================");
       fprintf(_out,"\n\nNumber of Key Bindings defined in the Class: %u",
               insthdr->numberKeyBindings);
  
     for (j = 0; j < k; j = j + line)      for (Uint32 i = 0, k = insthdr->numberKeyBindings; i < k; i++)
     {     {
         if ((insthdr->filterProperties-j)/16)          if (ptr[i].isSet)
         {         {
             line = 16 ;              fprintf(_out,"\n\nName: '%s'\nType: '%s'",
                   NULLSTR(_getCharString(
                       theClassKeyBindNodeArray[i].name,
                       insthdr->theClass.ptr->cls.base)),
                   cimTypeToString(theClassKeyBindNodeArray[i].type));
               printUnionValue(
                   theClassKeyBindNodeArray[i].type,
                   ptr[i].data,
                   instbase,
                   verbose);
         }         }
         else         else
         {         {
             line = insthdr->filterProperties%16;              fprintf(_out,"\n\nName: '%s': Not Set",
         }                  NULLSTR(_getCharString(
                       theClassKeyBindNodeArray[i].name,
                       insthdr->theClass.ptr->cls.base)));
         fprintf(_out,"Index :");  
         for (i = 0; i < line; i++)  
         {  
             fprintf(_out," %3u",j+i);  
         }  
   
         fprintf(_out,"\nNode  :");  
         for (i = 0; i < line; i++)  
         {  
             fprintf(_out," %3u",keyIndex[j+i]);  
         }         }
   
         fprintf(_out,"\n\n");  
   
     }     }
  
 }      fprintf(_out,"\n\nNumber of User Defined Key Bindings: %u",
               insthdr->numberUserKeyBindings);
  
 void SCMODump::dumpPropertyFilter(SCMOInstance& testInst) const  
 {  
  
     SCMBInstance_Main* insthdr = testInst.inst.hdr;      SCMBUserKeyBindingElement* theUserDefKBElement;
     char* instbase = testInst.inst.base;  
  
     if (!insthdr->flags.isFiltered)      Uint64 start = insthdr->userKeyBindingElement.start;
       while (start != 0)
     {     {
         fprintf(_out,"\n\nNo propterty filter!");          theUserDefKBElement = (SCMBUserKeyBindingElement*)&(instbase[start]);
         return;  
     }  
   
     Uint64 *thePropertyFilter =  
         (Uint64*)&(instbase[insthdr->propertyFilter.start]);  
      Uint32 end, noProperties = insthdr->numberProperties;  
      Uint32 noMasks = (noProperties-1)/64;  
      Uint64 printMask = 1;  
  
      for (Uint32 i = 0; i <= noMasks; i++ )          if (theUserDefKBElement->value.isSet)
      {  
          printMask = 1;  
          if (i < noMasks)  
          {          {
              end = 64;              fprintf(_out,"\n\nName: '%s'\nType: '%s'",
                   NULLSTR(_getCharString(theUserDefKBElement->name,instbase)),
                   cimTypeToString(theUserDefKBElement->type));
               printUnionValue(
                   theUserDefKBElement->type,
                   theUserDefKBElement->value.data,
                   instbase,
                   verbose);
          }          }
          else          else
          {          {
              end = noProperties%64;              fprintf(_out,"\n\n    %s : Not Set",
                   NULLSTR(_getCharString(theUserDefKBElement->name,instbase)));
   
          }          }
           start = theUserDefKBElement->nextElement.start;
       } // for all user def. key bindings.
  
          fprintf(_out,"\npropertyFilter[%02u]= ",i);      fprintf(_out,"\n\n");
  
          for (Uint32 j = 0; j < end; j++)  
          {  
              if (j > 0 && !(j%8))  
              {  
                  fprintf(_out," ");  
              }              }
  
              if (thePropertyFilter[i] & printMask)  void SCMODump::_dumpSCMBMgmt_Header(SCMBMgmt_Header& header,char* base) const
              {              {
                  fprintf(_out,"1");      fprintf(_out,"\nThe Management Header:");
              }      // The magic number
              else      fprintf(_out,"\n   magic=%08X",header.magic);
       // Total size of the memory block( # bytes )
       fprintf(_out,"\n   totalSize=%llu",header.totalSize);
       // Free bytes in the block
       fprintf(_out,"\n   freeBytes=%llu",header.freeBytes);
       // Index to the start of the free space in this SCMB memory block.
       fprintf(_out,"\n   startOfFreeSpace=%llu",header.startOfFreeSpace);
       // Number of external references in this instance.
       fprintf(_out,"\n   numberExtRef=%u",header.numberExtRef);
       // Size of external reference index array;
       fprintf(_out,"\n   sizeExtRefIndexArray=%u",header.sizeExtRefIndexArray);
   
       if (header.numberExtRef > 0)
       {
           fprintf(_out,"\n   extRefIndexArray=[");
           Uint64* extRefIndexArray =
               (Uint64*)&(base[header.extRefIndexArray.start]);
   
           for (Uint32 i = 0; i < header.numberExtRef;)
              {              {
                  fprintf(_out,"0");              fprintf(_out,"%llu",extRefIndexArray[i]);
               i++;
               if (i != header.numberExtRef)
               {
                   fprintf(_out,", ");
              }              }
   
              printMask = printMask << 1;  
          }          }
          fprintf(_out,"\n");          fprintf(_out,"\n");
      }      }
 }      else
   
 void SCMODump::dumpSCMOInstanceKeyBindings(SCMOInstance& testInst) const  
 {  
     SCMBInstance_Main* insthdr = testInst.inst.hdr;  
     char* instbase = testInst.inst.base;  
   
     SCMBDataPtr* ptr =  
         (SCMBDataPtr*)_resolveDataPtr(insthdr->keyBindingArray,instbase);  
   
     fprintf(_out,"\n\nInstance Key Bindings :");  
     fprintf(_out,"\n=======================");  
     fprintf(_out,"\n\nNumber of Key Bindings : %u",insthdr->numberKeyBindings);  
   
     for (Uint32 i = 0, k = insthdr->numberKeyBindings; i < k; i++)  
     {     {
         fprintf(_out,"\n\nNo %u : '%s'",i,             fprintf(_out,"\n   extRefIndexArray=[NO INDEX]\n");
                 NULLSTR(_getCharString(ptr[i],instbase)));  
     }     }
     fprintf(_out,"\n");  
 } }
  
 void SCMODump::dumpSCMOClass(SCMOClass& testCls) const  void SCMODump::dumpSCMOClass(SCMOClass& testCls, Boolean inclMemHdr) const
 { {
     SCMBClass_Main* clshdr = testCls.cls.hdr;     SCMBClass_Main* clshdr = testCls.cls.hdr;
     char* clsbase = testCls.cls.base;     char* clsbase = testCls.cls.base;
  
     fprintf(_out,"\n\nDump of SCMOClass\n");     fprintf(_out,"\n\nDump of SCMOClass\n");
     // The magic number for SCMO class  
     fprintf(_out,"\nheader.magic=%08X",clshdr->header.magic);      if (inclMemHdr)
     // Total size of the instance memory block( # bytes )      {
     fprintf(_out,"\nheader.totalSize=%llu",clshdr->header.totalSize);          _dumpSCMBMgmt_Header(clshdr->header,clsbase);
       }
   
     // The reference counter for this c++ class     // The reference counter for this c++ class
     fprintf(_out,"\nrefCount=%i",clshdr->refCount.get());     fprintf(_out,"\nrefCount=%i",clshdr->refCount.get());
       fprintf(_out,"\n\nThe Flags:");
       fprintf(_out,"\n   isEmpty: %s",
              (clshdr->flags.isEmpty ? "True" : "False"));
     fprintf(_out,"\n\nsuperClassName: \'%s\'",     fprintf(_out,"\n\nsuperClassName: \'%s\'",
            NULLSTR(_getCharString(clshdr->superClassName,clsbase)));            NULLSTR(_getCharString(clshdr->superClassName,clsbase)));
     fprintf(_out,"\nnameSpace: \'%s\'",     fprintf(_out,"\nnameSpace: \'%s\'",
Line 3092 
Line 5555 
  
 void SCMODump::hexDumpSCMOClass(SCMOClass& testCls) const void SCMODump::hexDumpSCMOClass(SCMOClass& testCls) const
 { {
     char* tmp;  
   
     SCMBClass_Main* clshdr = testCls.cls.hdr;     SCMBClass_Main* clshdr = testCls.cls.hdr;
     char* clsbase = testCls.cls.base;     char* clsbase = testCls.cls.base;
  
Line 3123 
Line 5584 
         }         }
         else         else
         {         {
             line = clshdr->propertySet.number%16;              line = clshdr->propertySet.number & 15;
         }         }
  
  
Line 3148 
Line 5609 
 void SCMODump::dumpKeyBindingSet(SCMOClass& testCls) const void SCMODump::dumpKeyBindingSet(SCMOClass& testCls) const
 { {
     SCMBClass_Main* clshdr = testCls.cls.hdr;     SCMBClass_Main* clshdr = testCls.cls.hdr;
     char* clsbase = testCls.cls.base;  
  
     fprintf(_out,"\n\nKey Binding Set:");     fprintf(_out,"\n\nKey Binding Set:");
     fprintf(_out,"\n=================\n");     fprintf(_out,"\n=================\n");
Line 3191 
Line 5651 
  
         fprintf(_out,"\nHash Tag %3u Hash Index %3u",         fprintf(_out,"\nHash Tag %3u Hash Index %3u",
                nodeArray[i].nameHashTag,                nodeArray[i].nameHashTag,
                nodeArray[i].nameHashTag%PEGASUS_KEYBINDIG_SCMB_HASHSIZE);                 nodeArray[i].nameHashTag & (PEGASUS_KEYBINDIG_SCMB_HASHSIZE -1));
  
         fprintf(_out,"\nKey binding type: %s",          fprintf(_out,"\nType: %s",cimTypeToString(nodeArray[i].type));
                XmlWriter::keyBindingTypeToString(nodeArray[i].type).str);  
  
     }     }
  
Line 3203 
Line 5662 
 void SCMODump::dumpClassProperties(SCMOClass& testCls) const void SCMODump::dumpClassProperties(SCMOClass& testCls) const
 { {
     SCMBClass_Main* clshdr = testCls.cls.hdr;     SCMBClass_Main* clshdr = testCls.cls.hdr;
     char* clsbase = testCls.cls.base;  
  
     fprintf(_out,"\n\nClass Properties:");     fprintf(_out,"\n\nClass Properties:");
     fprintf(_out,"\n=================\n");     fprintf(_out,"\n=================\n");
Line 3253 
Line 5711 
  
     fprintf(_out,"\nHash Tag %3u Hash Index %3u",     fprintf(_out,"\nHash Tag %3u Hash Index %3u",
            prop.nameHashTag,            prop.nameHashTag,
            prop.nameHashTag%PEGASUS_PROPERTY_SCMB_HASHSIZE);             prop.nameHashTag & (PEGASUS_PROPERTY_SCMB_HASHSIZE -1));
     fprintf(_out,"\nPropagated: %s isKey: %s",     fprintf(_out,"\nPropagated: %s isKey: %s",
            (prop.flags.propagated?"TRUE":"FALSE"),            (prop.flags.propagated?"TRUE":"FALSE"),
            (prop.flags.isKey?"TRUE":"FALSE")            (prop.flags.isKey?"TRUE":"FALSE")
Line 3287 
Line 5745 
         }         }
         else         else
         {         {
             line = size%16;              line = size & 15;
         }         }
  
  
Line 3338 
Line 5796 
      else      else
      {      {
          fprintf(_out,"\n\nQualifier DMTF defined name: \'%s\'",          fprintf(_out,"\n\nQualifier DMTF defined name: \'%s\'",
                 _qualifierNameStrLit[theQualifier.name].str);                  SCMOClass::qualifierNameStrLit(theQualifier.name).str);
      }      }
  
      fprintf(_out,"\nPropagated : %s",      fprintf(_out,"\nPropagated : %s",
Line 3352 
Line 5810 
  
 void SCMODump::printSCMOValue( void SCMODump::printSCMOValue(
     const SCMBValue& theValue,     const SCMBValue& theValue,
     char* base) const      char* base,
       Boolean verbose) const
 { {
    fprintf(_out,"\nValueType : %s",cimTypeToString(theValue.valueType));    fprintf(_out,"\nValueType : %s",cimTypeToString(theValue.valueType));
    fprintf(_out,"\nValue was set by the provider: %s",     fprintf(_out,"\nValue was set: %s",
        (theValue.flags.isSet ? "True" : "False"));        (theValue.flags.isSet ? "True" : "False"));
    if (theValue.flags.isNull)    if (theValue.flags.isNull)
    {    {
Line 3364 
Line 5823 
    }    }
    if (theValue.flags.isArray)    if (theValue.flags.isArray)
    {    {
        fprintf(_out,         fprintf(
              _out,
                "\nThe value is an Array of size: %u",                "\nThe value is an Array of size: %u",
                theValue.valueArraySize);                theValue.valueArraySize);
        fprintf(_out,"\nThe values are: '%s'",         printArrayValue(
               (const char*)printArrayValue(  
                   theValue.valueType,                   theValue.valueType,
                   theValue.valueArraySize,                   theValue.valueArraySize,
                   theValue.value,                   theValue.value,
                   base).getCString());             base,
              verbose);
    }    }
    else    else
    {    {
       fprintf(_out,"\nThe Value is: '%s'",         printUnionValue(theValue.valueType,theValue.value,base,verbose);
           (const char*)  
              printUnionValue(theValue.valueType,theValue.value,base)  
              .getCString());  
    }    }
  
    return;    return;
Line 3406 
Line 5863 
          }          }
          else          else
          {          {
              end = noProperties%64;               end = noProperties & 63;
          }          }
  
          fprintf(_out,"\nkeyPropertyMask[%02u]= ",i);          fprintf(_out,"\nkeyPropertyMask[%02u]= ",i);
  
          for (Uint32 j = 0; j < end; j++)          for (Uint32 j = 0; j < end; j++)
          {          {
              if (j > 0 && !(j%8))               if (j > 0 && !(j & 7))
              {              {
                  fprintf(_out," ");                  fprintf(_out," ");
              }              }
Line 3433 
Line 5890 
      }      }
 } }
  
 void SCMODump::_hexDump(char* buffer,int length) const  void SCMODump::_hexDump(char* buffer,Uint64 length) const
 { {
  
     unsigned char printLine[3][80];     unsigned char printLine[3][80];
Line 3441 
Line 5898 
     int len;     int len;
     unsigned char item;     unsigned char item;
  
     for (int i = 0; i < length;i=i+1)      for (Uint64 i = 0; i < length;i=i+1)
     {     {
         p = i%80;          p = (int)i%80;
  
         if ((p == 0 && i > 0) || i == length-1 )         if ((p == 0 && i > 0) || i == length-1 )
         {         {
Line 3484 
Line 5941 
         }         }
  
         printLine[1][p] = item/16;         printLine[1][p] = item/16;
         printLine[2][p] = item%16;          printLine[2][p] = item & 15;
  
     }     }
 } }
  
 String SCMODump::printArrayValue(  void SCMODump::printArrayValue(
     CIMType type,     CIMType type,
     Uint32 size,     Uint32 size,
     SCMBUnion u,     SCMBUnion u,
     char* base) const      char* base,
       Boolean verbose) const
 { {
     Buffer out;     Buffer out;
  
       SCMBUnion* p;
       p = (SCMBUnion*)&(base[u.arrayValue.start]);
   
     switch (type)     switch (type)
     {     {
     case CIMTYPE_BOOLEAN:     case CIMTYPE_BOOLEAN:
         {         {
             Boolean* p=(Boolean*)&(base[u._arrayValue.start]);  
             for (Uint32 i = 0; i < size; i++)             for (Uint32 i = 0; i < size; i++)
             {             {
                 _toString(out,p[i]);                  out.append('\'');
                 out.append(' ');                  _toString(out,p[i].simple.val.bin);
                   out << STRLIT("\'(hasValue=");
                   out << (p[i].simple.hasValue ?
                             STRLIT("TRUE)"):
                             STRLIT("FALSE)"));
                   out.append(';');
             }             }
               fprintf(_out,"\nThe values are: %s",out.getData());
             break;             break;
         }         }
  
     case CIMTYPE_UINT8:     case CIMTYPE_UINT8:
         {         {
             Uint8* p=(Uint8*)&(base[u._arrayValue.start]);              for (Uint32 i = 0; i < size; i++)
             _toString(out,p,size);              {
                   out.append('\'');
                   _toString(out,p[i].simple.val.u8);
                   out << STRLIT("\'(hasValue=");
                   out << (p[i].simple.hasValue ?
                             STRLIT("TRUE)"):
                             STRLIT("FALSE)"));
                   out.append(';');
               }
               fprintf(_out,"\nThe values are: %s",out.getData());
             break;             break;
         }         }
  
     case CIMTYPE_SINT8:     case CIMTYPE_SINT8:
         {         {
             Sint8* p=(Sint8*)&(base[u._arrayValue.start]);              for (Uint32 i = 0; i < size; i++)
               {
                   out.append('\'');
                   _toString(out,p[i].simple.val.s8);
                   out << STRLIT("\'(hasValue=");
                   out << (p[i].simple.hasValue ?
                             STRLIT("TRUE)"):
                             STRLIT("FALSE)"));
                   out.append(';');
               }
               fprintf(_out,"\nThe values are: %s",out.getData());
             break;             break;
         }         }
  
     case CIMTYPE_UINT16:     case CIMTYPE_UINT16:
         {         {
             Uint16* p=(Uint16*)&(base[u._arrayValue.start]);              for (Uint32 i = 0; i < size; i++)
             _toString(out,p,size);              {
                   out.append('\'');
                   _toString(out,p[i].simple.val.u16);
                   out << STRLIT("\'(hasValue=");
                   out << (p[i].simple.hasValue ?
                             STRLIT("TRUE)"):
                             STRLIT("FALSE)"));
                   out.append(';');
               }
               fprintf(_out,"\nThe values are: %s",out.getData());
             break;             break;
         }         }
  
     case CIMTYPE_SINT16:     case CIMTYPE_SINT16:
         {         {
             Sint16* p=(Sint16*)&(base[u._arrayValue.start]);              for (Uint32 i = 0; i < size; i++)
             _toString(out,p,size);              {
                   out.append('\'');
                   _toString(out,p[i].simple.val.s16);
                   out << STRLIT("\'(hasValue=");
                   out << (p[i].simple.hasValue ?
                             STRLIT("TRUE)"):
                             STRLIT("FALSE)"));
                   out.append(';');
               }
               fprintf(_out,"\nThe values are: %s",out.getData());
             break;             break;
         }         }
  
     case CIMTYPE_UINT32:     case CIMTYPE_UINT32:
         {         {
             Uint32* p=(Uint32*)&(base[u._arrayValue.start]);              for (Uint32 i = 0; i < size; i++)
             _toString(out,p,size);              {
                   out.append('\'');
                   _toString(out,p[i].simple.val.u32);
                   out << STRLIT("\'(hasValue=");
                   out << (p[i].simple.hasValue ?
                             STRLIT("TRUE)"):
                             STRLIT("FALSE)"));
                   out.append(';');
               }
               fprintf(_out,"\nThe values are: %s",out.getData());
             break;             break;
         }         }
  
     case CIMTYPE_SINT32:     case CIMTYPE_SINT32:
         {         {
             Sint32* p=(Sint32*)&(base[u._arrayValue.start]);              for (Uint32 i = 0; i < size; i++)
             _toString(out,p,size);              {
                   out.append('\'');
                   _toString(out,p[i].simple.val.s32);
                   out << STRLIT("\'(hasValue=");
                   out << (p[i].simple.hasValue ?
                             STRLIT("TRUE)"):
                             STRLIT("FALSE)"));
                   out.append(';');
               }
               fprintf(_out,"\nThe values are: %s",out.getData());
             break;             break;
         }         }
  
     case CIMTYPE_UINT64:     case CIMTYPE_UINT64:
         {         {
             Uint64* p=(Uint64*)&(base[u._arrayValue.start]);              for (Uint32 i = 0; i < size; i++)
             _toString(out,p,size);              {
                   out.append('\'');
                   _toString(out,p[i].simple.val.u64);
                   out << STRLIT("\'(hasValue=");
                   out << (p[i].simple.hasValue ?
                             STRLIT("TRUE)"):
                             STRLIT("FALSE)"));
                   out.append(';');
               }
               fprintf(_out,"\nThe values are: %s",out.getData());
             break;             break;
         }         }
  
     case CIMTYPE_SINT64:     case CIMTYPE_SINT64:
         {         {
             Sint64* p=(Sint64*)&(base[u._arrayValue.start]);              for (Uint32 i = 0; i < size; i++)
             _toString(out,p,size);              {
                   out.append('\'');
                   _toString(out,p[i].simple.val.s64);
                   out << STRLIT("\'(hasValue=");
                   out << (p[i].simple.hasValue ?
                             STRLIT("TRUE)"):
                             STRLIT("FALSE)"));
                   out.append(';');
               }
               fprintf(_out,"\nThe values are: %s",out.getData());
             break;             break;
         }         }
  
     case CIMTYPE_REAL32:     case CIMTYPE_REAL32:
         {         {
             Real32* p=(Real32*)&(base[u._arrayValue.start]);              for (Uint32 i = 0; i < size; i++)
             _toString(out,p,size);              {
                   out.append('\'');
                   _toString(out,p[i].simple.val.r32);
                   out << STRLIT("\'(hasValue=");
                   out << (p[i].simple.hasValue ?
                             STRLIT("TRUE)"):
                             STRLIT("FALSE)"));
                   out.append(';');
               }
               fprintf(_out,"\nThe values are: %s",out.getData());
             break;             break;
         }         }
  
     case CIMTYPE_REAL64:     case CIMTYPE_REAL64:
         {         {
             Real64* p=(Real64*)&(base[u._arrayValue.start]);              for (Uint32 i = 0; i < size; i++)
             _toString(out,p,size);              {
                   out.append('\'');
                   _toString(out,p[i].simple.val.r64);
                   out << STRLIT("\'(hasValue=");
                   out << (p[i].simple.hasValue ?
                             STRLIT("TRUE)"):
                             STRLIT("FALSE)"));
                   out.append(';');
               }
               fprintf(_out,"\nThe values are: %s",out.getData());
             break;             break;
         }         }
  
     case CIMTYPE_CHAR16:     case CIMTYPE_CHAR16:
         {         {
             Char16* p=(Char16*)&(base[u._arrayValue.start]);              for (Uint32 i = 0; i < size; i++)
             _toString(out,p,size);              {
                   out.append('\'');
                   _toString(out,p[i].simple.val.c16);
                   out << STRLIT("\'(hasValue=");
                   out << (p[i].simple.hasValue ?
                             STRLIT("TRUE)"):
                             STRLIT("FALSE)"));
                   out.append(';');
               }
               fprintf(_out,"\nThe values are: %s",out.getData());
             break;             break;
         }         }
  
     case CIMTYPE_STRING:     case CIMTYPE_STRING:
         {         {
             SCMBDataPtr* p = (SCMBDataPtr*)&(base[u._arrayValue.start]);  
             for (Uint32 i = 0; i < size; i++)             for (Uint32 i = 0; i < size; i++)
             {             {
                 out.append((const char*)_getCharString(p[i],base),                  if ( 0 != p[i].stringValue.size)
                            p[i].length-1);                  {
                 out.append(' ');                      out.append('\'');
                       out.append(
                           (const char*)_getCharString(p[i].stringValue,base),
                           p[i].stringValue.size-1);
                       out.append('\'');
                   }
                   else
                   {
                     out << STRLIT("NULL;");
             }             }
                   out.append(';');
               }
               fprintf(_out,"\nThe values are: %s",out.getData());
             break;             break;
         }         }
  
     case CIMTYPE_DATETIME:     case CIMTYPE_DATETIME:
         {         {
             SCMBDateTime* p = (SCMBDateTime*)&(base[u._arrayValue.start]);  
             CIMDateTime x;             CIMDateTime x;
             for (Uint32 i = 0; i < size; i++)             for (Uint32 i = 0; i < size; i++)
             {             {
                 memcpy(x._rep,&(p[i]),sizeof(SCMBDateTime));                  memcpy(x._rep,&(p[i].dateTimeValue),sizeof(SCMBDateTime));
                 _toString(out,x);                 _toString(out,x);
                 out.append(' ');                 out.append(' ');
             }             }
               fprintf(_out,"\nThe values are: %s",out.getData());
             break;             break;
         }         }
  
     case CIMTYPE_REFERENCE:     case CIMTYPE_REFERENCE:
       case CIMTYPE_OBJECT:
       case CIMTYPE_INSTANCE:
         {         {
             break;              if (verbose)
               {
                   for (Uint32 i = 0; i < size; i++)
                   {
                       fprintf(_out,"\n-----------> "
                                     "Start of embedded external reference [%d]"
                                     " <-----------\n\n",i);
                       dumpSCMOInstance(*(p[i].extRefPtr));
                       fprintf(_out,"\n-----------> "
                                     "End of embedded external reference [%d]"
                                     " <-----------\n\n",i);
         }         }
  
     case CIMTYPE_OBJECT:              } else
         {         {
             break;                  fprintf(_out,"\nThe values are: ");
         }  
  
     case CIMTYPE_INSTANCE:                  for (Uint32 i = 0; i < size; i++)
         {         {
                       fprintf(
                           _out,
                           "Pointer to external Reference[%d] : \'%p\';",
                           i,p[i].extRefPtr);
                   }
               }
   
             break;             break;
   
         }         }
     default:     default:
         {         {
             PEGASUS_ASSERT(0);              PEGASUS_ASSERT(false);
               break;
         }         }
     }     }
  
     return out.getData();      return;
 } }
  
 String SCMODump::printUnionValue(  void SCMODump::printUnionValue(
     CIMType type,     CIMType type,
     SCMBUnion u,     SCMBUnion u,
     char* base) const      char* base,
       Boolean verbose) const
 { {
  
     Buffer out;     Buffer out;
Line 3647 
Line 6243 
     {     {
     case CIMTYPE_BOOLEAN:     case CIMTYPE_BOOLEAN:
         {         {
             _toString(out,u._booleanValue);              _toString(out,u.simple.val.bin);
               fprintf(_out,"\nThe Value is: '%s'",out.getData());
             break;             break;
         }         }
  
     case CIMTYPE_UINT8:     case CIMTYPE_UINT8:
         {         {
             _toString(out,u._uint8Value);              _toString(out,u.simple.val.u8);
               fprintf(_out,"\nThe Value is: '%s'",out.getData());
             break;             break;
         }         }
  
     case CIMTYPE_SINT8:     case CIMTYPE_SINT8:
         {         {
             _toString(out,u._sint8Value);              _toString(out,u.simple.val.s8);
               fprintf(_out,"\nThe Value is: '%s'",out.getData());
             break;             break;
         }         }
  
     case CIMTYPE_UINT16:     case CIMTYPE_UINT16:
         {         {
             _toString(out,(Uint32)u._uint16Value);              _toString(out,(Uint32)u.simple.val.u16);
               fprintf(_out,"\nThe Value is: '%s'",out.getData());
             break;             break;
         }         }
  
     case CIMTYPE_SINT16:     case CIMTYPE_SINT16:
         {         {
             _toString(out,u._sint16Value);              _toString(out,u.simple.val.s16);
               fprintf(_out,"\nThe Value is: '%s'",out.getData());
             break;             break;
         }         }
  
     case CIMTYPE_UINT32:     case CIMTYPE_UINT32:
         {         {
             _toString(out,u._uint32Value);              _toString(out,u.simple.val.u32);
               fprintf(_out,"\nThe Value is: '%s'",out.getData());
             break;             break;
         }         }
  
     case CIMTYPE_SINT32:     case CIMTYPE_SINT32:
         {         {
             _toString(out,u._sint32Value);              _toString(out,u.simple.val.s32);
               fprintf(_out,"\nThe Value is: '%s'",out.getData());
             break;             break;
         }         }
  
     case CIMTYPE_UINT64:     case CIMTYPE_UINT64:
         {         {
             _toString(out,u._uint64Value);              _toString(out,u.simple.val.u64);
               fprintf(_out,"\nThe Value is: '%s'",out.getData());
             break;             break;
         }         }
  
     case CIMTYPE_SINT64:     case CIMTYPE_SINT64:
         {         {
             _toString(out,u._sint64Value);              _toString(out,u.simple.val.s64);
               fprintf(_out,"\nThe Value is: '%s'",out.getData());
             break;             break;
         }         }
  
     case CIMTYPE_REAL32:     case CIMTYPE_REAL32:
         {         {
             _toString(out,u._real32Value);              _toString(out,u.simple.val.r32);
               fprintf(_out,"\nThe Value is: '%s'",out.getData());
             break;             break;
         }         }
  
     case CIMTYPE_REAL64:     case CIMTYPE_REAL64:
         {         {
             _toString(out,u._real32Value);              _toString(out,u.simple.val.r32);
               fprintf(_out,"\nThe Value is: '%s'",out.getData());
             break;             break;
         }         }
  
     case CIMTYPE_CHAR16:     case CIMTYPE_CHAR16:
         {         {
             _toString(out,u._char16Value);              _toString(out,u.simple.val.c16);
               fprintf(_out,"\nThe Value is: '%s'",out.getData());
             break;             break;
         }         }
  
     case CIMTYPE_STRING:     case CIMTYPE_STRING:
         {         {
             out.append((const char*)_getCharString(u._stringValue,base),              if ( 0 != u.stringValue.size)
                        u._stringValue.length-1);              {
                   out.append((const char*)_getCharString(u.stringValue,base),
                              u.stringValue.size-1);
               }
               fprintf(_out,"\nThe Value is: '%s'",out.getData());
             break;             break;
         }         }
  
     case CIMTYPE_DATETIME:     case CIMTYPE_DATETIME:
         {         {
             CIMDateTime x;             CIMDateTime x;
             memcpy(x._rep,&(u._dateTimeValue),sizeof(SCMBDateTime));              memcpy(x._rep,&(u.dateTimeValue),sizeof(SCMBDateTime));
             _toString(out,x);             _toString(out,x);
               fprintf(_out,"\nThe Value is: '%s'",out.getData());
             break;             break;
         }         }
  
     case CIMTYPE_REFERENCE:     case CIMTYPE_REFERENCE:
         {  
             break;  
         }  
   
     case CIMTYPE_OBJECT:     case CIMTYPE_OBJECT:
       case CIMTYPE_INSTANCE:
         {         {
             break;              if (verbose)
               {
                   fprintf(_out,"\n-----------> "
                                 "Start of embedded external reference"
                                 " <-----------\n\n");
                   dumpSCMOInstance(*u.extRefPtr);
                   fprintf(_out,"\n-----------> "
                                "End of embedded external reference"
                                " <-----------\n\n");
               } else
               {
                   fprintf(
                       _out,
                       "Pointer to external Reference : \'%p\'",
                       u.extRefPtr);
         }         }
  
     case CIMTYPE_INSTANCE:  
         {  
             break;             break;
         }         }
     default:     default:
         {         {
             PEGASUS_ASSERT(0);              PEGASUS_ASSERT(false);
               break;
         }         }
     }     }
  
   return out.getData();    return;
 } }
   #endif // PEGASUS_DEBUG (class SCMODump only in debug builds available)
  
  
 /***************************************************************************** /*****************************************************************************
  * The constant functions  * The constant functions
  *****************************************************************************/  *****************************************************************************/
  
 static const void* _resolveDataPtr(  #ifdef PEGASUS_HAS_ICU
     const SCMBDataPtr& ptr,  Uint32 _utf8ICUncasecmp(
     char* base)      const char* a,
       const char* b,
       Uint32 len)
 { {
     return ((ptr.start==(Uint64)0 ? NULL : (void*)&(base[ptr.start])));      UErrorCode errorCode=U_ZERO_ERROR;
 }  
  
 PEGASUS_COMMON_LINKAGE const char* _getCharString(      Uint32 rc, a16len,b16len,utf16BufLen;
     const SCMBDataPtr& ptr,      utf16BufLen = (len*sizeof(UChar))+2;
     char* base)  
 {  
     return ((ptr.start==(Uint64)0 ? NULL : &(base[ptr.start])));  
 }  
  
       UChar* a_UTF16 = (UChar*)malloc(utf16BufLen);
       UChar* b_UTF16 = (UChar*)malloc(utf16BufLen);
  
 static Uint32 _generateSCMOStringTag(      UConverter *conv = ucnv_open(0, &errorCode);
     const SCMBDataPtr& ptr,      if(U_FAILURE(errorCode))
     char* base)      {
 {          free(a_UTF16);
     // The lenght of a SCMBDataPtr to a UTF8 string includs the trailing '\0'.          free(b_UTF16);
     return _generateStringTag(_getCharString(ptr,base),ptr.length-1);          String message("SCMO::_utf8ICUncasecmp() ICUError: ");
           message.append(u_errorName(errorCode));
           message.append(" Can not open ICU default converter!");
           throw CIMException(CIM_ERR_FAILED,message );
 } }
  
 static Uint32 _generateStringTag(const char* str, Uint32 len)      a16len = ucnv_toUChars(conv,a_UTF16,utf16BufLen,a,len,&errorCode);
 {  
     if (len == 0)  
     {  
         return 0;  
     }  
     return  
         (Uint32(CharSet::toUpperHash(str[0]) << 1) |  
         Uint32(CharSet::toUpperHash(str[len-1])));  
 }  
  
 static CIMKeyBinding::Type _cimTypeToKeyBindType(CIMType cimType)      if(U_FAILURE(errorCode))
 {  
     switch (cimType)  
     {     {
     case CIMTYPE_BOOLEAN:          free(a_UTF16);
         return(CIMKeyBinding::BOOLEAN);          free(b_UTF16);
         break;          ucnv_close(conv);
     case CIMTYPE_CHAR16:          String message("SCMO::_utf8ICUncasecmp() ICUError: ");
     case CIMTYPE_STRING:          message.append(u_errorName(errorCode));
     case CIMTYPE_DATETIME:          message.append(" Can not convert string a:'");
         return(CIMKeyBinding::STRING);          message.append(String(a,len));
         break;          message.append('\'');
     case CIMTYPE_REFERENCE:          throw CIMException(CIM_ERR_FAILED,message );
         return(CIMKeyBinding::REFERENCE);  
         break;  
     case CIMTYPE_OBJECT:  
     case CIMTYPE_INSTANCE:  
         // From PEP 194: EmbeddedObjects cannot be keys.  
         throw TypeMismatchException();  
         break;  
     default:  
         return(CIMKeyBinding::NUMERIC);  
         break;  
     }  
 } }
  
 static Boolean _equalUTF8Strings(      b16len = ucnv_toUChars(conv,b_UTF16,utf16BufLen,b,len,&errorCode);
     const SCMBDataPtr& ptr_a,  
     char* base,  
     const char* name,  
     Uint32 len)  
  
       if(U_FAILURE(errorCode))
 { {
     // size without trailing '\0' !!          free(a_UTF16);
     if (ptr_a.length-1 != len)          free(b_UTF16);
     {          ucnv_close(conv);
         return false;          String message("SCMO::_utf8ICUncasecmp() ICUError: ");
     }          message.append(u_errorName(errorCode));
           message.append(" Can not convert string b:'");
     const char* a = (const char*)_getCharString(ptr_a,base);          message.append(String(b,len));
           message.append('\'');
     // ToDo: Here an UTF8 complinet comparison should take place          throw CIMException(CIM_ERR_FAILED,message );
     return ( strncmp(a,name,len )== 0 );  
   
 } }
  
 static Boolean _equalNoCaseUTF8Strings(      rc = u_strCaseCompare(
     const SCMBDataPtr& ptr_a,          a_UTF16,a16len,
     char* base,          b_UTF16,b16len,
     const char* name,          U_FOLD_CASE_DEFAULT,
     Uint32 len)          &errorCode);
   
 {      if(U_FAILURE(errorCode))
     // size without trailing '\0' !!      {
     if (ptr_a.length-1 != len)          free(a_UTF16);
     {          free(b_UTF16);
         return false;          ucnv_close(conv);
           String message("SCMO::_utf8ICUncasecmp() ICUError: ");
           message.append(u_errorName(errorCode));
           message.append(" Can not compare string a:'");
           message.append(String(a,len));
           message.append("' with b: '");
           message.append(String(b,len));
           message.append('\'');
           throw CIMException(CIM_ERR_FAILED,message );
     }     }
  
     const char* a = (const char*)_getCharString(ptr_a,base);      free(a_UTF16);
       free(b_UTF16);
     // ToDo: Here an UTF8 complinet comparison should take place      ucnv_close(conv);
     return ( strncasecmp(a,name,len )== 0 );  
  
       return(rc);
 } }
   #endif
  
 /** /**
  * This function calcutates a free memory slot in the single chunk memory block.  * This function calcutates a free memory slot in the single chunk memory block.
Line 3874 
Line 6481 
  *            e.g. &cls.mem  *            e.g. &cls.mem
  * @return The relaive index of the free memory slot.  * @return The relaive index of the free memory slot.
  */  */
   Uint64 _getFreeSpace(
 static Uint64 _getFreeSpace(  
     SCMBDataPtr& ptr,     SCMBDataPtr& ptr,
     Uint64 size,      Uint32 size,
     SCMBMgmt_Header** pmem,      SCMBMgmt_Header** pmem)
     Boolean clear)  
 { {
     Uint64 oldSize, start;     Uint64 oldSize, start;
       Uint64 alignedStart, reqAlignSize;
  
     if (size == 0)     if (size == 0)
     {     {
         ptr.start = 0;         ptr.start = 0;
         ptr.length = 0;          ptr.size = 0;
         return 0;         return 0;
     }     }
  
     // The SCMBDataPtr has to be set before any reallocation.     // The SCMBDataPtr has to be set before any reallocation.
     start = (*pmem)->startOfFreeSpace;     start = (*pmem)->startOfFreeSpace;
     ptr.start = start;  
     ptr.length = size;  
  
     while ((*pmem)->freeBytes < size)      // Need to align the start of freespace to 8 byte
       // boundaries to avoid alignment issues on some architectures
       // Round up to nearest multiple of 8
       alignedStart = (start + 7) & ~7;
       // due to the alignment, a little more room is needed in the SCMB
       reqAlignSize = (size + alignedStart - start);
   
       ptr.start = alignedStart;
       ptr.size = size;
       // add 8 bytes of size for later alignment on the next pointer
       while ((*pmem)->freeBytes < reqAlignSize)
     {     {
         // save old size of buffer         // save old size of buffer
         oldSize = (*pmem)->totalSize;         oldSize = (*pmem)->totalSize;
         // reallocate the buffer, double the space !         // reallocate the buffer, double the space !
         // This is a working approach until a better algorithm is found.         // This is a working approach until a better algorithm is found.
         (*pmem) = (SCMBMgmt_Header*)realloc((*pmem),oldSize*2);          void* newBlockPtr = realloc((*pmem),(size_t)oldSize*2);
         if ((*pmem) == NULL)          if ((newBlockPtr) == 0)
         {         {
             // Not enough memory!             // Not enough memory!
             throw PEGASUS_STD(bad_alloc)();             throw PEGASUS_STD(bad_alloc)();
         }         }
           (*pmem) = (SCMBMgmt_Header*)newBlockPtr;
         // increase the total size and free space         // increase the total size and free space
         (*pmem)->freeBytes= (*pmem)->freeBytes + oldSize;          (*pmem)->freeBytes+=oldSize;
         (*pmem)->totalSize= (*pmem)->totalSize + oldSize;          (*pmem)->totalSize+=oldSize;
     }     }
  
     (*pmem)->freeBytes = (*pmem)->freeBytes - size;      (*pmem)->freeBytes -= reqAlignSize;
     (*pmem)->startOfFreeSpace = (*pmem)->startOfFreeSpace + size;      (*pmem)->startOfFreeSpace = alignedStart + size;
  
     if (clear)      // Init memory from unaligned start up to the size required with alignment
     {      // to zero.
         // If requested, set memory to 0.      memset(&((char*)(*pmem))[start],0,(size_t)reqAlignSize);
         memset(&((char*)(*pmem))[start],0,size);      PEGASUS_DEBUG_ASSERT(
     }          ((*pmem)->freeBytes+(*pmem)->startOfFreeSpace) == (*pmem)->totalSize);
     return start;  
       return alignedStart;
 } }
  
 static void _setString(  void _setString(
     const String& theString,     const String& theString,
     SCMBDataPtr& ptr,     SCMBDataPtr& ptr,
     SCMBMgmt_Header** pmem)     SCMBMgmt_Header** pmem)
Line 3934 
Line 6550 
     // Get the real size of the UTF8 sting + \0.     // Get the real size of the UTF8 sting + \0.
     // It maybe greater then the length in the String due to     // It maybe greater then the length in the String due to
     // 4 byte encoding of non ASCII chars.     // 4 byte encoding of non ASCII chars.
     Uint64 start,length = strlen((const char*)theCString)+1;      Uint64 start;
       Uint32 length = strlen((const char*)theCString)+1;
  
     // If the string is not empty.     // If the string is not empty.
     if (length != 1)     if (length != 1)
Line 3950 
Line 6567 
     else     else
     {     {
         ptr.start = 0;         ptr.start = 0;
         ptr.length = 0;          ptr.size = 0;
     }     }
 } }
  
 static void _setBinary(  void _setBinary(
     const void* theBuffer,     const void* theBuffer,
     Uint64 bufferSize,      Uint32 bufferSize,
     SCMBDataPtr& ptr,     SCMBDataPtr& ptr,
     SCMBMgmt_Header** pmem)     SCMBMgmt_Header** pmem)
 { {
  
     // If buffer is not empty.     // If buffer is not empty.
     if (bufferSize != 1)      if (bufferSize != 0 && theBuffer != 0)
     {     {
  
         Uint64 start;         Uint64 start;
Line 3979 
Line 6596 
     else     else
     {     {
         ptr.start = 0;         ptr.start = 0;
         ptr.length = 0;          ptr.size = 0;
       }
     }     }
   
   void _destroyExternalReferencesInternal(SCMBMgmt_Header* memHdr)
   {
   
       Uint32 number = memHdr->numberExtRef;
   
       if (0 != number)
       {
           char * base = ((char*)memHdr);
           Uint64* array =
               (Uint64*)&(base[memHdr->extRefIndexArray.start]);
           for (Uint32 i = 0; i < number; i++)
           {
                delete ((SCMBUnion*)(&(base[array[i]])))->extRefPtr;
 } }
  
       }
   }
  
 PEGASUS_NAMESPACE_END PEGASUS_NAMESPACE_END


Legend:
Removed from v.1.2.2.13  
changed lines
  Added in v.1.24

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2