(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.12 and 1.24

version 1.12, 2010/02/17 11:28:21 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>
Line 227 
Line 232 
     }     }
 } }
  
   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
  *****************************************************************************/  *****************************************************************************/
Line 538 
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 593 
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 760 
Line 797 
     Uint32 *hashTable = cls.hdr->keyBindingSet.hashTable;     Uint32 *hashTable = cls.hdr->keyBindingSet.hashTable;
  
     // 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 811 
Line 849 
     Uint32 *hashTable = cls.hdr->propertySet.hashTable;     Uint32 *hashTable = cls.hdr->propertySet.hashTable;
  
     // 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 884 
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]);
Line 904 
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]);
Line 1223 
Line 1261 
 SCMOInstance::SCMOInstance( SCMOInstance::SCMOInstance(
     SCMOClass& baseClass,     SCMOClass& baseClass,
     Boolean includeQualifiers,     Boolean includeQualifiers,
     Boolean includeClassOrigin,      Boolean includeClassOrigin)
     const char** propertyList)  
 { {
  
     _initSCMOInstance(new SCMOClass(baseClass));     _initSCMOInstance(new SCMOClass(baseClass));
Line 1232 
Line 1269 
     inst.hdr->flags.includeQualifiers=includeQualifiers;     inst.hdr->flags.includeQualifiers=includeQualifiers;
     inst.hdr->flags.includeClassOrigin=includeClassOrigin;     inst.hdr->flags.includeClassOrigin=includeClassOrigin;
  
     setPropertyFilter(propertyList);  
   
 } }
  
 SCMOInstance::SCMOInstance(SCMOClass& baseClass, const CIMObjectPath& cimObj) SCMOInstance::SCMOInstance(SCMOClass& baseClass, const CIMObjectPath& cimObj)
Line 1508 
Line 1543 
             // only references can be a key binding             // only references can be a key binding
             if (theClassKeyBindNodeArray[i].type == CIMTYPE_REFERENCE)             if (theClassKeyBindNodeArray[i].type == CIMTYPE_REFERENCE)
             {             {
                delete theInstanceKeyBindingNodeArray[i].data.extRefPtr;                 _deleteExternalReferenceInternal(
                      inst.mem,
                      theInstanceKeyBindingNodeArray[i].data.extRefPtr);
             }             }
         }         }
     }// for all key bindings     }// for all key bindings
Line 1527 
Line 1564 
                 // only references can be a key binding.                 // only references can be a key binding.
                 if (theUserDefKBElement->type == CIMTYPE_REFERENCE)                 if (theUserDefKBElement->type == CIMTYPE_REFERENCE)
                 {                 {
                     delete theUserDefKBElement->value.data.extRefPtr;                     _deleteExternalReferenceInternal(
                          inst.mem,
                          theUserDefKBElement->value.data.extRefPtr);
                 }                 }
             }             }
  
Line 1573 
Line 1612 
         }         }
     }     }
  
     if (inst.hdr->flags.isFiltered)  
     {  
         // Get absolut pointer to property filter index map of the instance  
         Uint32* propertyFilterIndexMap =  
             (Uint32*)&(inst.base[inst.hdr->propertyFilterIndexMap.start]);  
   
         for(Uint32 i = 0, k = inst.hdr->filterProperties; i<k; i++)  
         {  
             // Get absolut pointer to property filter index map  
             // of the instance get the real node index of the property.  
             CIMProperty theProperty=_getCIMPropertyAtNodeIndex(  
                 propertyFilterIndexMap[i]);  
   
             newInstance._rep->_properties.append(theProperty);  
         }  
   
     }  
     else  
     {  
   
         if (inst.hdr->flags.exportSetOnly)         if (inst.hdr->flags.exportSetOnly)
          {          {
              for(Uint32 i = 0, k = inst.hdr->numberProperties; i<k; i++)              for(Uint32 i = 0, k = inst.hdr->numberProperties; i<k; i++)
Line 1621 
Line 1640 
                  newInstance._rep->_properties.append(theProperty);                  newInstance._rep->_properties.append(theProperty);
              }              }
          }          }
     }  
     cimInstance = newInstance;     cimInstance = newInstance;
  
     return rc;     return rc;
