version 1.14.2.4, 2012/05/25 13:04:22
|
version 1.24, 2013/02/13 11:39:58
|
|
|
// | // |
////////////////////////////////////////////////////////////////////////// | ////////////////////////////////////////////////////////////////////////// |
// | // |
|
// 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> |
|
|
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) |
{ | { |
|
|
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) |
{ | { |
|
|
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) |
|
|
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) |
|
|
| |
// 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]); |
|
|
| |
// 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]); |
|
|
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)); |
|
|
{ | { |
return(u); | return(u); |
} | } |
break; |
|
} | } |
| |
case CIMTYPE_STRING: | case CIMTYPE_STRING: |
|
|
} | } |
| |
return(ptr); | return(ptr); |
break; |
|
} | } |
default: | default: |
{ | { |
|
|
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: |
|
|
// 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: |
{ | { |
|
|
{ | { |
// From PEP 194: EmbeddedObjects cannot be keys. | // From PEP 194: EmbeddedObjects cannot be keys. |
throw TypeMismatchException(); | throw TypeMismatchException(); |
break; |
|
} | } |
default: | default: |
{ | { |
|
|
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: |
|
|
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: |
|
|
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: |
|
|
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) |
|
|
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: |
|
|
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: |
|
|
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: |
|
|
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) |
|
|
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: |
|
|
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 |
{ | { |
|
|
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; |
|
} | } |
} | } |
} | } |
|
|
| |
} | } |
| |
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) |
|
{ |
|
return; |
|
} |
|
|
|
|
|
/****************************************************************************** | /****************************************************************************** |
* SCMODump Print and Dump functions | * SCMODump Print and Dump functions |
*****************************************************************************/ | *****************************************************************************/ |
|
|
} | } |
else | else |
{ | { |
line = clshdr->propertySet.number%16; |
line = clshdr->propertySet.number & 15; |
} | } |
| |
| |
|
|
| |
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)); |
| |
|
|
| |
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") |
|
|
} | } |
else | else |
{ | { |
line = size%16; |
line = size & 15; |
} | } |
| |
| |
|
|
} | } |
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," "); |
} | } |
|
|
} | } |
| |
printLine[1][p] = item/16; | printLine[1][p] = item/16; |
printLine[2][p] = item%16; |
printLine[2][p] = item & 15; |
| |
} | } |
} | } |
|
|
| |
return; | return; |
} | } |
|
#endif // PEGASUS_DEBUG (class SCMODump only in debug builds available) |
| |
| |
/***************************************************************************** | /***************************************************************************** |