version 1.19, 2012/02/21 11:36:15
|
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)); |
|
|
_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); |
|
|
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; |
|
|
| |
} | } |
| |
|
// class SCMODump only in debug builds available |
|
#ifdef PEGASUS_DEBUG |
/****************************************************************************** | /****************************************************************************** |
* 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) |
| |
| |
/***************************************************************************** | /***************************************************************************** |