Line 2331 
Line 2350 
     _setBinary(hostName,len+1,inst.hdr->hostName,&inst.mem);     _setBinary(hostName,len+1,inst.hdr->hostName,&inst.mem);
 } }
  
 void SCMOInstance::setHostName_l(const char* hostName, Uint32 len)  
 {  
     // Copy on Write is only necessary if a realloc() becomes necessary  
     if (inst.mem->freeBytes < ((len+8) & ~7))  
     {  
         _copyOnWrite();  
     }  
     // copy including trailing '\0'  
     _setBinary(hostName,len+1,inst.hdr->hostName,&inst.mem);  
 }  
   
 const char* SCMOInstance::getHostName() const const char* SCMOInstance::getHostName() const
 { {
     return _getCharString(inst.hdr->hostName,inst.base);     return _getCharString(inst.hdr->hostName,inst.base);
Line 2458 
Line 2466 
     return _getCharString(inst.hdr->instNameSpace,inst.base);     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() void SCMOInstance::buildKeyBindingsFromProperties()
 { {
     Uint32 propNode;     Uint32 propNode;
Line 2473 
Line 2508 
     SCMBValue* theInstPropNodeArray=     SCMBValue* theInstPropNodeArray=
         (SCMBValue*)&inst.base[inst.hdr->propertyArray.start];         (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++)     for (Uint32 i = 0, k = inst.hdr->numberKeyBindings; i < k; i++)
     {     {
         // If the keybinding is not set.         // If the keybinding is not set.
Line 2814 
Line 2852 
         return rc;         return rc;
     }     }
  
     // is filtering on ?  
     if (inst.hdr->flags.isFiltered)  
     {  
         // Is the property NOT in the property filter ?  
         if(!_isPropertyInFilter(node))  
         {  
             // The named propery is not part of this instance  
             // due to filtering.  
             return SCMO_NOT_FOUND;  
         }  
     }  
   
     return  _getPropertyAtNodeIndex(node,&pname,type,pOutVal,isArray,size);     return  _getPropertyAtNodeIndex(node,&pname,type,pOutVal,isArray,size);
 } }
  
Line 2841 
Line 2867 
     *pOutVal = 0;     *pOutVal = 0;
     isArray = false;     isArray = false;
     size = 0;     size = 0;
     Uint32 node;  
  
     // is filtering on ?      if (idx >= inst.hdr->numberProperties)
     if (inst.hdr->flags.isFiltered)  
     {  
         // check the number of properties part of the filter  
         if (idx >= inst.hdr->filterProperties)  
         {         {
             return SCMO_INDEX_OUT_OF_BOUND;             return SCMO_INDEX_OUT_OF_BOUND;
         }         }
  
         // Get absolut pointer to property filter index map of the instance      return  _getPropertyAtNodeIndex(idx,pname,type,pOutVal,isArray,size);
         Uint32* propertyFilterIndexMap =  
         (Uint32*)&(inst.base[inst.hdr->propertyFilterIndexMap.start]);  
   
         // get the real node index of the property.  
         node = propertyFilterIndexMap[idx];  
     }  
     else  
     {  
         // the index is used as node index.  
         node = idx;  
         if (node >= inst.hdr->numberProperties)  
         {  
             return SCMO_INDEX_OUT_OF_BOUND;  
         }  
     }  
   
     return  _getPropertyAtNodeIndex(node,pname,type,pOutVal,isArray,size);  
 } }
  
 SCMO_RC SCMOInstance::getPropertyNodeIndex(const char* name, Uint32& node) const SCMO_RC SCMOInstance::getPropertyNodeIndex(const char* name, Uint32& node) const
Line 2915 
Line 2919 
         return rc;         return rc;
     }     }
  
     // is filtering on ?  
     if (inst.hdr->flags.isFiltered)  
     {  
         // Is the property NOT in the property filter ?  
         if(!_isPropertyInFilter(node))  
         {  
             // The named propery is not part of this instance  
             // due to filtering.  
             return SCMO_NOT_FOUND;  
         }  
     }  
   
     // check class origin if set.     // check class origin if set.
     if (origin!= 0)     if (origin!= 0)
     {     {
Line 2959 
Line 2951 
         return SCMO_INDEX_OUT_OF_BOUND;         return SCMO_INDEX_OUT_OF_BOUND;
     }     }
  
     // is filtering on ?  
     if (inst.hdr->flags.isFiltered)  
     {  
         // Is the property NOT in the property filter ?  
         if(!_isPropertyInFilter(node))  
         {  
             // The proptery of the is not set due to filtering.  
             return SCMO_OK;  
         }  
     }  
   
     // Is the traget type OK ?     // Is the traget type OK ?
     // The type stored in the class information is set on realType.     // The type stored in the class information is set on realType.
     // It must be used in further calls to guaranty consistence.     // It must be used in further calls to guaranty consistence.
Line 3769 
Line 3750 
  
     case CIMTYPE_STRING:     case CIMTYPE_STRING:
         {         {
             _setString(*((String*)((void*)&u)),              CString cstr = ((String*)((void*)&u))->getCString();
               const char *cptr = (const char*)cstr;
               _setBinary(
                   cptr,
                   strlen(cptr) + 1,
                        scmoUnion->stringValue,                        scmoUnion->stringValue,
                        pmem );                        pmem );
             break;             break;
Line 4255 
Line 4240 
  
 Uint32 SCMOInstance::getPropertyCount() const Uint32 SCMOInstance::getPropertyCount() const
 { {
     if (inst.hdr->flags.isFiltered)  
     {  
         return(inst.hdr->filterProperties);  
     }  
   
     return(inst.hdr->numberProperties);     return(inst.hdr->numberProperties);
 } }
  
Line 4311 
Line 4291 
             {             {
                 return(u);                 return(u);
             }             }
             break;  
         }         }
  
     case CIMTYPE_STRING:     case CIMTYPE_STRING:
Line 4346 
Line 4325 
             }             }
  
              return(ptr);              return(ptr);
             break;  
         }         }
     default:     default:
         {         {
Line 4374 
Line 4352 
           inst.hdr->keyBindingArray,           inst.hdr->keyBindingArray,
           sizeof(SCMBKeyBindingValue)*inst.hdr->numberKeyBindings,           sizeof(SCMBKeyBindingValue)*inst.hdr->numberKeyBindings,
           &inst.mem);           &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 Uint32 SCMOInstance::getKeyBindingCount() const
Line 4585 
Line 4569 
                         return CIMTYPE_REAL64;                         return CIMTYPE_REAL64;
                     }                     }
                 }                 }
                 break;  
             }             }
  
  
         case CIMKeyBinding::STRING:         case CIMKeyBinding::STRING:
         {         {
             return CIMTYPE_STRING;             return CIMTYPE_STRING;
             break;  
         }         }
  
         case CIMKeyBinding::BOOLEAN:         case CIMKeyBinding::BOOLEAN:
         {         {
             return CIMTYPE_BOOLEAN;             return CIMTYPE_BOOLEAN;
             break;  
         }         }
  
         case CIMKeyBinding::REFERENCE:         case CIMKeyBinding::REFERENCE:
         {         {
             return CIMTYPE_REFERENCE;             return CIMTYPE_REFERENCE;
             break;  
         }         }
  
         default:         default:
Line 4815 
Line 4795 
             // Can cause reallocation !             // Can cause reallocation !
             _setString(kbs,scmoKBV.data.stringValue,&inst.mem);             _setString(kbs,scmoKBV.data.stringValue,&inst.mem);
             return true;             return true;
             break;  
         }         }
     case CIMTYPE_REFERENCE:     case CIMTYPE_REFERENCE:
         {         {
Line 4852 
Line 4831 
         {         {
             // From PEP 194: EmbeddedObjects cannot be keys.             // From PEP 194: EmbeddedObjects cannot be keys.
             throw TypeMismatchException();             throw TypeMismatchException();
             break;  
         }         }
     default:     default:
         {         {
Line 4939 
Line 4917 
  
     _copyOnWrite();     _copyOnWrite();
  
       // 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;
       }
   
     rc = inst.hdr->theClass.ptr->_getKeyBindingNodeIndex(node,name);     rc = inst.hdr->theClass.ptr->_getKeyBindingNodeIndex(node,name);
     if (rc != SCMO_OK)     if (rc != SCMO_OK)
     {     {
Line 4989 
Line 4976 
  
     _copyOnWrite();     _copyOnWrite();
  
       // 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;
       }
   
   
    // 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.ptr->cls.hdr->     Uint64 idx = inst.hdr->theClass.ptr->cls.hdr->
         keyBindingSet.nodeArray.start;         keyBindingSet.nodeArray.start;
Line 5075 
Line 5072 
                 kbValue.isSet=true;                 kbValue.isSet=true;
                 kbValue.data.simple.hasValue=true;                 kbValue.data.simple.hasValue=true;
                 kbValue.data.simple.val.u8=Uint8(keyValue->simple.val.u64);                 kbValue.data.simple.val.u8=Uint8(keyValue->simple.val.u64);
                 return SCMO_OK;  
                 break;                 break;
             }             }
         case CIMTYPE_UINT16:         case CIMTYPE_UINT16:
Line 5083 
Line 5079 
                 kbValue.isSet=true;                 kbValue.isSet=true;
                 kbValue.data.simple.hasValue=true;                 kbValue.data.simple.hasValue=true;
                 kbValue.data.simple.val.u16=Uint16(keyValue->simple.val.u64);                 kbValue.data.simple.val.u16=Uint16(keyValue->simple.val.u64);
                 return SCMO_OK;  
                 break;                 break;
             }             }
         case CIMTYPE_UINT32:         case CIMTYPE_UINT32:
Line 5091 
Line 5086 
                 kbValue.isSet=true;                 kbValue.isSet=true;
                 kbValue.data.simple.hasValue=true;                 kbValue.data.simple.hasValue=true;
                 kbValue.data.simple.val.u32=Uint32(keyValue->simple.val.u64);                 kbValue.data.simple.val.u32=Uint32(keyValue->simple.val.u64);
                 return SCMO_OK;  
                 break;                 break;
             }             }
         case CIMTYPE_UINT64:         case CIMTYPE_UINT64:
Line 5099 
Line 5093 
                 kbValue.isSet=true;                 kbValue.isSet=true;
                 kbValue.data.simple.hasValue=true;                 kbValue.data.simple.hasValue=true;
                 kbValue.data.simple.val.u64=keyValue->simple.val.u64;                 kbValue.data.simple.val.u64=keyValue->simple.val.u64;
                 return SCMO_OK;  
                 break;                 break;
             }             }
         default:         default:
             {             {
                 return SCMO_TYPE_MISSMATCH;                 return SCMO_TYPE_MISSMATCH;
                 break;  
             }             }
         }         }
           return SCMO_OK;
   
     }     }
  
     if (setType == CIMTYPE_SINT64)     if (setType == CIMTYPE_SINT64)
Line 5120 
Line 5114 
                 kbValue.isSet=true;                 kbValue.isSet=true;
                 kbValue.data.simple.hasValue=true;                 kbValue.data.simple.hasValue=true;
                 kbValue.data.simple.val.s8=Sint8(keyValue->simple.val.s64);                 kbValue.data.simple.val.s8=Sint8(keyValue->simple.val.s64);
                 return SCMO_OK;  
                 break;                 break;
             }             }
         case CIMTYPE_SINT16:         case CIMTYPE_SINT16:
Line 5128 
Line 5121 
                 kbValue.isSet=true;                 kbValue.isSet=true;
                 kbValue.data.simple.hasValue=true;                 kbValue.data.simple.hasValue=true;
                 kbValue.data.simple.val.s16=Sint16(keyValue->simple.val.s64);                 kbValue.data.simple.val.s16=Sint16(keyValue->simple.val.s64);
                 return SCMO_OK;  
                 break;                 break;
             }             }
         case CIMTYPE_SINT32:         case CIMTYPE_SINT32:
Line 5136 
Line 5128 
                 kbValue.isSet=true;                 kbValue.isSet=true;
                 kbValue.data.simple.hasValue=true;                 kbValue.data.simple.hasValue=true;
                 kbValue.data.simple.val.s32=Sint32(keyValue->simple.val.s64);                 kbValue.data.simple.val.s32=Sint32(keyValue->simple.val.s64);
                 return SCMO_OK;  
                 break;                 break;
             }             }
         case CIMTYPE_SINT64:         case CIMTYPE_SINT64:
Line 5144 
Line 5135 
                 kbValue.isSet=true;                 kbValue.isSet=true;
                 kbValue.data.simple.hasValue=true;                 kbValue.data.simple.hasValue=true;
                 kbValue.data.simple.val.s64=keyValue->simple.val.s64;                 kbValue.data.simple.val.s64=keyValue->simple.val.s64;
                 return SCMO_OK;  
                 break;                 break;
             }             }
         default:         default:
             {             {
                 return SCMO_TYPE_MISSMATCH;                 return SCMO_TYPE_MISSMATCH;
                 break;  
             }             }
         }         }
           return SCMO_OK;
     }     }
  
     if (setType == CIMTYPE_REAL64)     if (setType == CIMTYPE_REAL64)
Line 5164 
Line 5154 
                 kbValue.isSet=true;                 kbValue.isSet=true;
                 kbValue.data.simple.hasValue=true;                 kbValue.data.simple.hasValue=true;
                 kbValue.data.simple.val.r32=Real32(keyValue->simple.val.r64);                 kbValue.data.simple.val.r32=Real32(keyValue->simple.val.r64);
                 return SCMO_OK;  
                 break;                 break;
             }             }
         case CIMTYPE_REAL64:         case CIMTYPE_REAL64:
Line 5172 
Line 5161 
                 kbValue.isSet=true;                 kbValue.isSet=true;
                 kbValue.data.simple.hasValue=true;                 kbValue.data.simple.hasValue=true;
                 kbValue.data.simple.val.r64=keyValue->simple.val.r64;                 kbValue.data.simple.val.r64=keyValue->simple.val.r64;
                 return SCMO_OK;  
                 break;                 break;
             }             }
         default:         default:
             {             {
                 return SCMO_TYPE_MISSMATCH;                 return SCMO_TYPE_MISSMATCH;
                 break;  
             }             }
         }         }
           return SCMO_OK;
     }     }
     else     else
     {     {
Line 5205 
Line 5193 
                 kbValue.isSet=true;                 kbValue.isSet=true;
                 _setSCMBUnion(keyValue,classType,false, 0,kbValue.data);                 _setSCMBUnion(keyValue,classType,false, 0,kbValue.data);
                 return SCMO_OK;                 return SCMO_OK;
                 break;  
             }             }
         default:         default:
             {             {
                 return SCMO_TYPE_MISSMATCH;                 return SCMO_TYPE_MISSMATCH;
                 break;  
             }             }
         }         }
     }     }
Line 5219 
Line 5205 
  
 } }
  
 static int _indexComp(const void* left, const void* right)  // class SCMODump only in debug builds available
 {  #ifdef PEGASUS_DEBUG
     return((*(Uint32 *)left)-(*(Uint32 *)right));  
 }  
   
 void SCMOInstance::setPropertyFilter(const char **propertyList)  
 {  
     SCMO_RC rc;  
     Uint32 node,i = 0;  
   
     _copyOnWrite();  
   
     if (inst.hdr->propertyFilter.start == 0)  
     {  
         // Allocate the SCMBPropertyFilter  
         _getFreeSpace(  
             inst.hdr->propertyFilter,  
             sizeof(Uint64)*(((inst.hdr->numberProperties-1)/64)+1),  
             &inst.mem);  
   
         // Allocate the SCMBPropertyFilterIndexMap  
         _getFreeSpace(  
             inst.hdr->propertyFilterIndexMap,  
             sizeof(Uint32)*inst.hdr->numberProperties,  
             &inst.mem);  
     }  
     // 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 == 0)  
     {  
         // Clear filtering:  
         // Switch filtering off.  
         inst.hdr->flags.isFiltered = false;  
   
         // Clear filter index map  
         memset(  
             propertyFilterIndexMap,  
             0,  
             sizeof(Uint32)*inst.hdr->numberProperties);  
   
         //reset number filter properties to all  
         inst.hdr->filterProperties = inst.hdr->numberProperties;  
   
         return;  
     }  
   
     // Switch filtering on.  
     inst.hdr->flags.isFiltered = true;  
   
     // intit the filter with the key properties  
     inst.hdr->filterProperties=_initPropFilterWithKeys();  
   
     // add the properties to the filter.  
     while (propertyList[i] != 0)  
     {  
         // the hash index of the property if the property name is found  
         rc = inst.hdr->theClass.ptr->_getProperyNodeIndex(node,propertyList[i]);  
   
         // if property is already in the filter  
         // ( eg. key properties ) do not add them !  
         if (rc == SCMO_OK && !_isPropertyInFilter(node))  
         {  
             // The property name was found. Otherwise ignore this property name.  
             // 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++;  
     }  
   
     // sort the filter index to be in order as properties stored in the class.  
     qsort(  
         propertyFilterIndexMap,  
         inst.hdr->filterProperties,  
         sizeof(Uint32),  
         _indexComp);  
 }  
   
 Uint32 SCMOInstance::_initPropFilterWithKeys()  
 {  
   
     // Get absolut pointer to the key property mask of the class.  
     Uint64 idx = inst.hdr->theClass.ptr->cls.hdr->keyPropertyMask.start;  
     Uint64* keyMask =(Uint64*)&(inst.hdr->theClass.ptr->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  
     memcpy(  
         propertyFilterMask,  
         keyMask,  
         sizeof(Uint64)*(((inst.hdr->numberProperties-1)/64)+1));  
   
     // Get absolut pointer to key index list of the class  
     idx=inst.hdr->theClass.ptr->cls.hdr->keyIndexList.start;  
     Uint32* keyIndex = (Uint32*)&(inst.hdr->theClass.ptr->cls.base)[idx];  
   
     // Get absolut pointer to property filter index map of the instance  
     Uint32* propertyFilterIndexMap =  
         (Uint32*)&(inst.base[inst.hdr->propertyFilterIndexMap.start]);  
   
     Uint32 noKeys = inst.hdr->theClass.ptr->cls.hdr->keyBindingSet.number;  
     memcpy(propertyFilterIndexMap,keyIndex,sizeof(Uint32)*noKeys);  
   
     // return the number of properties already in the filter index map  
     return noKeys;  
   
 }  
   
 void SCMOInstance::_clearPropertyFilter()  
 {  
     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 :  
     // 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(propertyFilter,  
            0,  
            sizeof(Uint64)*(((inst.hdr->numberProperties-1)/64)+1));  
   
 }  
 void SCMOInstance::_setPropertyInPropertyFilter(Uint32 i)  
 {  
     Uint64 *propertyFilter;  
   
     // In which Uint64 of key mask is the bit for property i ?  
     // Divide with the number of bits in a Uint64.  
     // 47 / 64 = 0 --> The key bit for property i is in in keyMask[0].  
     Uint32 idx = i/64 ;  
   
     // 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]);  
   
     propertyFilter[idx] = propertyFilter[idx] | filter ;  
 }  
   
 Boolean SCMOInstance::_isPropertyInFilter(Uint32 i) const  
 {  
     Uint64 *propertyFilter;  
   
     // In which Uint64 of key mask is the bit for property i ?  
     // Divide with the number of bits in a Uint64.  
     // e.g. number of Properties = 68  
     // 47 / 64 = 0 --> The key bit for property i is in in keyMask[0].  
     Uint32 idx = i/64 ;  
   
     // Create a filter to check if the bit is set:  
     // 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]);  
   
     // If the bit is set the property is NOT filtered.  
     // So the result has to be negated!  
     return propertyFilter[idx] & filter ;  
   
 }  
   
 /****************************************************************************** /******************************************************************************
  * SCMODump Print and Dump functions  * SCMODump Print and Dump functions
  *****************************************************************************/  *****************************************************************************/
Line 5522 
Line 5331 
            (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",  
            (insthdr->flags.isFiltered ? "True" : "False"));  
     fprintf(_out,"\n   isClassOnly: %s",     fprintf(_out,"\n   isClassOnly: %s",
            (insthdr->flags.isClassOnly ? "True" : "False"));            (insthdr->flags.isClassOnly ? "True" : "False"));
     fprintf(_out,"\n   isCompromised: %s",     fprintf(_out,"\n   isCompromised: %s",
Line 5539 
Line 5346 
  
     dumpSCMOInstanceKeyBindings(testInst);     dumpSCMOInstanceKeyBindings(testInst);
  
     dumpSCMOInstancePropertyFilter(testInst);  
   
     dumpInstanceProperties(testInst);     dumpInstanceProperties(testInst);
     fprintf(_out,"\n\n");     fprintf(_out,"\n\n");
  
 } }
  
 void SCMODump::dumpSCMOInstancePropertyFilter(SCMOInstance& testInst) const  
 {  
     SCMBInstance_Main* insthdr = testInst.inst.hdr;  
   
     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( void SCMODump::dumpInstanceProperties(
     SCMOInstance& testInst,     SCMOInstance& testInst,
     Boolean verbose) const     Boolean verbose) const
Line 5586 
Line 5370 
     {     {
         fprintf(_out,"\n\nInstance property (#%3u) %s\n",i,         fprintf(_out,"\n\nInstance property (#%3u) %s\n",i,
                 NULLSTR(insthdr->theClass.ptr->_getPropertyNameAtNode(i)));                 NULLSTR(insthdr->theClass.ptr->_getPropertyNameAtNode(i)));
         if(insthdr->flags.isFiltered && !testInst._isPropertyInFilter(i))  
         {  
             fprintf(_out,"\nProperty is filtered out!");  
         }  
         else  
         {  
             printSCMOValue(val[i],instbase,verbose);  
         }  
     }  
   
 }  
   
 void SCMODump::dumpPropertyFilterIndexMap(SCMOInstance& testInst) const  
 {  
  
     SCMBInstance_Main* insthdr = testInst.inst.hdr;          printSCMOValue(val[i],instbase,verbose);
     char* instbase = testInst.inst.base;  
   
     if (!insthdr->flags.isFiltered)  
     {  
         fprintf(_out,"\n\nNo propterty filter!\n\n");  
         return;  
     }  
   
     fprintf(_out,"\n\nProperty Filter Index Max:");  
     fprintf(_out,"\n==========================\n");  
   
     // Get absolut pointer to key index list of the class  
     Uint32* keyIndex =  
         (Uint32*)&(instbase)[insthdr->propertyFilterIndexMap.start];  
   
     Uint32 line,j,i,k = insthdr->filterProperties;  
   
     for (j = 0; j < k; j = j + line)  
     {  
         if ((insthdr->filterProperties-j)/16)  
         {  
             line = 16 ;  
         }  
         else  
         {  
             line = insthdr->filterProperties%16;  
         }  
   
   
         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");  
   
     }  
   
 }  
   
 void SCMODump::dumpPropertyFilter(SCMOInstance& testInst) const  
 {  
   
     SCMBInstance_Main* insthdr = testInst.inst.hdr;  
     char* instbase = testInst.inst.base;  
   
     if (!insthdr->flags.isFiltered)  
     {  
         fprintf(_out,"\n\nNo propterty filter!");  
         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++ )  
      {  
          printMask = 1;  
          if (i < noMasks)  
          {  
              end = 64;  
          }  
          else  
          {  
              end = noProperties%64;  
          }          }
  
          fprintf(_out,"\npropertyFilter[%02u]= ",i);  
   
          for (Uint32 j = 0; j < end; j++)  
          {  
              if (j > 0 && !(j%8))  
              {  
                  fprintf(_out," ");  
              }              }
  
              if (thePropertyFilter[i] & printMask)  
              {  
                  fprintf(_out,"1");  
              }  
              else  
              {  
                  fprintf(_out,"0");  
              }  
   
              printMask = printMask << 1;  
          }  
          fprintf(_out,"\n");  
      }  
 }  
  
 void SCMODump::dumpSCMOInstanceKeyBindings( void SCMODump::dumpSCMOInstanceKeyBindings(
     SCMOInstance& testInst,     SCMOInstance& testInst,
Line 5910 
Line 5584 
         }         }
         else         else
         {         {
             line = clshdr->propertySet.number%16;              line = clshdr->propertySet.number & 15;
         }         }
  
  
Line 5977 
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,"\nType: %s",cimTypeToString(nodeArray[i].type));         fprintf(_out,"\nType: %s",cimTypeToString(nodeArray[i].type));
  
Line 6037 
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 6071 
Line 5745 
         }         }
         else         else
         {         {
             line = size%16;              line = size & 15;
         }         }
  
  
Line 6189 
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 6267 
Line 5941 
         }         }
  
         printLine[1][p] = item/16;         printLine[1][p] = item/16;
         printLine[2][p] = item%16;          printLine[2][p] = item & 15;
  
     }     }
 } }
Line 6703 
Line 6377 
  
   return;   return;
 } }
   #endif // PEGASUS_DEBUG (class SCMODump only in debug builds available)
  
  
 /***************************************************************************** /*****************************************************************************


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

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2