version 1.2.2.38, 2009/10/13 09:36:35
|
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> |
|
|
#include <Pegasus/Common/CIMNameCast.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/ArrayIterator.h> |
#include <Pegasus/Common/PegasusAssert.h> | #include <Pegasus/Common/PegasusAssert.h> |
|
#include <Pegasus/Common/CIMValueRep.h> |
|
|
|
# if defined PEGASUS_OS_ZOS |
#include <strings.h> | #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> |
|
|
*/ | */ |
#define NULLSTR(x) ((x) == 0 ? "" : (x)) | #define NULLSTR(x) ((x) == 0 ? "" : (x)) |
| |
#define NEWCIMSTR(ptr,base) \ |
|
((ptr).length == 0 ? \ |
|
(String()) : \ |
|
(String(&(base)[(ptr).start],((ptr).length)-1))) |
|
|
|
PEGASUS_NAMESPACE_BEGIN | PEGASUS_NAMESPACE_BEGIN |
| |
#define PEGASUS_ARRAY_T SCMOInstance | #define PEGASUS_ARRAY_T SCMOInstance |
# include "ArrayImpl.h" | # include "ArrayImpl.h" |
#undef PEGASUS_ARRAY_T | #undef PEGASUS_ARRAY_T |
| |
|
|
const StrLit SCMOClass::_qualifierNameStrLit[72] = | const StrLit SCMOClass::_qualifierNameStrLit[72] = |
{ | { |
STRLIT(""), | STRLIT(""), |
|
|
#define _NUM_QUALIFIER_NAMES \ | #define _NUM_QUALIFIER_NAMES \ |
(sizeof(_qualifierNameStrLit)/sizeof(_qualifierNameStrLit[0])) | (sizeof(_qualifierNameStrLit)/sizeof(_qualifierNameStrLit[0])) |
| |
|
|
/***************************************************************************** | /***************************************************************************** |
* Internal inline functions. |
* The static declaration of the common SCMO memory functions. |
*****************************************************************************/ | *****************************************************************************/ |
| |
inline SCMOClass* _getSCMOClass( |
static Uint64 _getFreeSpace( |
const CIMObjectPath& theCIMObj, |
SCMBDataPtr& ptr, |
const char* altNS, |
Uint32 size, |
Uint64 altNSlength) |
SCMBMgmt_Header** pmem); |
{ |
|
SCMOClass* theClass=0; |
|
| |
if (theCIMObj.getClassName().isNull()) |
static void _setString( |
{ |
const String& theString, |
return 0; |
SCMBDataPtr& ptr, |
} |
SCMBMgmt_Header** pmem); |
| |
if (theCIMObj.getNameSpace().isNull()) |
static void _setBinary( |
{ |
const void* theBuffer, |
// the name space of the object path is empty, |
Uint32 bufferSize, |
// use alternative name space. |
SCMBDataPtr& ptr, |
CString clsName = theCIMObj.getClassName().getString().getCString(); |
SCMBMgmt_Header** pmem); |
| |
SCMOClassCache* theCache = SCMOClassCache::getInstance(); |
|
theClass = theCache->getSCMOClass( |
|
altNS, |
|
altNSlength, |
|
(const char*)clsName, |
|
strlen(clsName)); |
|
| |
|
|
|
/***************************************************************************** |
|
* 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 | else |
{ | { |
CString nameSpace = theCIMObj.getNameSpace().getString().getCString(); |
return String(); |
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; |
|
} | } |
| |
inline void _deleteArrayExtReference( | inline void _deleteArrayExtReference( |
|
|
SCMBUnion* ptr; | SCMBUnion* ptr; |
// if the array was already set, | // if the array was already set, |
// the previous references has to be deleted | // the previous references has to be deleted |
if(theArray.length != 0) |
if(theArray.size != 0) |
{ | { |
Uint32 oldArraySize=(theArray.length/sizeof(SCMBUnion)); |
Uint32 oldArraySize=(theArray.size/sizeof(SCMBUnion)); |
| |
ptr = (SCMBUnion*)&(((char*)*pmem)[theArray.start]); | ptr = (SCMBUnion*)&(((char*)*pmem)[theArray.start]); |
for (Uint32 i = 0 ; i < oldArraySize ; i++) | for (Uint32 i = 0 ; i < oldArraySize ; i++) |
{ | { |
delete ptr[i].extRefPtr; | delete ptr[i].extRefPtr; |
|
ptr[i].extRefPtr = 0; |
} | } |
} | } |
} | } |
| |
inline void _copyArrayExtReference( |
static void _deleteExternalReferenceInternal( |
SCMBDataPtr& theArray, |
SCMBMgmt_Header* memHdr, SCMOInstance *extRefPtr) |
SCMBMgmt_Header** pmem ) |
|
{ | { |
SCMBUnion* ptr; |
Uint32 nuExtRef = memHdr->numberExtRef; |
// if the array was already set, |
char * base = ((char*)memHdr); |
// the previous references has to be deleted |
Uint64* array = |
if(theArray.length != 0) |
(Uint64*)&(base[memHdr->extRefIndexArray.start]); |
{ |
Uint32 extRefIndex = PEG_NOT_FOUND; |
Uint32 oldArraySize=(theArray.length/sizeof(SCMBUnion)); |
|
| |
ptr = (SCMBUnion*)&(((char*)*pmem)[theArray.start]); |
for (Uint32 i = 0; i < nuExtRef; i++) |
for (Uint32 i = 0 ; i < oldArraySize ; i++) |
|
{ | { |
if (ptr[i].extRefPtr != 0) |
if (((SCMBUnion*)(&(base[array[i]])))->extRefPtr == extRefPtr) |
{ | { |
ptr[i].extRefPtr = new SCMOInstance(*ptr[i].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; |
} | } |
| |
/***************************************************************************** | /***************************************************************************** |
|
|
*****************************************************************************/ | *****************************************************************************/ |
SCMOClass::SCMOClass() | SCMOClass::SCMOClass() |
{ | { |
cls.mem = 0; |
_initSCMOClass(); |
} |
|
|
|
void SCMOClass::_destroyExternalReferences() |
|
{ |
|
// TODO: Has to be optimized not to loop through all props. |
|
// Address the property array |
|
SCMBClassPropertyNode* nodeArray = |
|
(SCMBClassPropertyNode*) |
|
&(cls.base[cls.hdr->propertySet.nodeArray.start]); |
|
|
|
SCMBValue* theValue; |
|
|
|
for (Uint32 i = 0; i < cls.hdr->propertySet.number; i++) |
|
{ |
|
theValue = &(nodeArray[i].theProperty.defaultValue); |
|
| |
// if not an NULL value ! |
_setBinary("",1,cls.hdr->className,&cls.mem ); |
if(!theValue->flags.isNull) |
_setBinary("",1,cls.hdr->nameSpace,&cls.mem ); |
{ |
cls.hdr->flags.isEmpty=true; |
if (theValue->valueType == CIMTYPE_REFERENCE || |
|
theValue->valueType == CIMTYPE_OBJECT || |
|
theValue->valueType == CIMTYPE_INSTANCE ) |
|
{ |
|
if (theValue->flags.isArray) |
|
{ |
|
_deleteArrayExtReference( |
|
theValue->value.arrayValue, |
|
&cls.mem); |
|
} |
|
else |
|
{ |
|
delete theValue->value.extRefPtr; |
|
} // end is Array |
|
} // end is ext. reference. |
|
}// end is not null |
|
}// loop throug all properties |
|
} | } |
| |
inline void SCMOClass::_initSCMOClass() | inline void SCMOClass::_initSCMOClass() |
|
|
| |
SCMOClass::SCMOClass(const char* className, const char* nameSpaceName ) | SCMOClass::SCMOClass(const char* className, const char* nameSpaceName ) |
{ | { |
|
Uint32 clsNameLen = strlen(className); |
|
Uint32 nsNameLen = strlen(nameSpaceName); |
|
|
if (0 == className) | if (0 == className) |
{ | { |
String message("SCMOClass: Class name not set (null pointer)!"); | String message("SCMOClass: Class name not set (null pointer)!"); |
|
|
| |
_initSCMOClass(); | _initSCMOClass(); |
| |
_setBinary(className, |
_setBinary(className,clsNameLen+1,cls.hdr->className,&cls.mem ); |
strlen(className)+1, |
|
cls.hdr->className, |
|
&cls.mem ); |
|
| |
_setBinary(nameSpaceName, |
_setBinary(nameSpaceName,nsNameLen+1,cls.hdr->nameSpace,&cls.mem ); |
strlen(nameSpaceName)+1, |
|
cls.hdr->nameSpace, |
cls.hdr->flags.isEmpty=true; |
&cls.mem ); |
|
| |
} | } |
| |
|
|
{ | { |
// 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(); |
|
|
| |
} | } |
| |
|
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 | void SCMOClass::getCIMClass(CIMClass& cimClass) const |
{ | { |
CIMClass newCimClass( | CIMClass newCimClass( |
CIMNameCast(NEWCIMSTR(cls.hdr->className,cls.base)), |
CIMNameCast(_newCimString(cls.hdr->className,cls.base)), |
CIMNameCast(NEWCIMSTR(cls.hdr->superClassName,cls.base))); |
CIMNameCast(_newCimString(cls.hdr->superClassName,cls.base))); |
| |
// set the name space | // set the name space |
newCimClass._rep->_reference._rep->_nameSpace= | newCimClass._rep->_reference._rep->_nameSpace= |
CIMNamespaceNameCast(NEWCIMSTR(cls.hdr->nameSpace,cls.base)); |
CIMNamespaceNameCast(_newCimString(cls.hdr->nameSpace,cls.base)); |
| |
// Add class qualifier if exist | // Add class qualifier if exist |
if (0 != cls.hdr->numberOfQualifiers) | if (0 != cls.hdr->numberOfQualifiers) |
|
|
if (0 != clsProp.theProperty.originClassName.start) | if (0 != clsProp.theProperty.originClassName.start) |
{ | { |
retCimProperty = CIMProperty( | retCimProperty = CIMProperty( |
CIMNameCast(NEWCIMSTR(clsProp.theProperty.name,cls.base)), |
CIMNameCast(_newCimString(clsProp.theProperty.name,cls.base)), |
theCimValue, | theCimValue, |
theCimValue.getArraySize(), | theCimValue.getArraySize(), |
CIMNameCast(NEWCIMSTR(clsProp.theProperty.refClassName,cls.base)), |
CIMNameCast( |
CIMNameCast(NEWCIMSTR( |
_newCimString(clsProp.theProperty.refClassName,cls.base)), |
clsProp.theProperty.originClassName,cls.base)), |
CIMNameCast( |
|
_newCimString(clsProp.theProperty.originClassName,cls.base)), |
clsProp.theProperty.flags.propagated); | clsProp.theProperty.flags.propagated); |
} | } |
else | else |
{ | { |
retCimProperty = CIMProperty( | retCimProperty = CIMProperty( |
CIMNameCast(NEWCIMSTR(clsProp.theProperty.name,cls.base)), |
CIMNameCast(_newCimString(clsProp.theProperty.name,cls.base)), |
theCimValue, | theCimValue, |
theCimValue.getArraySize(), | theCimValue.getArraySize(), |
CIMNameCast(NEWCIMSTR(clsProp.theProperty.refClassName,cls.base)), |
CIMNameCast( |
|
_newCimString(clsProp.theProperty.refClassName,cls.base)), |
CIMName(), | CIMName(), |
clsProp.theProperty.flags.propagated); | clsProp.theProperty.flags.propagated); |
} | } |
|
|
| |
if (scmbQualifier.name == QUALNAME_USERDEFINED) | if (scmbQualifier.name == QUALNAME_USERDEFINED) |
{ | { |
theCimQualiName = NEWCIMSTR(scmbQualifier.userDefName,base); |
theCimQualiName = _newCimString(scmbQualifier.userDefName,base); |
} | } |
else | else |
{ | { |
|
|
| |
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)); |
|
|
|
} | } |
} | } |
| |
|
|
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) |
{ | { |
|
|
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; |
|
|
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) |
{ | { |
|
|
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 ! |
|
|
} 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(PropertySet& theCIMProperties) | void SCMOClass::_setClassProperties(PropertySet& theCIMProperties) |
|
|
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; |
| |
|
|
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) |
{ | { |
|
|
// (68 - 1) / 64 = 1 --> The mask consists of two Uint64 values. | // (68 - 1) / 64 = 1 --> The mask consists of two Uint64 values. |
_getFreeSpace(cls.hdr->keyPropertyMask, | _getFreeSpace(cls.hdr->keyPropertyMask, |
sizeof(Uint64)*(((noProps-1)/64)+1), | sizeof(Uint64)*(((noProps-1)/64)+1), |
&cls.mem,true); |
&cls.mem); |
| |
// allocate property array and save the start index of the array. | // allocate property array and save the start index of the array. |
start = _getFreeSpace(cls.hdr->propertySet.nodeArray, | start = _getFreeSpace(cls.hdr->propertySet.nodeArray, |
sizeof(SCMBClassPropertyNode)*noProps, | sizeof(SCMBClassPropertyNode)*noProps, |
&cls.mem,true); |
&cls.mem); |
| |
// clear the hash table | // clear the hash table |
memset(cls.hdr->propertySet.hashTable, | memset(cls.hdr->propertySet.hashTable, |
|
|
// 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++) |
|
|
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; |
} | } |
} | } |
| |
|
|
| |
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) |
|
|
| |
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) |
|
|
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(), |
|
|
| |
// 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]); |
|
|
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; |
|
|
else | else |
{ | { |
cls.hdr->qualifierArray.start=0; | cls.hdr->qualifierArray.start=0; |
cls.hdr->qualifierArray.length=0; |
cls.hdr->qualifierArray.size=0; |
} | } |
} | } |
| |
|
|
// 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.start, |
cls.hdr->nameSpace.length, |
cls.hdr->nameSpace.size, |
rep->u); | rep->u); |
} | } |
else | else |
|
|
&cls.mem, | &cls.mem, |
rep->type, | rep->type, |
cls.hdr->nameSpace.start, | cls.hdr->nameSpace.start, |
cls.hdr->nameSpace.length, |
cls.hdr->nameSpace.size, |
rep->u); | rep->u); |
} | } |
} | } |
|
|
(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, |
|
|
inst.base = 0; | inst.base = 0; |
} | } |
| |
SCMOInstance::SCMOInstance(SCMOClass baseClass) |
SCMOInstance::SCMOInstance(SCMOClass& baseClass) |
{ | { |
_initSCMOInstance(new SCMOClass(baseClass)); | _initSCMOInstance(new SCMOClass(baseClass)); |
} | } |
| |
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)); |
|
|
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) |
{ | { |
_initSCMOInstance(new SCMOClass(baseClass)); | _initSCMOInstance(new SCMOClass(baseClass)); |
| |
_setCIMObjectPath(cimObj); | _setCIMObjectPath(cimObj); |
} | } |
| |
SCMOInstance::SCMOInstance(SCMOClass baseClass, const CIMInstance& cimInstance) |
SCMOInstance::SCMOInstance(SCMOClass& baseClass, const CIMInstance& cimInstance) |
{ | { |
| |
_initSCMOInstance(new SCMOClass(baseClass)); | _initSCMOInstance(new SCMOClass(baseClass)); |
|
|
| |
} | } |
| |
|
SCMOInstance::SCMOInstance(CIMClass& theCIMClass, const char* altNameSpace) |
void SCMOInstance::_copyExternalReferences() |
|
{ | { |
// TODO: Has to be optimized not to loop through all props. |
_initSCMOInstance(new SCMOClass(theCIMClass,altNameSpace)); |
// create a pointer to keybinding node array of the class. |
|
Uint64 idx = inst.hdr->theClass->cls.hdr->keyBindingSet.nodeArray.start; |
|
SCMBKeyBindingNode* theClassKeyBindNodeArray = |
|
(SCMBKeyBindingNode*)&((inst.hdr->theClass->cls.base)[idx]); |
|
| |
// 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++) |
SCMOInstance::SCMOInstance( |
{ |
const CIMInstance& cimInstance, |
if (theInstanceKeyBindingNodeArray[i].isSet) |
const char* altNameSpace, |
|
Uint32 altNSLen) |
|
{ |
|
SCMOClass theSCMOClass = _getSCMOClass( |
|
cimInstance._rep->_reference, |
|
altNameSpace, |
|
altNSLen); |
|
|
|
_initSCMOInstance( new SCMOClass(theSCMOClass)); |
|
|
|
if(theSCMOClass.isEmpty()) |
{ | { |
// only references can be a key binding. |
// flag the instance as compromized |
if (theClassKeyBindNodeArray[i].type == CIMTYPE_REFERENCE) |
inst.hdr->flags.isCompromised=true; |
|
} |
|
else |
{ | { |
// Use the copy constructro to ref. count the reference. |
_setCIMInstance(cimInstance); |
// These objects are handeld by the SCMOInstance it sef. |
|
// No one can modify these instances. |
|
theInstanceKeyBindingNodeArray[i].data.extRefPtr = |
|
new SCMOInstance( |
|
*theInstanceKeyBindingNodeArray[i].data.extRefPtr); |
|
} | } |
} | } |
}// for all key bindings defined in the class |
|
| |
// Are there user defined key bindings ? |
SCMOInstance::SCMOInstance( |
if (0 != inst.hdr->numberUserKeyBindindigs) |
const CIMObject& cimObject, |
|
const char* altNameSpace, |
|
Uint32 altNSLen) |
{ | { |
SCMBUserKeyBindingElement* theUserDefKBElement = |
if (cimObject.isClass()) |
(SCMBUserKeyBindingElement*) |
{ |
&(inst.base[inst.hdr->userKeyBindingElement.start]); |
CIMClass cimClass(cimObject); |
| |
for(Uint32 i = 0; i < inst.hdr->numberUserKeyBindindigs; i++) |
_initSCMOInstance(new SCMOClass(cimClass,altNameSpace)); |
|
|
|
inst.hdr->flags.isClassOnly=true; |
|
} |
|
else |
{ | { |
if (theUserDefKBElement->value.isSet) |
CIMInstance cimInstance(cimObject); |
|
|
|
SCMOClass theSCMOClass = _getSCMOClass( |
|
cimInstance._rep->_reference, |
|
altNameSpace, |
|
altNSLen); |
|
|
|
_initSCMOInstance( new SCMOClass(theSCMOClass)); |
|
|
|
if(theSCMOClass.isEmpty()) |
{ | { |
// only references can be a key binding. |
// flag the instance as compromized |
if (theUserDefKBElement->type == CIMTYPE_REFERENCE) |
inst.hdr->flags.isCompromised=true; |
|
} |
|
else |
{ | { |
// Use the copy constructro to ref. count the reference. |
_setCIMInstance(cimInstance); |
// These objects are handeld by the SCMOInstance it sef. |
|
// No one can modify these instances. |
|
theUserDefKBElement->value.data.extRefPtr = |
|
new SCMOInstance( |
|
*theUserDefKBElement->value.data.extRefPtr); |
|
} | } |
} | } |
|
|
theUserDefKBElement = |
|
(SCMBUserKeyBindingElement*) |
|
&(inst.base[theUserDefKBElement->nextElement.start]); |
|
} // for all user def. key bindings. |
|
} | } |
| |
SCMBValue* theInstPropArray = |
SCMOInstance::SCMOInstance( |
(SCMBValue*)&(inst.base[inst.hdr->propertyArray.start]); |
const CIMObjectPath& cimObj, |
|
const char* altNameSpace, |
|
Uint32 altNSLen) |
|
{ |
|
SCMOClass theSCMOClass = _getSCMOClass( |
|
cimObj, |
|
altNameSpace, |
|
altNSLen); |
| |
for (Uint32 i = 0; i < inst.hdr->numberProperties; i++) |
_initSCMOInstance( new SCMOClass(theSCMOClass)); |
{ |
|
// was the property set by the provider ? |
if(theSCMOClass.isEmpty()) |
if(theInstPropArray[i].flags.isSet) |
|
{ |
|
// is the property type reference,instance or object? |
|
if (theInstPropArray[i].valueType == CIMTYPE_REFERENCE || |
|
theInstPropArray[i].valueType == CIMTYPE_OBJECT || |
|
theInstPropArray[i].valueType == CIMTYPE_INSTANCE ) |
|
{ |
|
if (theInstPropArray[i].flags.isArray) |
|
{ | { |
_copyArrayExtReference( |
// flag the instance as compromized |
theInstPropArray[i].value.arrayValue, |
inst.hdr->flags.isCompromised=true; |
&inst.mem); |
|
} | } |
else | else |
{ | { |
theInstPropArray[i].value.extRefPtr = |
_setCIMObjectPath(cimObj); |
new SCMOInstance(*theInstPropArray[i].value.extRefPtr); |
} |
} // end is arry |
|
} // end is reference |
|
}// end is set |
|
} // for all properties. |
|
} | } |
| |
void SCMOInstance::_destroyExternalReferences() | void SCMOInstance::_destroyExternalReferences() |
{ | { |
// TODO: Has to be optimized not to loop through all props. |
_destroyExternalReferencesInternal(inst.mem); |
// create a pointer to keybinding node array of the class. |
} |
Uint64 idx = inst.hdr->theClass->cls.hdr->keyBindingSet.nodeArray.start; |
|
SCMBKeyBindingNode* theClassKeyBindNodeArray = |
|
(SCMBKeyBindingNode*)&((inst.hdr->theClass->cls.base)[idx]); |
|
| |
// create a pointer to instanc key binding array. |
SCMOClass SCMOInstance::_getSCMOClass( |
SCMBKeyBindingValue* theInstanceKeyBindingNodeArray = |
const CIMObjectPath& theCIMObj, |
(SCMBKeyBindingValue*)&(inst.base[inst.hdr->keyBindingArray.start]); |
const char* altNS, |
|
Uint32 altNSlength) |
|
{ |
|
SCMOClass theClass; |
| |
for (Uint32 i = 0; i < inst.hdr->numberKeyBindings; i++) |
if (theCIMObj.getClassName().isNull()) |
{ | { |
if (theInstanceKeyBindingNodeArray[i].isSet) |
return SCMOClass(); |
|
} |
|
|
|
if (theCIMObj.getNameSpace().isNull()) |
{ | { |
// only references can be a key binding |
// the name space of the object path is empty, |
if (theClassKeyBindNodeArray[i].type == CIMTYPE_REFERENCE) |
// use alternative name space. |
|
CString clsName = theCIMObj.getClassName().getString().getCString(); |
|
|
|
SCMOClassCache* theCache = SCMOClassCache::getInstance(); |
|
theClass = theCache->getSCMOClass( |
|
altNS, |
|
altNSlength, |
|
(const char*)clsName, |
|
strlen(clsName)); |
|
} |
|
else |
{ | { |
delete theInstanceKeyBindingNodeArray[i].data.extRefPtr; |
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; |
} | } |
}// for all key bindings |
|
| |
// Are there user defined key bindings ? |
#define PEGASUS_SIZE_REFERENCE_INDEX_ARRAY 8 |
if (0 != inst.hdr->numberUserKeyBindindigs) |
|
{ |
|
SCMBUserKeyBindingElement* theUserDefKBElement = |
|
(SCMBUserKeyBindingElement*) |
|
&(inst.base[inst.hdr->userKeyBindingElement.start]); |
|
| |
for(Uint32 i = 0; i < inst.hdr->numberUserKeyBindindigs; i++) |
void SCMOInstance::_setExtRefIndex(SCMBUnion* pInst, SCMBMgmt_Header** pmem) |
{ | { |
if (theUserDefKBElement->value.isSet) |
|
|
Uint64 refPtr =(((char *)pInst) - (char *)(*pmem)); |
|
SCMBMgmt_Header* memHdr = (*pmem); |
|
// Save the number of external references in the array |
|
Uint32 noExtRef = memHdr->numberExtRef; |
|
|
|
// Allocate the external reflerence array |
|
// if it is full or empty ( 0 == 0 ). |
|
if (noExtRef == memHdr->sizeExtRefIndexArray) |
{ | { |
// only references can be a key binding. |
Uint64 oldArrayStart = memHdr->extRefIndexArray.start; |
if (theUserDefKBElement->type == CIMTYPE_REFERENCE) |
Uint32 newSize = |
|
memHdr->sizeExtRefIndexArray + PEGASUS_SIZE_REFERENCE_INDEX_ARRAY; |
|
|
|
// Allocate the external reference index array |
|
_getFreeSpace( |
|
memHdr->extRefIndexArray, |
|
sizeof(Uint64)*newSize, |
|
pmem); |
|
|
|
// reset the pointer. It could be changed due to reallocation ! |
|
memHdr = (*pmem); |
|
|
|
// Assign new size. |
|
memHdr->sizeExtRefIndexArray=newSize; |
|
|
|
// Get absolute pointer to old index array. |
|
Uint64* oldArray = (Uint64*)&(((char*)(*pmem))[oldArrayStart]); |
|
// Get absolute pointer to new index array |
|
Uint64* newArray = |
|
(Uint64*)&(((char*)(*pmem))[memHdr->extRefIndexArray.start]); |
|
|
|
// Copy all elements of the old array to the new. |
|
// If noExtRef = 0, no elements are copied. |
|
for (Uint32 i = 0 ; i < noExtRef ; i++) |
{ | { |
delete theUserDefKBElement->value.data.extRefPtr; |
newArray[i] = oldArray[i]; |
} | } |
} | } |
| |
theUserDefKBElement = |
// Get absolute pointer to the array |
(SCMBUserKeyBindingElement*) |
Uint64* array = |
&(inst.base[theUserDefKBElement->nextElement.start]); |
(Uint64*)&(((char*)(*pmem))[memHdr->extRefIndexArray.start]); |
} // for all user def. key bindings. |
// look in the table if the index is already in the array |
|
for (Uint32 i = 0 ; i < noExtRef ; i++) |
|
{ |
|
// is the index already part of the array |
|
if (array[i] == refPtr) |
|
{ |
|
// leave. |
|
return; |
} | } |
|
} |
|
// 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++; |
| |
SCMBValue* theInstPropArray = |
} |
(SCMBValue*)&(inst.base[inst.hdr->propertyArray.start]); |
|
| |
for (Uint32 i = 0; i < inst.hdr->numberProperties; i++) |
SCMOInstance* SCMOInstance::getExtRef(Uint32 idx) const |
{ | { |
// was the property set by the provider ? |
Uint64* array = |
if(theInstPropArray[i].flags.isSet) |
(Uint64*)&(inst.base[inst.mem->extRefIndexArray.start]); |
|
SCMBUnion* pUnion; |
|
pUnion = (SCMBUnion*)(&(inst.base[array[idx]])); |
|
return pUnion->extRefPtr; |
|
} |
|
|
|
void SCMOInstance::putExtRef(Uint32 idx,SCMOInstance* ptr) |
|
{ |
|
Uint64* array = |
|
(Uint64*)&(inst.base[inst.mem->extRefIndexArray.start]); |
|
SCMBUnion* pUnion; |
|
pUnion = (SCMBUnion*)(&(inst.base[array[idx]])); |
|
pUnion->extRefPtr = ptr; |
|
} |
|
|
|
void SCMOInstance::_copyExternalReferences() |
{ | { |
// is the property type reference,instance or object? |
Uint32 number = inst.mem->numberExtRef; |
if (theInstPropArray[i].valueType == CIMTYPE_REFERENCE || |
|
theInstPropArray[i].valueType == CIMTYPE_OBJECT || |
if (0 != number) |
theInstPropArray[i].valueType == CIMTYPE_INSTANCE ) |
|
{ | { |
if (theInstPropArray[i].flags.isArray) |
SCMBUnion* pUnion; |
|
Uint64* array = |
|
(Uint64*)&(inst.base[inst.mem->extRefIndexArray.start]); |
|
for (Uint32 i = 0; i < number; i++) |
{ | { |
_deleteArrayExtReference( |
pUnion = (SCMBUnion*)(&(inst.base[array[i]])); |
theInstPropArray[i].value.arrayValue, |
if (0 != pUnion) |
&inst.mem); |
{ |
|
pUnion->extRefPtr = new SCMOInstance(*(pUnion->extRefPtr)); |
} | } |
else |
} |
|
|
|
} |
|
|
|
} |
|
|
|
void SCMOInstance::_destroyExternalKeyBindings() |
|
{ |
|
// Create a pointer to keybinding 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]); |
|
|
|
// 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++) |
{ | { |
delete theInstPropArray[i].value.extRefPtr; |
if (theInstanceKeyBindingNodeArray[i].isSet) |
} // end is arry |
{ |
} // end is reference |
// only references can be a key binding |
}// end is set |
if (theClassKeyBindNodeArray[i].type == CIMTYPE_REFERENCE) |
} // for all properties. |
{ |
|
_deleteExternalReferenceInternal( |
|
inst.mem, |
|
theInstanceKeyBindingNodeArray[i].data.extRefPtr); |
|
} |
|
} |
|
}// for all key bindings |
|
|
|
// 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) |
|
{ |
|
// only references can be a key binding. |
|
if (theUserDefKBElement->type == CIMTYPE_REFERENCE) |
|
{ |
|
_deleteExternalReferenceInternal( |
|
inst.mem, |
|
theUserDefKBElement->value.data.extRefPtr); |
|
} |
|
} |
|
|
|
theUserDefKBElement = |
|
(SCMBUserKeyBindingElement*) |
|
&(inst.base[theUserDefKBElement->nextElement.start]); |
|
} // for all user def. key bindings. |
|
} |
} | } |
| |
SCMO_RC SCMOInstance::getCIMInstance(CIMInstance& cimInstance) const | SCMO_RC SCMOInstance::getCIMInstance(CIMInstance& cimInstance) const |
{ | { |
| |
SCMO_RC rc = SCMO_OK; | SCMO_RC rc = SCMO_OK; |
Uint32 noProps; |
|
CIMObjectPath objPath; | CIMObjectPath objPath; |
| |
// For better usability define pointers to SCMO Class data structures. | // For better usability define pointers to SCMO Class data structures. |
SCMBClass_Main* clshdr = inst.hdr->theClass->cls.hdr; |
SCMBClass_Main* clshdr = inst.hdr->theClass.ptr->cls.hdr; |
char* clsbase = inst.hdr->theClass->cls.base; |
char* clsbase = inst.hdr->theClass.ptr->cls.base; |
| |
getCIMObjectPath(objPath); | getCIMObjectPath(objPath); |
| |
|
|
} | } |
} | } |
| |
if (inst.hdr->flags.isFiltered) |
if (inst.hdr->flags.exportSetOnly) |
{ |
|
// 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 |
|
{ | { |
for(Uint32 i = 0, k = inst.hdr->numberProperties; i<k; i++) | for(Uint32 i = 0, k = inst.hdr->numberProperties; i<k; i++) |
{ | { |
|
|
newInstance._rep->_properties.append(theProperty); | newInstance._rep->_properties.append(theProperty); |
} | } |
} | } |
|
} |
|
else |
|
{ |
|
for(Uint32 i = 0, k = inst.hdr->numberProperties; i<k; i++) |
|
{ |
|
// Set all properties in the CIMInstance gegarding they |
|
// are part of the SCMOInstance or the SCMOClass. |
|
CIMProperty theProperty=_getCIMPropertyAtNodeIndex(i); |
| |
|
newInstance._rep->_properties.append(theProperty); |
|
} |
} | } |
| |
cimInstance = newInstance; | cimInstance = newInstance; |
|
|
| |
void SCMOInstance::getCIMObjectPath(CIMObjectPath& cimObj) const | void SCMOInstance::getCIMObjectPath(CIMObjectPath& cimObj) const |
{ | { |
|
Array<CIMKeyBinding> keys; |
CIMObjectPath newObjectPath; |
|
| |
// For better usability define pointers to SCMO Class data structures. | // For better usability define pointers to SCMO Class data structures. |
SCMBClass_Main* clshdr = inst.hdr->theClass->cls.hdr; |
SCMBClass_Main* clshdr = inst.hdr->theClass.ptr->cls.hdr; |
char* clsbase = inst.hdr->theClass->cls.base; |
char* clsbase = inst.hdr->theClass.ptr->cls.base; |
| |
// Address the class keybinding information | // Address the class keybinding information |
SCMBKeyBindingNode* scmoClassArray = | SCMBKeyBindingNode* scmoClassArray = |
|
|
0, | 0, |
scmoInstArray[i].data, | scmoInstArray[i].data, |
inst.base); | inst.base); |
newObjectPath._rep->_keyBindings.append( |
keys.append( |
CIMKeyBinding( | CIMKeyBinding( |
CIMNameCast(NEWCIMSTR(scmoClassArray[i].name,clsbase)), |
CIMNameCast(_newCimString(scmoClassArray[i].name,clsbase)), |
theKeyBindingValue | theKeyBindingValue |
)); | )); |
} | } |
} | } |
| |
// Are there user defined key bindings ? | // Are there user defined key bindings ? |
if (0 != inst.hdr->numberUserKeyBindindigs) |
if (0 != inst.hdr->numberUserKeyBindings) |
{ | { |
SCMBUserKeyBindingElement* theUserDefKBElement = | SCMBUserKeyBindingElement* theUserDefKBElement = |
(SCMBUserKeyBindingElement*) | (SCMBUserKeyBindingElement*) |
&(inst.base[inst.hdr->userKeyBindingElement.start]); | &(inst.base[inst.hdr->userKeyBindingElement.start]); |
| |
for(Uint32 i = 0; i < inst.hdr->numberUserKeyBindindigs; i++) |
for(Uint32 i = 0; i < inst.hdr->numberUserKeyBindings; i++) |
{ | { |
if (theUserDefKBElement->value.isSet) | if (theUserDefKBElement->value.isSet) |
{ | { |
|
|
theUserDefKBElement->value.data, | theUserDefKBElement->value.data, |
inst.base); | inst.base); |
| |
newObjectPath._rep->_keyBindings.append( |
keys.append( |
CIMKeyBinding( | CIMKeyBinding( |
CIMNameCast( | CIMNameCast( |
NEWCIMSTR(theUserDefKBElement->name,inst.base)), |
_newCimString(theUserDefKBElement->name,inst.base)), |
theKeyBindingValue)); | theKeyBindingValue)); |
} | } |
theUserDefKBElement = | theUserDefKBElement = |
|
|
} // for all user def. key bindings. | } // for all user def. key bindings. |
} | } |
| |
newObjectPath._rep->_host = NEWCIMSTR(inst.hdr->hostName,inst.base); |
String host = _newCimString(inst.hdr->hostName,inst.base); |
|
|
// Use name space and class name of the instance | // Use name space and class name of the instance |
newObjectPath._rep->_nameSpace = |
CIMNamespaceName nameSpace = |
CIMNamespaceNameCast(NEWCIMSTR(inst.hdr->instNameSpace,inst.base)); |
CIMNamespaceNameCast(_newCimString(inst.hdr->instNameSpace,inst.base)); |
newObjectPath._rep->_className= |
|
CIMNameCast(NEWCIMSTR(inst.hdr->instClassName,inst.base)); |
CIMName className = |
|
CIMNameCast(_newCimString(inst.hdr->instClassName,inst.base)); |
| |
cimObj = newObjectPath; |
cimObj.set(host,nameSpace,className,keys); |
} | } |
| |
CIMProperty SCMOInstance::_getCIMPropertyAtNodeIndex(Uint32 nodeIdx) const | CIMProperty SCMOInstance::_getCIMPropertyAtNodeIndex(Uint32 nodeIdx) const |
|
|
CIMProperty retProperty; | CIMProperty retProperty; |
| |
// For better usability define pointers to SCMO Class data structures. | // For better usability define pointers to SCMO Class data structures. |
SCMBClass_Main* clshdr = inst.hdr->theClass->cls.hdr; |
SCMBClass_Main* clshdr = inst.hdr->theClass.ptr->cls.hdr; |
char* clsbase = inst.hdr->theClass->cls.base; |
char* clsbase = inst.hdr->theClass.ptr->cls.base; |
| |
| |
SCMBClassPropertyNode& clsProp = | SCMBClassPropertyNode& clsProp = |
|
|
SCMBValue& instValue = | SCMBValue& instValue = |
((SCMBValue*)&(inst.base[inst.hdr->propertyArray.start]))[nodeIdx]; | ((SCMBValue*)&(inst.base[inst.hdr->propertyArray.start]))[nodeIdx]; |
| |
|
if (instValue.flags.isSet) |
|
{ |
_getCIMValueFromSCMBValue(theValue,instValue,inst.base); | _getCIMValueFromSCMBValue(theValue,instValue,inst.base); |
|
} |
|
else |
|
{ |
|
_getCIMValueFromSCMBValue( |
|
theValue, |
|
clsProp.theProperty.defaultValue, |
|
clsbase); |
|
} |
|
|
| |
| |
if (inst.hdr->flags.includeClassOrigin) | if (inst.hdr->flags.includeClassOrigin) |
{ | { |
retProperty = CIMProperty( | retProperty = CIMProperty( |
CIMNameCast(NEWCIMSTR(clsProp.theProperty.name,clsbase)), |
CIMNameCast(_newCimString(clsProp.theProperty.name,clsbase)), |
theValue, | theValue, |
theValue.getArraySize(), | theValue.getArraySize(), |
CIMNameCast(NEWCIMSTR(clsProp.theProperty.refClassName,clsbase)), |
CIMNameCast( |
CIMNameCast(NEWCIMSTR(clsProp.theProperty.originClassName,clsbase)), |
_newCimString(clsProp.theProperty.refClassName,clsbase)), |
|
CIMNameCast( |
|
_newCimString(clsProp.theProperty.originClassName,clsbase)), |
clsProp.theProperty.flags.propagated); | clsProp.theProperty.flags.propagated); |
} | } |
else | else |
{ | { |
retProperty = CIMProperty( | retProperty = CIMProperty( |
CIMNameCast(NEWCIMSTR(clsProp.theProperty.name,clsbase)), |
CIMNameCast(_newCimString(clsProp.theProperty.name,clsbase)), |
theValue, | theValue, |
theValue.getArraySize(), | theValue.getArraySize(), |
CIMNameCast(NEWCIMSTR(clsProp.theProperty.refClassName,clsbase)), |
CIMNameCast( |
|
_newCimString(clsProp.theProperty.refClassName,clsbase)), |
CIMName(), | CIMName(), |
clsProp.theProperty.flags.propagated); | clsProp.theProperty.flags.propagated); |
} | } |
|
|
Array<Char16> x; | Array<Char16> x; |
for (Uint32 i = 0, k = arraySize; i < k ; i++) | for (Uint32 i = 0, k = arraySize; i < k ; i++) |
{ | { |
x.append(pscmbArrayUn[i].simple.val.c16); |
x.append(Char16(pscmbArrayUn[i].simple.val.c16)); |
} | } |
cimV.set(x); | cimV.set(x); |
} | } |
else | else |
{ | { |
cimV.set(scmbUn.simple.val.c16); |
cimV.set(Char16(scmbUn.simple.val.c16)); |
} | } |
break; | break; |
} | } |
|
|
| |
for (Uint32 i = 0, k = arraySize; i < k ; i++) | for (Uint32 i = 0, k = arraySize; i < k ; i++) |
{ | { |
x.append(NEWCIMSTR(pscmbArrayUn[i].stringValue,base)); |
x.append(_newCimString(pscmbArrayUn[i].stringValue,base)); |
} | } |
cimV.set(x); | cimV.set(x); |
} | } |
else | else |
{ | { |
cimV.set(NEWCIMSTR(scmbUn.stringValue,base)); |
cimV.set(_newCimString(scmbUn.stringValue,base)); |
} | } |
break; | break; |
} | } |
|
|
} | } |
case CIMTYPE_OBJECT: | case CIMTYPE_OBJECT: |
{ | { |
CIMInstance theInstance; |
CIMInstance cimInstance; |
CIMClass theClass; |
CIMClass cimClass; |
| |
if(isArray) | if(isArray) |
{ | { |
|
|
inst.hdr->flags.isClassOnly) | inst.hdr->flags.isClassOnly) |
{ | { |
pscmbArrayUn[i].extRefPtr-> | pscmbArrayUn[i].extRefPtr-> |
inst.hdr->theClass->getCIMClass(theClass); |
inst.hdr->theClass.ptr->getCIMClass(cimClass); |
x.append(CIMObject(theClass)); |
x.append(CIMObject(cimClass)); |
} | } |
else | else |
{ | { |
pscmbArrayUn[i].extRefPtr-> | pscmbArrayUn[i].extRefPtr-> |
getCIMInstance(theInstance); |
getCIMInstance(cimInstance); |
x.append(CIMObject(theInstance)); |
x.append(CIMObject(cimInstance)); |
} | } |
} | } |
else | else |
|
|
if(scmbUn.extRefPtr->inst.hdr->flags.isClassOnly) | if(scmbUn.extRefPtr->inst.hdr->flags.isClassOnly) |
{ | { |
scmbUn.extRefPtr-> | scmbUn.extRefPtr-> |
inst.hdr->theClass->getCIMClass(theClass); |
inst.hdr->theClass.ptr->getCIMClass(cimClass); |
cimV.set(CIMObject(theClass)); |
cimV.set(CIMObject(cimClass)); |
} | } |
else | else |
{ | { |
scmbUn.extRefPtr->getCIMInstance(theInstance); |
scmbUn.extRefPtr->getCIMInstance(cimInstance); |
cimV.set(CIMObject(theInstance)); |
cimV.set(CIMObject(cimInstance)); |
} | } |
} | } |
else | else |
|
|
| |
void SCMOInstance::_setCIMObjectPath(const CIMObjectPath& cimObj) | void SCMOInstance::_setCIMObjectPath(const CIMObjectPath& cimObj) |
{ | { |
CIMObjectPathRep* objRep = cimObj._rep; |
CString className = cimObj.getClassName().getString().getCString(); |
SCMO_RC rc; |
|
|
|
CString className = objRep->_className.getString().getCString(); |
|
| |
// Is the instance from the same class ? | // Is the instance from the same class ? |
if (!(_equalNoCaseUTF8Strings( | if (!(_equalNoCaseUTF8Strings( |
|
|
strlen(className)))) | strlen(className)))) |
{ | { |
throw PEGASUS_CIM_EXCEPTION(CIM_ERR_INVALID_CLASS, | throw PEGASUS_CIM_EXCEPTION(CIM_ERR_INVALID_CLASS, |
objRep->_className.getString()); |
cimObj.getClassName().getString()); |
} | } |
| |
//set host name | //set host name |
_setString(objRep->_host,inst.hdr->hostName,&inst.mem ); |
_setString(cimObj.getHost(),inst.hdr->hostName,&inst.mem ); |
| |
for (Uint32 i = 0, k = objRep->_keyBindings.size(); i < k; i++) |
const Array<CIMKeyBinding> & keys=cimObj.getKeyBindings(); |
|
for (Uint32 i = 0, k = keys.size(); i < k; i++) |
{ | { |
String key = objRep->_keyBindings[i].getValue(); |
String key = keys[i].getValue(); |
rc = _setKeyBindingFromString( |
_setKeyBindingFromString( |
(const char*) |
(const char*) keys[i].getName().getString().getCString(), |
objRep->_keyBindings[i].getName().getString().getCString(), |
|
_CIMTypeFromKeyBindingType( | _CIMTypeFromKeyBindingType( |
(const char*)key.getCString(), | (const char*)key.getCString(), |
objRep->_keyBindings[i].getType()), |
keys[i].getType()), |
key); | key); |
|
|
if (rc != SCMO_OK) |
|
{ |
|
String message("Can not set CIMObjectPath key binding:'"); |
|
message.append( |
|
objRep->_keyBindings[i].getName().getString()); |
|
message.append("'"); |
|
throw CIMException(CIM_ERR_FAILED, message); |
|
} | } |
} | } |
| |
} |
|
void SCMOInstance::_setCIMValueAtNodeIndex( | void SCMOInstance::_setCIMValueAtNodeIndex( |
Uint32 node, | Uint32 node, |
CIMValueRep* valRep, | CIMValueRep* valRep, |
|
|
// Is set to the number of array members by the function. | // Is set to the number of array members by the function. |
theInstProp.valueArraySize, | theInstProp.valueArraySize, |
inst.hdr->instNameSpace.start, | inst.hdr->instNameSpace.start, |
inst.hdr->instNameSpace.length, |
inst.hdr->instNameSpace.size, |
valRep->u); | valRep->u); |
} | } |
else | else |
|
|
&inst.mem, | &inst.mem, |
realType, | realType, |
inst.hdr->instNameSpace.start, | inst.hdr->instNameSpace.start, |
inst.hdr->instNameSpace.length, |
inst.hdr->instNameSpace.size, |
valRep->u); | valRep->u); |
} | } |
} | } |
|
|
| |
void SCMOInstance::setHostName(const char* hostName) | void SCMOInstance::setHostName(const char* hostName) |
{ | { |
Uint32 len; |
Uint32 len = 0; |
|
|
|
_copyOnWrite(); |
| |
if (hostName!=0) | if (hostName!=0) |
{ | { |
| |
len = strlen((const char*)hostName); | len = strlen((const char*)hostName); |
if(len != 0) |
} |
{ |
|
|
|
// copy including trailing '\0' | // copy including trailing '\0' |
_setBinary(hostName,len+1,inst.hdr->hostName,&inst.mem); | _setBinary(hostName,len+1,inst.hdr->hostName,&inst.mem); |
return; |
|
} |
|
|
|
} |
|
inst.hdr->hostName.start=0; |
|
inst.hdr->hostName.length=0; |
|
} | } |
| |
const char* SCMOInstance::getHostName() const | const char* SCMOInstance::getHostName() const |
|
|
return _getCharString(inst.hdr->hostName,inst.base); | return _getCharString(inst.hdr->hostName,inst.base); |
} | } |
| |
const char* SCMOInstance::getHostName_l(Uint64& length) const |
const char* SCMOInstance::getHostName_l(Uint32& length) const |
|
{ |
|
length = inst.hdr->hostName.size; |
|
if (0 == length) |
{ | { |
length = inst.hdr->hostName.length; |
return 0; |
|
} |
|
else |
|
{ |
|
length--; |
|
} |
return _getCharString(inst.hdr->hostName,inst.base); | return _getCharString(inst.hdr->hostName,inst.base); |
} | } |
| |
void SCMOInstance::setClassName(const char* className) | void SCMOInstance::setClassName(const char* className) |
{ | { |
Uint32 len; |
Uint32 len=0; |
| |
|
_copyOnWrite(); |
|
|
|
// flag the instance as compromized |
|
inst.hdr->flags.isCompromised=true; |
if (className!=0) | if (className!=0) |
{ | { |
|
|
len = strlen((const char*)className); | len = strlen((const char*)className); |
if(len != 0) |
} |
{ |
|
|
|
// copy including trailing '\0' | // 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); | _setBinary(className,len+1,inst.hdr->instClassName,&inst.mem); |
return; |
|
} |
|
|
|
} | } |
| |
inst.hdr->instClassName.start=0; |
void SCMOInstance::setClassName_l(const char* className, Uint32 len) |
inst.hdr->instClassName.length=0; |
{ |
|
_copyOnWrite(); |
| |
// flag the instance as compromized |
// flag the instance as compromised |
inst.hdr->flags.isCompromised=true; | 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 | const char* SCMOInstance::getClassName() const |
|
|
return _getCharString(inst.hdr->instClassName,inst.base); | return _getCharString(inst.hdr->instClassName,inst.base); |
} | } |
| |
const char* SCMOInstance::getClassName_l(Uint64 & length) const |
const char* SCMOInstance::getClassName_l(Uint32 & length) const |
{ | { |
length = inst.hdr->instClassName.length; |
length = inst.hdr->instClassName.size; |
|
if (0 == length) |
|
{ |
|
return 0; |
|
} |
|
else |
|
{ |
|
length--; |
|
} |
return _getCharString(inst.hdr->instClassName,inst.base); | return _getCharString(inst.hdr->instClassName,inst.base); |
} | } |
| |
void SCMOInstance::setNameSpace(const char* nameSpace) | void SCMOInstance::setNameSpace(const char* nameSpace) |
{ | { |
Uint32 len; |
Uint32 len = 0; |
|
|
|
_copyOnWrite(); |
|
|
|
// flag the instance as compromized |
|
inst.hdr->flags.isCompromised=true; |
| |
if (nameSpace!=0) | if (nameSpace!=0) |
{ | { |
| |
len = strlen((const char*)nameSpace); | len = strlen((const char*)nameSpace); |
if(len != 0) |
} |
{ |
|
|
|
// copy including trailing '\0' | // copy including trailing '\0' |
_setBinary(nameSpace,len+1,inst.hdr->instNameSpace,&inst.mem); | _setBinary(nameSpace,len+1,inst.hdr->instNameSpace,&inst.mem); |
return; |
|
} | } |
| |
|
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(); |
} | } |
|
|
inst.hdr->instNameSpace.start=0; |
|
inst.hdr->instNameSpace.length=0; |
|
|
|
// flag the instance as compromized | // flag the instance as compromized |
inst.hdr->flags.isCompromised=true; | inst.hdr->flags.isCompromised=true; |
|
// copy including trailing '\0' |
|
_setBinary(nameSpace,len+1,inst.hdr->instNameSpace,&inst.mem); |
} | } |
| |
const char* SCMOInstance::getNameSpace() const | const char* SCMOInstance::getNameSpace() const |
|
|
return _getCharString(inst.hdr->instNameSpace,inst.base); | return _getCharString(inst.hdr->instNameSpace,inst.base); |
} | } |
| |
const char* SCMOInstance::getNameSpace_l(Uint64 & length) const |
const char* SCMOInstance::getNameSpace_l(Uint32 & length) const |
|
{ |
|
length = inst.hdr->instNameSpace.size; |
|
if (0 == length) |
{ | { |
length = inst.hdr->instNameSpace.length; |
return 0; |
|
} |
|
else |
|
{ |
|
length--; |
|
} |
return _getCharString(inst.hdr->instNameSpace,inst.base); | return _getCharString(inst.hdr->instNameSpace,inst.base); |
} | } |
| |
void SCMOInstance::buildKeyBindingsFromProperties() |
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* theClassKeyPropList = |
(Uint32*) &((inst.hdr->theClass->cls.base) |
(Uint32*) &((inst.hdr->theClass.ptr->cls.base) |
[(inst.hdr->theClass->cls.hdr->keyIndexList.start)]); |
[(inst.hdr->theClass.ptr->cls.hdr->keyIndexList.start)]); |
| |
SCMBKeyBindingValue* theKeyBindValueArray; |
SCMBKeyBindingValue* theKeyBindValueArray = |
SCMBValue* theInstPropNodeArray; |
(SCMBKeyBindingValue*)&(inst.base[inst.hdr->keyBindingArray.start]); |
|
SCMBValue* theInstPropNodeArray= |
|
(SCMBValue*)&inst.base[inst.hdr->propertyArray.start]; |
| |
Uint32 propNode; |
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++) |
{ | { |
// the instance pointers has to be reinitialized each time, |
|
// because in _setKeyBindingFromSCMBUnion() |
|
// a reallocation can take place. |
|
theKeyBindValueArray = |
|
(SCMBKeyBindingValue*)&inst.base[inst.hdr->keyBindingArray.start]; |
|
|
|
theInstPropNodeArray = |
|
(SCMBValue*)&inst.base[inst.hdr->propertyArray.start]; |
|
|
|
// If the keybinding is not set. | // If the keybinding is not set. |
if (!theKeyBindValueArray[i].isSet) | if (!theKeyBindValueArray[i].isSet) |
{ | { |
// get the node index for this key binding form class | // get the node index for this key binding form class |
propNode = theClassKeyPropList[i]; | propNode = theClassKeyPropList[i]; |
| |
// if property was not set by the provider or it is null. |
// if property was set by the provider and it is not null. |
if (!theInstPropNodeArray[propNode].flags.isSet || |
if ( theInstPropNodeArray[propNode].flags.isSet && |
theInstPropNodeArray[propNode].flags.isNull) |
!theInstPropNodeArray[propNode].flags.isNull) |
{ |
{ |
const char * propName = |
_copyOnWrite(); |
inst.hdr->theClass->_getPropertyNameAtNode(propNode); |
// the instance pointers have to be recalculated as copyOnWrite |
throw NoSuchProperty(String(propName)); |
// 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( | _setKeyBindingFromSCMBUnion( |
theInstPropNodeArray[propNode].valueType, | theInstPropNodeArray[propNode].valueType, |
theInstPropNodeArray[propNode].value, | theInstPropNodeArray[propNode].value, |
inst.base, | inst.base, |
theKeyBindValueArray[i]); | 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]; |
|
|
|
} |
} | } |
} | } |
} | } |
|
|
case CIMTYPE_REAL64: | case CIMTYPE_REAL64: |
case CIMTYPE_CHAR16: | case CIMTYPE_CHAR16: |
case CIMTYPE_BOOLEAN: | case CIMTYPE_BOOLEAN: |
|
{ |
|
memcpy(&keyData.data,&u,sizeof(SCMBUnion)); |
|
keyData.data.simple.hasValue=true; |
|
keyData.isSet=true; |
|
break; |
|
} |
case CIMTYPE_DATETIME: | case CIMTYPE_DATETIME: |
{ | { |
memcpy(&keyData.data,&u,sizeof(SCMBUnion)); | memcpy(&keyData.data,&u,sizeof(SCMBUnion)); |
|
|
case CIMTYPE_STRING: | case CIMTYPE_STRING: |
{ | { |
keyData.isSet=true; | 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; |
|
} |
|
|
|
} |
|
else |
|
{ |
_setBinary( | _setBinary( |
&uBase[u.stringValue.start], | &uBase[u.stringValue.start], |
u.stringValue.length, |
u.stringValue.size, |
keyData.data.stringValue, | keyData.data.stringValue, |
&inst.mem); | &inst.mem); |
|
} |
|
|
break; | break; |
} | } |
case CIMTYPE_REFERENCE: | case CIMTYPE_REFERENCE: |
|
|
if(u.extRefPtr) | if(u.extRefPtr) |
{ | { |
keyData.data.extRefPtr = new SCMOInstance(*u.extRefPtr); | keyData.data.extRefPtr = new SCMOInstance(*u.extRefPtr); |
|
keyData.isSet=true; |
|
// This function can cause a reallocation ! |
|
// Pointers can be invalid after the call. |
|
_setExtRefIndex(&(keyData.data),&inst.mem); |
} | } |
else | else |
{ | { |
|
keyData.isSet=true; |
keyData.data.extRefPtr=0; | keyData.data.extRefPtr=0; |
} | } |
keyData.isSet=true; |
|
break; | break; |
} | } |
case CIMTYPE_OBJECT: | case CIMTYPE_OBJECT: |
|
|
inst.hdr->refCount=1; | inst.hdr->refCount=1; |
| |
//Assign the SCMBClass structure this instance based on. | //Assign the SCMBClass structure this instance based on. |
inst.hdr->theClass = pClass; |
inst.hdr->theClass.ptr = pClass; |
| |
// Copy name space name and class name of the class | // Copy name space name and class name of the class |
_setBinary( | _setBinary( |
_getCharString(inst.hdr->theClass->cls.hdr->className, |
_getCharString(inst.hdr->theClass.ptr->cls.hdr->className, |
inst.hdr->theClass->cls.base), |
inst.hdr->theClass.ptr->cls.base), |
inst.hdr->theClass->cls.hdr->className.length, |
inst.hdr->theClass.ptr->cls.hdr->className.size, |
inst.hdr->instClassName, | inst.hdr->instClassName, |
&inst.mem); | &inst.mem); |
| |
_setBinary( | _setBinary( |
_getCharString(inst.hdr->theClass->cls.hdr->nameSpace, |
_getCharString(inst.hdr->theClass.ptr->cls.hdr->nameSpace, |
inst.hdr->theClass->cls.base), |
inst.hdr->theClass.ptr->cls.base), |
inst.hdr->theClass->cls.hdr->nameSpace.length, |
inst.hdr->theClass.ptr->cls.hdr->nameSpace.size, |
inst.hdr->instNameSpace, | inst.hdr->instNameSpace, |
&inst.mem); | &inst.mem); |
| |
// Number of key bindings | // Number of key bindings |
inst.hdr->numberKeyBindings = | inst.hdr->numberKeyBindings = |
inst.hdr->theClass->cls.hdr->keyBindingSet.number; |
inst.hdr->theClass.ptr->cls.hdr->keyBindingSet.number; |
| |
// Number of properties | // Number of properties |
inst.hdr->numberProperties = | inst.hdr->numberProperties = |
inst.hdr->theClass->cls.hdr->propertySet.number; |
inst.hdr->theClass.ptr->cls.hdr->propertySet.number; |
| |
// Allocate the SCMOInstanceKeyBindingArray | // Allocate the SCMOInstanceKeyBindingArray |
_getFreeSpace( | _getFreeSpace( |
inst.hdr->keyBindingArray, | inst.hdr->keyBindingArray, |
sizeof(SCMBKeyBindingValue)*inst.hdr->numberKeyBindings, | sizeof(SCMBKeyBindingValue)*inst.hdr->numberKeyBindings, |
&inst.mem, |
&inst.mem); |
true); |
|
| |
// Allocate the SCMBInstancePropertyArray | // Allocate the SCMBInstancePropertyArray |
_getFreeSpace( | _getFreeSpace( |
inst.hdr->propertyArray, | inst.hdr->propertyArray, |
sizeof(SCMBValue)*inst.hdr->numberProperties, | sizeof(SCMBValue)*inst.hdr->numberProperties, |
&inst.mem, |
&inst.mem); |
true); |
|
| |
} | } |
| |
|
|
{ | { |
CIMPropertyRep* propRep; | CIMPropertyRep* propRep; |
Uint32 propNode; | Uint32 propNode; |
Uint64 valueStart; |
|
SCMO_RC rc; | SCMO_RC rc; |
CIMType realType; | CIMType realType; |
| |
|
|
// The instance level qualifiers are stored on the associated SCMOClass. | // The instance level qualifiers are stored on the associated SCMOClass. |
inst.hdr->flags.includeQualifiers=(instRep->_qualifiers.getCount()>0); | 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); | _setCIMObjectPath(instRep->_reference); |
| |
// Copy all properties | // Copy all properties |
|
|
} | } |
| |
// get the property node index for the property | // get the property node index for the property |
rc = inst.hdr->theClass->_getProperyNodeIndex( |
rc = inst.hdr->theClass.ptr->_getProperyNodeIndex( |
propNode, | propNode, |
(const char*)propRep->_name.getString().getCString()); | (const char*)propRep->_name.getString().getCString()); |
| |
if (rc != SCMO_OK) |
if (rc == SCMO_OK) |
{ | { |
throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NO_SUCH_PROPERTY, |
|
propRep->_name.getString()); |
|
} |
|
// 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. |
rc = inst.hdr->theClass->_isNodeSameType( |
rc = inst.hdr->theClass.ptr->_isNodeSameType( |
propNode, | propNode, |
propRep->_value._rep->type, | propRep->_value._rep->type, |
propRep->_value._rep->isArray, | propRep->_value._rep->isArray, |
realType); | realType); |
if (rc == SCMO_OK) | if (rc == SCMO_OK) |
{ | { |
_setCIMValueAtNodeIndex(propNode, propRep->_value._rep,realType); |
_setCIMValueAtNodeIndex( |
|
propNode, |
|
propRep->_value._rep, |
|
realType); |
} | } |
else | else |
{ | { |
throw PEGASUS_CIM_EXCEPTION(CIM_ERR_TYPE_MISMATCH, |
PEG_TRACE((TRC_DISCARDED_DATA,Tracer::LEVEL2, |
propRep->_name.getString()); |
"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())); |
} | } |
} | } |
} | } |
|
|
isArray = false; | isArray = false; |
size = 0; | size = 0; |
| |
rc = inst.hdr->theClass->_getProperyNodeIndex(node,name); |
rc = inst.hdr->theClass.ptr->_getProperyNodeIndex(node,name); |
if (rc != SCMO_OK) | if (rc != SCMO_OK) |
{ | { |
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); |
} | } |
| |
|
|
*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::getPropertyAt( |
|
Uint32 pos, |
|
SCMBValue** value, |
|
const char ** valueBase, |
|
SCMBClassProperty ** propDef) const |
|
{ |
|
Uint32 node; |
|
// is filtering on ? |
|
if (inst.hdr->flags.isFiltered) |
|
{ |
|
// check the number of properties part of the filter |
|
if (pos >= inst.hdr->filterProperties) |
|
{ |
|
return SCMO_INDEX_OUT_OF_BOUND; |
|
} |
|
|
|
// Get absolut pointer to property filter index map of the instance |
|
Uint32* propertyFilterIndexMap = |
|
(Uint32*)&(inst.base[inst.hdr->propertyFilterIndexMap.start]); |
|
|
|
// get the real node index of the property. |
|
node = propertyFilterIndexMap[pos]; |
|
} |
|
else |
|
{ |
|
// the index is used as node index. |
|
node = pos; |
|
if (node >= inst.hdr->numberProperties) |
|
{ |
|
return SCMO_INDEX_OUT_OF_BOUND; |
|
} |
|
} |
|
|
|
SCMBValue* theInstPropNodeArray = |
|
(SCMBValue*)&(inst.base[inst.hdr->propertyArray.start]); |
|
|
|
// create a pointer to property node array of the class. |
|
Uint64 idx = inst.hdr->theClass->cls.hdr->propertySet.nodeArray.start; |
|
SCMBClassPropertyNode* theClassPropNodeArray = |
|
(SCMBClassPropertyNode*)&(inst.hdr->theClass->cls.base)[idx]; |
|
|
|
// return the absolute pointer to the property definition |
|
*propDef= &(theClassPropNodeArray[node].theProperty); |
|
|
|
// need check if property set or not, if not set use the default value |
|
if (theInstPropNodeArray[node].flags.isSet) |
|
{ |
|
// return the absolute pointer to the property value in the instance |
|
*value = &(theInstPropNodeArray[node]); |
|
*valueBase = inst.base; |
|
} | } |
else |
|
{ |
|
// return the absolute pointer to |
|
*value = &(theClassPropNodeArray[node].theProperty.defaultValue); |
|
*valueBase = inst.hdr->theClass->cls.base; |
|
} |
|
|
|
return SCMO_OK; |
|
} |
|
|
|
| |
SCMO_RC SCMOInstance::getPropertyNodeIndex(const char* name, Uint32& node) const | SCMO_RC SCMOInstance::getPropertyNodeIndex(const char* name, Uint32& node) const |
{ | { |
|
|
return SCMO_INVALID_PARAMETER; | return SCMO_INVALID_PARAMETER; |
} | } |
| |
rc = inst.hdr->theClass->_getProperyNodeIndex(node,name); |
rc = inst.hdr->theClass.ptr->_getProperyNodeIndex(node,name); |
| |
return rc; | return rc; |
| |
|
|
Uint32 size, | Uint32 size, |
const char* origin) | const char* origin) |
{ | { |
|
// In this function no _copyOnWrite(), it does not change the instance. |
|
|
Uint32 node; | Uint32 node; |
SCMO_RC rc; | SCMO_RC rc; |
CIMType realType; | CIMType realType; |
| |
rc = inst.hdr->theClass->_getProperyNodeIndex(node,name); |
rc = inst.hdr->theClass.ptr->_getProperyNodeIndex(node,name); |
if (rc != SCMO_OK) | if (rc != SCMO_OK) |
{ | { |
return rc; | return rc; |
|
|
// 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. |
rc = inst.hdr->theClass->_isNodeSameType(node,type,isArray,realType); |
rc = inst.hdr->theClass.ptr->_isNodeSameType(node,type,isArray,realType); |
if (rc != SCMO_OK) | if (rc != SCMO_OK) |
{ | { |
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) |
{ | { |
if(!inst.hdr->theClass->_isSamePropOrigin(node,origin)) |
if(!inst.hdr->theClass.ptr->_isSamePropOrigin(node,origin)) |
{ | { |
return SCMO_NOT_SAME_ORIGIN; | return SCMO_NOT_SAME_ORIGIN; |
} | } |
|
|
Boolean isArray, | Boolean isArray, |
Uint32 size) | Uint32 size) |
{ | { |
|
// In this function no _copyOnWrite(), it does not change the instance. |
|
|
SCMO_RC rc; | SCMO_RC rc; |
CIMType realType; | CIMType realType; |
| |
|
|
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. |
rc = inst.hdr->theClass->_isNodeSameType(node,type,isArray,realType); |
rc = inst.hdr->theClass.ptr->_isNodeSameType(node,type,isArray,realType); |
if (rc != SCMO_OK) | if (rc != SCMO_OK) |
{ | { |
return rc; | return rc; |
|
|
Boolean isArray, | Boolean isArray, |
Uint32 size) | Uint32 size) |
{ | { |
|
|
|
_copyOnWrite(); |
|
|
SCMBValue* theInstPropNodeArray = | SCMBValue* theInstPropNodeArray = |
(SCMBValue*)&(inst.base[inst.hdr->propertyArray.start]); | (SCMBValue*)&(inst.base[inst.hdr->propertyArray.start]); |
| |
|
|
} | } |
else | else |
{ | { |
|
theInstPropNodeArray[node].flags.isNull=false; |
_setSCMBUnion( | _setSCMBUnion( |
pInVal, | pInVal, |
type, | type, |
|
|
case CIMTYPE_REAL32: | case CIMTYPE_REAL32: |
case CIMTYPE_REAL64: | case CIMTYPE_REAL64: |
case CIMTYPE_CHAR16: | 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: | case CIMTYPE_DATETIME: |
{ | { |
if (isArray) | if (isArray) |
|
|
else | else |
{ | { |
memcpy(&u,pInVal,sizeof(SCMBUnion)); | memcpy(&u,pInVal,sizeof(SCMBUnion)); |
|
|
} | } |
break; | break; |
} | } |
|
|
startPtr = _getFreeSpace( | startPtr = _getFreeSpace( |
u.arrayValue, | u.arrayValue, |
size*sizeof(SCMBUnion), | size*sizeof(SCMBUnion), |
&inst.mem,true); |
&inst.mem); |
| |
for (Uint32 i = 0; i < size; i++) | for (Uint32 i = 0; i < size; i++) |
{ | { |
|
|
startPtr = _getFreeSpace( | startPtr = _getFreeSpace( |
u.arrayValue, | u.arrayValue, |
size*sizeof(SCMBUnion), | size*sizeof(SCMBUnion), |
&inst.mem,false); |
&inst.mem); |
| |
ptr = (SCMBUnion*)&(inst.base[startPtr]); | ptr = (SCMBUnion*)&(inst.base[startPtr]); |
| |
|
|
{ | { |
ptr[i].extRefPtr= | ptr[i].extRefPtr= |
new SCMOInstance(*(pInVal[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 | else |
{ | { |
|
|
if(pInVal->extRefPtr) | if(pInVal->extRefPtr) |
{ | { |
u.extRefPtr = new SCMOInstance(*(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 | else |
{ | { |
|
|
CIMType type, | CIMType type, |
Uint32& n, | Uint32& n, |
Uint64 startNS, | Uint64 startNS, |
Uint64 lenNS, |
Uint32 sizeNS, |
Union& u) | Union& u) |
{ | { |
SCMBUnion* scmoUnion = (SCMBUnion*)&(((char*)*pmem)[start]); | SCMBUnion* scmoUnion = (SCMBUnion*)&(((char*)*pmem)[start]); |
|
|
arrayStart = _getFreeSpace( | arrayStart = _getFreeSpace( |
scmoUnion->arrayValue, | scmoUnion->arrayValue, |
loop*sizeof(SCMBUnion), | loop*sizeof(SCMBUnion), |
pmem, |
pmem); |
true); |
|
| |
ConstArrayIterator<Boolean> iterator(*x); | ConstArrayIterator<Boolean> iterator(*x); |
| |
|
|
arrayStart = _getFreeSpace( | arrayStart = _getFreeSpace( |
scmoUnion->arrayValue, | scmoUnion->arrayValue, |
loop*sizeof(SCMBUnion), | loop*sizeof(SCMBUnion), |
pmem, |
pmem); |
true); |
|
| |
ConstArrayIterator<Uint8> iterator(*x); | ConstArrayIterator<Uint8> iterator(*x); |
| |
|
|
arrayStart = _getFreeSpace( | arrayStart = _getFreeSpace( |
scmoUnion->arrayValue, | scmoUnion->arrayValue, |
loop*sizeof(SCMBUnion), | loop*sizeof(SCMBUnion), |
pmem, |
pmem); |
true); |
|
| |
ConstArrayIterator<Sint8> iterator(*x); | ConstArrayIterator<Sint8> iterator(*x); |
| |
|
|
arrayStart = _getFreeSpace( | arrayStart = _getFreeSpace( |
scmoUnion->arrayValue, | scmoUnion->arrayValue, |
loop*sizeof(SCMBUnion), | loop*sizeof(SCMBUnion), |
pmem, |
pmem); |
true); |
|
| |
ConstArrayIterator<Uint16> iterator(*x); | ConstArrayIterator<Uint16> iterator(*x); |
| |
|
|
arrayStart = _getFreeSpace( | arrayStart = _getFreeSpace( |
scmoUnion->arrayValue, | scmoUnion->arrayValue, |
loop*sizeof(SCMBUnion), | loop*sizeof(SCMBUnion), |
pmem, |
pmem); |
true); |
|
| |
ConstArrayIterator<Sint16> iterator(*x); | ConstArrayIterator<Sint16> iterator(*x); |
| |
|
|
arrayStart = _getFreeSpace( | arrayStart = _getFreeSpace( |
scmoUnion->arrayValue, | scmoUnion->arrayValue, |
loop*sizeof(SCMBUnion), | loop*sizeof(SCMBUnion), |
pmem, |
pmem); |
true); |
|
| |
ConstArrayIterator<Uint32> iterator(*x); | ConstArrayIterator<Uint32> iterator(*x); |
| |
|
|
arrayStart = _getFreeSpace( | arrayStart = _getFreeSpace( |
scmoUnion->arrayValue, | scmoUnion->arrayValue, |
loop*sizeof(SCMBUnion), | loop*sizeof(SCMBUnion), |
pmem, |
pmem); |
true); |
|
| |
ConstArrayIterator<Sint32> iterator(*x); | ConstArrayIterator<Sint32> iterator(*x); |
| |
|
|
arrayStart = _getFreeSpace( | arrayStart = _getFreeSpace( |
scmoUnion->arrayValue, | scmoUnion->arrayValue, |
loop*sizeof(SCMBUnion), | loop*sizeof(SCMBUnion), |
pmem, |
pmem); |
true); |
|
| |
ConstArrayIterator<Uint64> iterator(*x); | ConstArrayIterator<Uint64> iterator(*x); |
| |
|
|
arrayStart = _getFreeSpace( | arrayStart = _getFreeSpace( |
scmoUnion->arrayValue, | scmoUnion->arrayValue, |
loop*sizeof(SCMBUnion), | loop*sizeof(SCMBUnion), |
pmem, |
pmem); |
true); |
|
| |
ConstArrayIterator<Sint64> iterator(*x); | ConstArrayIterator<Sint64> iterator(*x); |
| |
|
|
arrayStart = _getFreeSpace( | arrayStart = _getFreeSpace( |
scmoUnion->arrayValue, | scmoUnion->arrayValue, |
loop*sizeof(SCMBUnion), | loop*sizeof(SCMBUnion), |
pmem, |
pmem); |
true); |
|
| |
ConstArrayIterator<Real32> iterator(*x); | ConstArrayIterator<Real32> iterator(*x); |
| |
|
|
arrayStart = _getFreeSpace( | arrayStart = _getFreeSpace( |
scmoUnion->arrayValue, | scmoUnion->arrayValue, |
loop*sizeof(SCMBUnion), | loop*sizeof(SCMBUnion), |
pmem, |
pmem); |
true); |
|
| |
ConstArrayIterator<Real64> iterator(*x); | ConstArrayIterator<Real64> iterator(*x); |
| |
|
|
arrayStart = _getFreeSpace( | arrayStart = _getFreeSpace( |
scmoUnion->arrayValue, | scmoUnion->arrayValue, |
loop*sizeof(SCMBUnion), | loop*sizeof(SCMBUnion), |
pmem, |
pmem); |
true); |
|
| |
ConstArrayIterator<Char16> iterator(*x); | ConstArrayIterator<Char16> iterator(*x); |
| |
|
|
| |
ptargetUnion = (SCMBUnion*)(&((char*)*pmem)[arrayStart]); | ptargetUnion = (SCMBUnion*)(&((char*)*pmem)[arrayStart]); |
| |
SCMOClass* theRefClass; |
|
|
|
for (Uint32 i = 0; i < loop ; i++) | for (Uint32 i = 0; i < loop ; i++) |
{ | { |
| |
theRefClass = _getSCMOClass( |
ptargetUnion[i].extRefPtr = |
|
new SCMOInstance( |
iterator[i], | iterator[i], |
&(((const char*)*pmem)[startNS]), | &(((const char*)*pmem)[startNS]), |
lenNS); |
sizeNS-1); |
|
// Was the conversion successful? |
if (theRefClass != 0) |
if (ptargetUnion[i].extRefPtr->isEmpty()) |
{ |
|
ptargetUnion[i].extRefPtr = |
|
new SCMOInstance(*theRefClass,iterator[i]); |
|
} else |
|
{ | { |
//There is no reference class for the object path |
// N0, delete the SCMOInstance. |
|
delete ptargetUnion[i].extRefPtr; |
ptargetUnion[i].extRefPtr = 0; | ptargetUnion[i].extRefPtr = 0; |
} | } |
|
else |
|
{ |
|
_setExtRefIndex(&(ptargetUnion[i]),pmem); |
|
} |
} | } |
| |
break; | break; |
|
|
| |
ptargetUnion = (SCMBUnion*)(&((char*)*pmem)[arrayStart]); | ptargetUnion = (SCMBUnion*)(&((char*)*pmem)[arrayStart]); |
| |
SCMOClass* theRefClass; |
|
|
|
for (Uint32 i = 0; i < loop ; i++) | for (Uint32 i = 0; i < loop ; i++) |
{ | { |
if (iterator[i].isUninitialized()) | if (iterator[i].isUninitialized()) |
|
|
{ | { |
if (iterator[i].isClass()) | if (iterator[i].isClass()) |
{ | { |
CIMClass theClass(iterator[i]); |
CIMClass cimClass(iterator[i]); |
ptargetUnion[i].extRefPtr = new SCMOInstance(theClass); |
|
|
ptargetUnion[i].extRefPtr = |
|
new SCMOInstance( |
|
cimClass, |
|
(&((const char*)*pmem)[startNS])); |
// marke as class only ! | // marke as class only ! |
ptargetUnion[i].extRefPtr-> | ptargetUnion[i].extRefPtr-> |
inst.hdr->flags.isClassOnly=true; | inst.hdr->flags.isClassOnly=true; |
|
|
|
// This function can cause a reallocation ! |
|
// Pointers can be invalid after the call. |
|
_setExtRefIndex(&(ptargetUnion[i]),pmem); |
} | } |
else | else |
{ | { |
CIMInstance theInst(iterator[i]); | CIMInstance theInst(iterator[i]); |
theRefClass = _getSCMOClass( |
|
theInst.getPath(), |
|
&(((const char*)*pmem)[startNS]), |
|
lenNS); |
|
| |
if (theRefClass != 0) |
|
{ |
|
ptargetUnion[i].extRefPtr = | ptargetUnion[i].extRefPtr = |
new SCMOInstance(*theRefClass,theInst); |
new SCMOInstance( |
} else |
theInst, |
|
&(((const char*)*pmem)[startNS]), |
|
sizeNS-1); |
|
// Was the conversion successful? |
|
if (ptargetUnion[i].extRefPtr->isEmpty()) |
{ | { |
//There is no reference class for the object path |
// N0, delete the SCMOInstance. |
|
delete ptargetUnion[i].extRefPtr; |
ptargetUnion[i].extRefPtr = 0; | ptargetUnion[i].extRefPtr = 0; |
} | } |
|
else |
|
{ |
|
// This function can cause a reallocation ! |
|
// Pointers can be invalid after the call. |
|
_setExtRefIndex(&(ptargetUnion[i]),pmem); |
|
} |
} | } |
} | } |
} | } |
|
|
| |
ptargetUnion = (SCMBUnion*)(&((char*)*pmem)[arrayStart]); | ptargetUnion = (SCMBUnion*)(&((char*)*pmem)[arrayStart]); |
| |
SCMOClass* theRefClass; |
|
|
|
for (Uint32 i = 0; i < loop ; i++) | for (Uint32 i = 0; i < loop ; i++) |
{ | { |
if (iterator[i].isUninitialized()) | if (iterator[i].isUninitialized()) |
|
|
} | } |
else | else |
{ | { |
theRefClass = _getSCMOClass( |
|
iterator[i].getPath(), |
|
&(((const char*)*pmem)[startNS]), |
|
lenNS); |
|
|
|
|
|
if (theRefClass != 0) |
|
{ |
|
ptargetUnion[i].extRefPtr = | ptargetUnion[i].extRefPtr = |
new SCMOInstance(*theRefClass,iterator[i]); |
new SCMOInstance( |
} else |
iterator[i], |
|
&(((const char*)*pmem)[startNS]), |
|
sizeNS-1); |
|
// Was the conversion successful? |
|
if (ptargetUnion[i].extRefPtr->isEmpty()) |
{ | { |
//There is no reference class for the object path |
// N0, delete the SCMOInstance. |
|
delete ptargetUnion[i].extRefPtr; |
ptargetUnion[i].extRefPtr = 0; | ptargetUnion[i].extRefPtr = 0; |
} | } |
|
else |
|
{ |
|
// This function can cause a reallocation ! |
|
// Pointers can be invalid after the call. |
|
_setExtRefIndex(&(ptargetUnion[i]),pmem); |
|
} |
|
|
} | } |
} | } |
| |
|
|
SCMBMgmt_Header** pmem, | SCMBMgmt_Header** pmem, |
CIMType type, | CIMType type, |
Uint64 startNS, | Uint64 startNS, |
Uint64 lenNS, |
Uint32 sizeNS, |
Union& u) | Union& u) |
{ | { |
SCMBUnion* scmoUnion = (SCMBUnion*)&(((char*)*pmem)[start]); | SCMBUnion* scmoUnion = (SCMBUnion*)&(((char*)*pmem)[start]); |
|
|
| |
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; |
|
|
CIMObjectPath* theCIMObj = | CIMObjectPath* theCIMObj = |
(CIMObjectPath*)((void*)&u._referenceValue); | (CIMObjectPath*)((void*)&u._referenceValue); |
| |
SCMOClass* theRefClass = _getSCMOClass( |
scmoUnion->extRefPtr = |
|
new SCMOInstance( |
*theCIMObj, | *theCIMObj, |
&(((const char*)*pmem)[startNS]), | &(((const char*)*pmem)[startNS]), |
lenNS); |
sizeNS-1); |
| |
if (theRefClass != 0) |
// Was the conversion successful? |
{ |
if (scmoUnion->extRefPtr->isEmpty()) |
scmoUnion->extRefPtr = |
|
new SCMOInstance(*theRefClass,*theCIMObj); |
|
} else |
|
{ | { |
//There is no reference class for the object path |
// N0, delete the SCMOInstance. |
|
delete scmoUnion->extRefPtr; |
scmoUnion->extRefPtr = 0; | scmoUnion->extRefPtr = 0; |
} | } |
|
else |
|
{ |
|
// This function can cause a reallocation ! |
|
// Pointers can be invalid after the call. |
|
_setExtRefIndex(scmoUnion,pmem); |
|
} |
|
|
break; | break; |
} | } |
case CIMTYPE_OBJECT: | case CIMTYPE_OBJECT: |
|
|
} | } |
| |
CIMObject* theCIMObject =(CIMObject*)((void*)&u._objectValue); | CIMObject* theCIMObject =(CIMObject*)((void*)&u._objectValue); |
SCMOClass* theRefClass; |
|
| |
if (theCIMObject->isUninitialized()) | if (theCIMObject->isUninitialized()) |
{ | { |
|
|
{ | { |
if (theCIMObject->isClass()) | if (theCIMObject->isClass()) |
{ | { |
CIMClass theClass(*theCIMObject); |
CIMClass cimClass(*theCIMObject); |
scmoUnion->extRefPtr = new SCMOInstance(theClass); |
|
|
scmoUnion->extRefPtr = |
|
new SCMOInstance( |
|
cimClass, |
|
(&((const char*)*pmem)[startNS])); |
// marke as class only ! | // marke as class only ! |
scmoUnion->extRefPtr->inst.hdr->flags.isClassOnly=true; | scmoUnion->extRefPtr->inst.hdr->flags.isClassOnly=true; |
|
|
|
// This function can cause a reallocation ! |
|
// Pointers can be invalid after the call. |
|
_setExtRefIndex(scmoUnion,pmem); |
} | } |
else | else |
{ | { |
CIMInstance theInst(*theCIMObject); |
CIMInstance theCIMInst(*theCIMObject); |
theRefClass = _getSCMOClass( |
|
theInst.getPath(), |
|
&(((const char*)*pmem)[startNS]), |
|
lenNS); |
|
| |
if (theRefClass != 0) |
|
{ |
|
scmoUnion->extRefPtr = | scmoUnion->extRefPtr = |
new SCMOInstance(*theRefClass,theInst); |
new SCMOInstance( |
} else |
theCIMInst, |
|
&(((const char*)*pmem)[startNS]), |
|
sizeNS-1); |
|
|
|
// Was the conversion successful? |
|
if (scmoUnion->extRefPtr->isEmpty()) |
{ | { |
//There is no reference class for the object path |
// N0, delete the SCMOInstance. |
|
delete scmoUnion->extRefPtr; |
scmoUnion->extRefPtr = 0; | scmoUnion->extRefPtr = 0; |
} | } |
|
else |
|
{ |
|
// This function can cause a reallocation ! |
|
// Pointers can be invalid after the call. |
|
_setExtRefIndex(scmoUnion,pmem); |
|
} |
} | } |
} | } |
break; | break; |
|
|
} | } |
else | else |
{ | { |
SCMOClass* theRefClass = _getSCMOClass( |
|
theCIMInst->getPath(), |
|
&(((const char*)*pmem)[startNS]), |
|
lenNS); |
|
if (theRefClass != 0) |
|
{ |
|
scmoUnion->extRefPtr = | scmoUnion->extRefPtr = |
new SCMOInstance(*theRefClass,*theCIMInst); |
new SCMOInstance( |
} else |
*theCIMInst, |
|
&(((const char*)*pmem)[startNS]), |
|
sizeNS-1); |
|
|
|
// Was the conversion successful? |
|
if (scmoUnion->extRefPtr->isEmpty()) |
{ | { |
//There is no reference class for the object path |
// N0, delete the SCMOInstance. |
|
delete scmoUnion->extRefPtr; |
scmoUnion->extRefPtr = 0; | scmoUnion->extRefPtr = 0; |
} | } |
|
else |
|
{ |
|
// This function can cause a reallocation ! |
|
// Pointers can be invalid after the call. |
|
_setExtRefIndex(scmoUnion,pmem); |
|
} |
} | } |
break; | break; |
} | } |
|
|
(SCMBValue*)&inst.base[inst.hdr->propertyArray.start]; | (SCMBValue*)&inst.base[inst.hdr->propertyArray.start]; |
| |
// create a pointer to property node array of the class. | // create a pointer to property node array of the class. |
Uint64 idx = inst.hdr->theClass->cls.hdr->propertySet.nodeArray.start; |
Uint64 idx = inst.hdr->theClass.ptr->cls.hdr->propertySet.nodeArray.start; |
SCMBClassPropertyNode* theClassPropNodeArray = | SCMBClassPropertyNode* theClassPropNodeArray = |
(SCMBClassPropertyNode*)&(inst.hdr->theClass->cls.base)[idx]; |
(SCMBClassPropertyNode*)&(inst.hdr->theClass.ptr->cls.base)[idx]; |
| |
// the property name is always from the class. | // the property name is always from the class. |
// return the absolut pointer to the property name, | // return the absolut pointer to the property name, |
// the caller has to copy the name! | // the caller has to copy the name! |
*pname=_getCharString( | *pname=_getCharString( |
theClassPropNodeArray[node].theProperty.name, | theClassPropNodeArray[node].theProperty.name, |
inst.hdr->theClass->cls.base); |
inst.hdr->theClass.ptr->cls.base); |
| |
// the property was set by the provider. | // the property was set by the provider. |
if (theInstPropNodeArray[node].flags.isSet) | if (theInstPropNodeArray[node].flags.isSet) |
|
|
Uint64 start = | Uint64 start = |
(const char*) | (const char*) |
&(theClassPropNodeArray[node].theProperty.defaultValue.value) - | &(theClassPropNodeArray[node].theProperty.defaultValue.value) - |
(inst.hdr->theClass->cls.base); |
(inst.hdr->theClass.ptr->cls.base); |
| |
*pvalue = _resolveSCMBUnion( | *pvalue = _resolveSCMBUnion( |
type, | type, |
isArray, | isArray, |
size, | size, |
start, | start, |
(inst.hdr->theClass->cls.base) |
(inst.hdr->theClass.ptr->cls.base) |
); | ); |
| |
return SCMO_OK; | return SCMO_OK; |
|
|
if (objectPathOnly) | if (objectPathOnly) |
{ | { |
// Create a new, empty SCMOInstance | // Create a new, empty SCMOInstance |
SCMOInstance newInst(*(this->inst.hdr->theClass)); |
SCMOInstance newInst(*(this->inst.hdr->theClass.ptr)); |
| |
// Copy the host name to tha new instance- | // Copy the host name to tha new instance- |
_setBinary( | _setBinary( |
_resolveDataPtr(this->inst.hdr->hostName,this->inst.base), | _resolveDataPtr(this->inst.hdr->hostName,this->inst.base), |
this->inst.hdr->hostName.length, |
this->inst.hdr->hostName.size, |
newInst.inst.hdr->hostName, | newInst.inst.hdr->hostName, |
&newInst.inst.mem); | &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. | // Copy the key bindings to that new instance. |
this->_copyKeyBindings(newInst); | this->_copyKeyBindings(newInst); |
| |
|
|
} | } |
| |
SCMOInstance newInst; | SCMOInstance newInst; |
newInst.inst.base = (char*)malloc(this->inst.mem->totalSize); |
newInst.inst.base = inst.base; |
if (newInst.inst.base == 0 ) |
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)(); | throw PEGASUS_STD(bad_alloc)(); |
} | } |
| |
memcpy( newInst.inst.base,this->inst.base,this->inst.mem->totalSize); |
memcpy( newBase,inst.base,(size_t)inst.mem->totalSize); |
// reset the refcounter of this new instance |
|
newInst.inst.hdr->refCount = 1; |
// 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 ! | // keep the ref counter of the class correct ! |
newInst.inst.hdr->theClass = new SCMOClass(*(this->inst.hdr->theClass)); |
inst.hdr->theClass.ptr = new SCMOClass(*(inst.hdr->theClass.ptr)); |
// keep the ref count for external references | // keep the ref count for external references |
newInst._copyExternalReferences(); |
_copyExternalReferences(); |
| |
return newInst; |
|
} | } |
| |
void SCMOInstance::_copyKeyBindings(SCMOInstance& targetInst) const | void SCMOInstance::_copyKeyBindings(SCMOInstance& targetInst) const |
|
|
(SCMBKeyBindingValue*)&(inst.base[inst.hdr->keyBindingArray.start]); | (SCMBKeyBindingValue*)&(inst.base[inst.hdr->keyBindingArray.start]); |
| |
// Address the class keybinding information | // Address the class keybinding information |
const SCMBClass_Main* clshdr = inst.hdr->theClass->cls.hdr; |
const SCMBClass_Main* clshdr = inst.hdr->theClass.ptr->cls.hdr; |
const char * clsbase = inst.hdr->theClass->cls.base; |
const char * clsbase = inst.hdr->theClass.ptr->cls.base; |
SCMBKeyBindingNode* scmoClassArray = | SCMBKeyBindingNode* scmoClassArray = |
(SCMBKeyBindingNode*)&(clsbase[clshdr->keyBindingSet.nodeArray.start]); | (SCMBKeyBindingNode*)&(clsbase[clshdr->keyBindingSet.nodeArray.start]); |
| |
|
|
} | } |
| |
// Are there user defined key bindings ? | // Are there user defined key bindings ? |
if (0 != inst.hdr->numberUserKeyBindindigs) |
if (0 != inst.hdr->numberUserKeyBindings) |
{ | { |
SCMBUserKeyBindingElement* theUserDefKBElement = | SCMBUserKeyBindingElement* theUserDefKBElement = |
(SCMBUserKeyBindingElement*) | (SCMBUserKeyBindingElement*) |
&(inst.base[inst.hdr->userKeyBindingElement.start]); | &(inst.base[inst.hdr->userKeyBindingElement.start]); |
| |
for(Uint32 i = 0; i < inst.hdr->numberUserKeyBindindigs; i++) |
for(Uint32 i = 0; i < inst.hdr->numberUserKeyBindings; i++) |
{ | { |
if (theUserDefKBElement->value.isSet) | if (theUserDefKBElement->value.isSet) |
{ | { |
|
|
ptrNewElement = _getUserDefinedKeyBinding( | ptrNewElement = _getUserDefinedKeyBinding( |
_getCharString(theInsertElement.name,elementBase), | _getCharString(theInsertElement.name,elementBase), |
// lenght is without the trailing '\0' | // lenght is without the trailing '\0' |
theInsertElement.name.length-1, |
theInsertElement.name.size-1, |
theInsertElement.type); | theInsertElement.type); |
| |
// Copy the data | // Copy the data |
|
|
// to the next element of the new element. | // to the next element of the new element. |
ptrNewElement->nextElement.start = | ptrNewElement->nextElement.start = |
inst.hdr->userKeyBindingElement.start; | inst.hdr->userKeyBindingElement.start; |
ptrNewElement->nextElement.length = |
ptrNewElement->nextElement.size = |
inst.hdr->userKeyBindingElement.length; |
inst.hdr->userKeyBindingElement.size; |
// - Assing the the new element | // - Assing the the new element |
// to the start point of user key binding element chain | // to the start point of user key binding element chain |
inst.hdr->userKeyBindingElement.start = newElement.start; | inst.hdr->userKeyBindingElement.start = newElement.start; |
inst.hdr->userKeyBindingElement.length = newElement.length; |
inst.hdr->userKeyBindingElement.size = newElement.size; |
// Adjust the couter of user defined key bindings. | // Adjust the couter of user defined key bindings. |
inst.hdr->numberUserKeyBindindigs++; |
inst.hdr->numberUserKeyBindings++; |
| |
| |
// Copy the type | // Copy the type |
|
|
| |
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); |
} | } |
| |
|
|
{ | { |
return(u); | return(u); |
} | } |
break; |
|
} | } |
| |
case CIMTYPE_STRING: | case CIMTYPE_STRING: |
|
|
ptr[i].extString.pchar = | ptr[i].extString.pchar = |
(char*)_getCharString(av[i].stringValue,base); | (char*)_getCharString(av[i].stringValue,base); |
// lenght with out the trailing /0 ! | // lenght with out the trailing /0 ! |
ptr[i].extString.length = av[i].stringValue.length-1; |
ptr[i].extString.length = av[i].stringValue.size-1; |
} | } |
} | } |
else | else |
|
|
ptr->extString.pchar = | ptr->extString.pchar = |
(char*)_getCharString(u->stringValue,base); | (char*)_getCharString(u->stringValue,base); |
// lenght with out the trailing /0 ! | // lenght with out the trailing /0 ! |
ptr->extString.length = u->stringValue.length-1; |
ptr->extString.length = u->stringValue.size-1; |
} | } |
| |
return(ptr); | return(ptr); |
break; |
|
} | } |
default: | default: |
{ | { |
|
|
return 0; | 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 | Uint32 SCMOInstance::getKeyBindingCount() const |
{ | { |
// count of class keys + user definded keys | // count of class keys + user definded keys |
return(inst.hdr->numberKeyBindings+ | return(inst.hdr->numberKeyBindings+ |
inst.hdr->numberUserKeyBindindigs); |
inst.hdr->numberUserKeyBindings); |
} | } |
| |
| |
|
|
| |
// count of class keys + user definded keys | // count of class keys + user definded keys |
if (node >= (inst.hdr->numberKeyBindings+ | if (node >= (inst.hdr->numberKeyBindings+ |
inst.hdr->numberUserKeyBindindigs)) |
inst.hdr->numberUserKeyBindings)) |
{ | { |
return SCMO_INDEX_OUT_OF_BOUND; | return SCMO_INDEX_OUT_OF_BOUND; |
} | } |
|
|
| |
*pvalue = 0; | *pvalue = 0; |
| |
rc = inst.hdr->theClass->_getKeyBindingNodeIndex(node,name); |
rc = inst.hdr->theClass.ptr->_getKeyBindingNodeIndex(node,name); |
if (rc != SCMO_OK) | if (rc != SCMO_OK) |
{ | { |
// look at the user defined key bindings. | // look at the user defined key bindings. |
|
|
(SCMBKeyBindingValue*)&(inst.base[inst.hdr->keyBindingArray.start]); | (SCMBKeyBindingValue*)&(inst.base[inst.hdr->keyBindingArray.start]); |
| |
// create a pointer to key binding node array of the class. | // create a pointer to key binding 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; | type = theClassKeyBindNodeArray[node].type; |
| |
// First resolve pointer to the key binding name | // First resolve pointer to the key binding name |
pnameLen = theClassKeyBindNodeArray[node].name.length; |
pnameLen = theClassKeyBindNodeArray[node].name.size; |
*pname = _getCharString( | *pname = _getCharString( |
theClassKeyBindNodeArray[node].name, | theClassKeyBindNodeArray[node].name, |
inst.hdr->theClass->cls.base); |
inst.hdr->theClass.ptr->cls.base); |
| |
// There is no value set in the instance | // There is no value set in the instance |
if (!theInstKeyBindValueArray[node].isSet) | if (!theInstKeyBindValueArray[node].isSet) |
|
|
| |
type = theElem->type; | type = theElem->type; |
| |
pnameLen = theElem->name.length; |
pnameLen = theElem->name.size; |
*pname = _getCharString(theElem->name,inst.base); | *pname = _getCharString(theElem->name,inst.base); |
| |
// There is no value set in the instance | // There is no value set in the instance |
|
|
| |
Uint32 len = strlen(name); | Uint32 len = strlen(name); |
node = 0; | node = 0; |
SCMBUserKeyBindingElement* theUserDefKBElement; |
|
| |
Uint64 elementStart = inst.hdr->userKeyBindingElement.start; | Uint64 elementStart = inst.hdr->userKeyBindingElement.start; |
| |
|
|
SCMBUserKeyBindingElement* theUserDefKBElement = | SCMBUserKeyBindingElement* theUserDefKBElement = |
(SCMBUserKeyBindingElement*)&(inst.base[elementStart]); | (SCMBUserKeyBindingElement*)&(inst.base[elementStart]); |
| |
if (_equalUTF8Strings(theUserDefKBElement->name,inst.base,name,len)) |
if (_equalNoCaseUTF8Strings( |
|
theUserDefKBElement->name,inst.base,name,len)) |
{ | { |
// the node index of a user defined key binding has an offset | // the node index of a user defined key binding has an offset |
// by the number of key bindings defined in the class | // by the number of key bindings defined in the class |
|
|
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: |
|
|
) | ) |
{ | { |
scmoKBV.isSet=false; | scmoKBV.isSet=false; |
|
// If it not a simple value, it will be over written. |
|
scmoKBV.data.simple.hasValue=false; |
| |
if ( kbs.size() == 0 && type != CIMTYPE_STRING) | if ( kbs.size() == 0 && type != CIMTYPE_STRING) |
{ | { |
|
|
StringConversion::checkUintBounds(x, type)) | StringConversion::checkUintBounds(x, type)) |
{ | { |
scmoKBV.data.simple.val.u8 = Uint8(x); | scmoKBV.data.simple.val.u8 = Uint8(x); |
|
scmoKBV.data.simple.hasValue=true; |
scmoKBV.isSet=true; | scmoKBV.isSet=true; |
} | } |
break; | break; |
|
|
StringConversion::checkUintBounds(x, type)) | StringConversion::checkUintBounds(x, type)) |
{ | { |
scmoKBV.data.simple.val.u16 = Uint16(x); | scmoKBV.data.simple.val.u16 = Uint16(x); |
|
scmoKBV.data.simple.hasValue=true; |
scmoKBV.isSet=true; | scmoKBV.isSet=true; |
} | } |
break; | break; |
|
|
StringConversion::checkUintBounds(x, type)) | StringConversion::checkUintBounds(x, type)) |
{ | { |
scmoKBV.data.simple.val.u32 = Uint32(x); | scmoKBV.data.simple.val.u32 = Uint32(x); |
|
scmoKBV.data.simple.hasValue=true; |
scmoKBV.isSet=true; | scmoKBV.isSet=true; |
} | } |
break; | break; |
|
|
if (StringConversion::stringToUnsignedInteger(v, x)) | if (StringConversion::stringToUnsignedInteger(v, x)) |
{ | { |
scmoKBV.data.simple.val.u64 = x; | scmoKBV.data.simple.val.u64 = x; |
|
scmoKBV.data.simple.hasValue=true; |
scmoKBV.isSet=true; | scmoKBV.isSet=true; |
} | } |
break; | break; |
|
|
StringConversion::checkSintBounds(x, type)) | StringConversion::checkSintBounds(x, type)) |
{ | { |
scmoKBV.data.simple.val.s8 = Sint8(x); | scmoKBV.data.simple.val.s8 = Sint8(x); |
|
scmoKBV.data.simple.hasValue=true; |
scmoKBV.isSet=true; | scmoKBV.isSet=true; |
} | } |
break; | break; |
|
|
StringConversion::checkSintBounds(x, type)) | StringConversion::checkSintBounds(x, type)) |
{ | { |
scmoKBV.data.simple.val.s16 = Sint16(x); | scmoKBV.data.simple.val.s16 = Sint16(x); |
|
scmoKBV.data.simple.hasValue=true; |
scmoKBV.isSet=true; | scmoKBV.isSet=true; |
} | } |
break; | break; |
|
|
StringConversion::checkSintBounds(x, type)) | StringConversion::checkSintBounds(x, type)) |
{ | { |
scmoKBV.data.simple.val.s32 = Sint32(x); | scmoKBV.data.simple.val.s32 = Sint32(x); |
|
scmoKBV.data.simple.hasValue=true; |
scmoKBV.isSet=true; | scmoKBV.isSet=true; |
} | } |
break; | break; |
|
|
if (StringConversion::stringToSignedInteger(v, x)) | if (StringConversion::stringToSignedInteger(v, x)) |
{ | { |
scmoKBV.data.simple.val.s64 = x; | scmoKBV.data.simple.val.s64 = x; |
|
scmoKBV.data.simple.hasValue=true; |
scmoKBV.isSet=true; | scmoKBV.isSet=true; |
} | } |
break; | break; |
|
|
if (StringConversion::stringToReal64(v, x)) | if (StringConversion::stringToReal64(v, x)) |
{ | { |
scmoKBV.data.simple.val.r32 = Real32(x); | scmoKBV.data.simple.val.r32 = Real32(x); |
|
scmoKBV.data.simple.hasValue=true; |
scmoKBV.isSet=true; | scmoKBV.isSet=true; |
} | } |
break; | break; |
|
|
if (StringConversion::stringToReal64(v, x)) | if (StringConversion::stringToReal64(v, x)) |
{ | { |
scmoKBV.data.simple.val.r64 = x; | scmoKBV.data.simple.val.r64 = x; |
|
scmoKBV.data.simple.hasValue=true; |
scmoKBV.isSet=true; | scmoKBV.isSet=true; |
} | } |
break; | break; |
|
|
if (kbs.size() == 1) | if (kbs.size() == 1) |
{ | { |
scmoKBV.data.simple.val.c16 = kbs[0]; | scmoKBV.data.simple.val.c16 = kbs[0]; |
|
scmoKBV.data.simple.hasValue=true; |
scmoKBV.isSet=true; | scmoKBV.isSet=true; |
} | } |
break; | break; |
|
|
if (String::equalNoCase(kbs,"TRUE")) | if (String::equalNoCase(kbs,"TRUE")) |
{ | { |
scmoKBV.data.simple.val.bin = true; | scmoKBV.data.simple.val.bin = true; |
|
scmoKBV.data.simple.hasValue=true; |
scmoKBV.isSet=true; | scmoKBV.isSet=true; |
} | } |
else if (String::equalNoCase(kbs,"FALSE")) | else if (String::equalNoCase(kbs,"FALSE")) |
{ | { |
scmoKBV.data.simple.val.bin = false; | scmoKBV.data.simple.val.bin = false; |
|
scmoKBV.data.simple.hasValue=true; |
scmoKBV.isSet=true; | scmoKBV.isSet=true; |
} | } |
break; | break; |
|
|
// 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: |
{ | { |
|
|
} | } |
// TBD: Optimize parsing and SCMOInstance creation. | // TBD: Optimize parsing and SCMOInstance creation. |
CIMObjectPath theCIMObj(kbs); | CIMObjectPath theCIMObj(kbs); |
SCMOClass* theRefClass = _getSCMOClass( |
|
theCIMObj, |
|
_getCharString(inst.hdr->instNameSpace,inst.base), |
|
inst.hdr->instNameSpace.length); |
|
| |
if (theRefClass != 0) |
scmoKBV.data.extRefPtr = new SCMOInstance(theCIMObj); |
{ |
scmoKBV.isSet=true; |
scmoKBV.data.extRefPtr = |
|
new SCMOInstance(*theRefClass,theCIMObj); |
// Was the conversion successful? |
} else |
if (scmoKBV.data.extRefPtr->isEmpty()) |
{ | { |
|
// N0, delete the SCMOInstance. |
|
delete scmoKBV.data.extRefPtr; |
scmoKBV.data.extRefPtr = 0; | scmoKBV.data.extRefPtr = 0; |
|
scmoKBV.isSet=false; |
|
} |
|
else |
|
{ |
|
// This function can cause a reallocation ! |
|
// Pointers can be invalid after the call. |
|
_setExtRefIndex(&(scmoKBV.data),&inst.mem); |
} | } |
scmoKBV.isSet=true; |
|
break; | break; |
} | } |
case CIMTYPE_OBJECT: | case CIMTYPE_OBJECT: |
|
|
{ | { |
// From PEP 194: EmbeddedObjects cannot be keys. | // From PEP 194: EmbeddedObjects cannot be keys. |
throw TypeMismatchException(); | throw TypeMismatchException(); |
break; |
|
} | } |
default: | default: |
{ | { |
|
|
CIMType type, | CIMType type, |
String cimKeyBinding) | String cimKeyBinding) |
{ | { |
SCMO_RC rc; |
|
Uint32 node; | Uint32 node; |
| |
if (0 == name) | if (0 == name) |
|
|
return SCMO_INVALID_PARAMETER; | return SCMO_INVALID_PARAMETER; |
} | } |
| |
if (SCMO_OK == inst.hdr->theClass->_getKeyBindingNodeIndex(node,name)) |
if (SCMO_OK == inst.hdr->theClass.ptr->_getKeyBindingNodeIndex(node,name)) |
{ | { |
// 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]); |
| |
// create a pointer to instance keybinding values | // create a pointer to instance keybinding values |
SCMBKeyBindingValue* theInstKeyBindValueArray = | SCMBKeyBindingValue* theInstKeyBindValueArray = |
|
|
return SCMO_INVALID_PARAMETER; | return SCMO_INVALID_PARAMETER; |
} | } |
| |
rc = inst.hdr->theClass->_getKeyBindingNodeIndex(node,name); |
_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); |
if (rc != SCMO_OK) | if (rc != SCMO_OK) |
{ | { |
// the key bindig does not belong to the associated class | // the key bindig does not belong to the associated class |
|
|
CIMType type, | CIMType type, |
const SCMBUnion* keyvalue) | const SCMBUnion* keyvalue) |
{ | { |
SCMO_RC rc; |
|
|
|
// create a pointer to keybinding node array of the class. |
|
Uint64 idx = inst.hdr->theClass->cls.hdr->keyBindingSet.nodeArray.start; |
|
SCMBKeyBindingNode* theClassKeyBindNodeArray = |
|
(SCMBKeyBindingNode*)&((inst.hdr->theClass->cls.base)[idx]); |
|
|
|
if (0 == keyvalue) | if (0 == keyvalue) |
{ | { |
return SCMO_INVALID_PARAMETER; | return SCMO_INVALID_PARAMETER; |
|
|
| |
// count of class keys + user definded keys | // count of class keys + user definded keys |
if (node >= (inst.hdr->numberKeyBindings+ | if (node >= (inst.hdr->numberKeyBindings+ |
inst.hdr->numberUserKeyBindindigs)) |
inst.hdr->numberUserKeyBindings)) |
{ | { |
return SCMO_INDEX_OUT_OF_BOUND; | return SCMO_INDEX_OUT_OF_BOUND; |
} | } |
| |
|
_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. |
|
Uint64 idx = inst.hdr->theClass.ptr->cls.hdr-> |
|
keyBindingSet.nodeArray.start; |
|
SCMBKeyBindingNode* theClassKeyBindNodeArray = |
|
(SCMBKeyBindingNode*)&((inst.hdr->theClass.ptr->cls.base)[idx]); |
|
|
// is the node a user defined key binding ? | // is the node a user defined key binding ? |
if (node >= inst.hdr->numberKeyBindings) | if (node >= inst.hdr->numberKeyBindings) |
{ | { |
|
|
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 |
{ | { |
|
// 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; |
|
} |
|
|
switch (classType) | switch (classType) |
{ | { |
|
case CIMTYPE_DATETIME: |
case CIMTYPE_BOOLEAN: | case CIMTYPE_BOOLEAN: |
case CIMTYPE_UINT64: | case CIMTYPE_UINT64: |
case CIMTYPE_SINT64: | case CIMTYPE_SINT64: |
|
|
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: |
|
{ |
|
return SCMO_TYPE_MISSMATCH; |
|
break; |
|
} |
|
} |
|
} |
|
|
|
return SCMO_TYPE_MISSMATCH; |
|
|
|
} |
|
|
|
|
|
void SCMOInstance::setPropertyFilter(const char **propertyList) |
|
{ |
|
SCMO_RC rc; |
|
Uint32 node,i = 0; |
|
|
|
if (inst.hdr->propertyFilter.start == 0) |
|
{ |
|
// Allocate the SCMBPropertyFilter |
|
_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 == 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->_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++; |
|
} |
|
|
|
} |
|
|
|
|
|
Uint32 SCMOInstance::_initPropFilterWithKeys() |
|
{ |
|
|
|
// 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 |
|
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->cls.hdr->keyIndexList.start; |
|
Uint32* keyIndex = (Uint32*)&(inst.hdr->theClass->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->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 ; |
|
} | } |
|
default: |
Boolean SCMOInstance::_isPropertyInFilter(Uint32 i) const |
|
{ | { |
Uint64 *propertyFilter; |
return SCMO_TYPE_MISSMATCH; |
|
} |
// 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. |
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 |
|
|
| |
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", |
|
(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", |
(insthdr->flags.isCompromised ? "True" : "False")); | (insthdr->flags.isCompromised ? "True" : "False")); |
|
fprintf(_out,"\n exportSetOnly: %s", |
|
(insthdr->flags.exportSetOnly ? "True" : "False")); |
fprintf(_out,"\n\ninstNameSpace: \'%s\'", | fprintf(_out,"\n\ninstNameSpace: \'%s\'", |
NULLSTR(_getCharString(insthdr->instNameSpace,instbase))); | NULLSTR(_getCharString(insthdr->instNameSpace,instbase))); |
fprintf(_out,"\n\ninstClassName: \'%s\'", | fprintf(_out,"\n\ninstClassName: \'%s\'", |
|
|
| |
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; |
|
|
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))); |
|
|
fprintf(_out,"\npropertyFilter[%02u]= ",i); |
|
| |
for (Uint32 j = 0; j < end; j++) |
|
{ |
|
if (j > 0 && !(j%8)) |
|
{ |
|
fprintf(_out," "); |
|
} | } |
|
start = theUserDefKBElement->nextElement.start; |
|
} // for all user def. key bindings. |
| |
if (thePropertyFilter[i] & printMask) |
fprintf(_out,"\n\n"); |
{ |
|
fprintf(_out,"1"); |
|
} |
|
else |
|
{ |
|
fprintf(_out,"0"); |
|
} |
|
| |
printMask = printMask << 1; |
|
} |
|
fprintf(_out,"\n"); |
|
} |
|
} | } |
| |
void SCMODump::dumpSCMOInstanceKeyBindings(SCMOInstance& testInst) const |
void SCMODump::_dumpSCMBMgmt_Header(SCMBMgmt_Header& header,char* base) const |
{ | { |
SCMBInstance_Main* insthdr = testInst.inst.hdr; |
fprintf(_out,"\nThe Management Header:"); |
char* instbase = testInst.inst.base; |
// The magic number |
|
fprintf(_out,"\n magic=%08X",header.magic); |
// create a pointer to keybinding node array of the class. |
// Total size of the memory block( # bytes ) |
Uint64 idx = insthdr->theClass->cls.hdr->keyBindingSet.nodeArray.start; |
fprintf(_out,"\n totalSize=%llu",header.totalSize); |
SCMBKeyBindingNode* theClassKeyBindNodeArray = |
// Free bytes in the block |
(SCMBKeyBindingNode*)&((insthdr->theClass->cls.base)[idx]); |
fprintf(_out,"\n freeBytes=%llu",header.freeBytes); |
|
// Index to the start of the free space in this SCMB memory block. |
SCMBKeyBindingValue* ptr = |
fprintf(_out,"\n startOfFreeSpace=%llu",header.startOfFreeSpace); |
(SCMBKeyBindingValue*) |
// Number of external references in this instance. |
_resolveDataPtr(insthdr->keyBindingArray,instbase); |
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]); |
| |
fprintf(_out,"\n\nInstance Key Bindings :"); |
for (Uint32 i = 0; i < header.numberExtRef;) |
fprintf(_out,"\n======================="); |
|
fprintf(_out,"\n\nNumber of Key Bindings : %u",insthdr->numberKeyBindings); |
|
|
|
for (Uint32 i = 0, k = insthdr->numberKeyBindings; i < k; i++) |
|
{ | { |
if (ptr[i].isSet) |
fprintf(_out,"%llu",extRefIndexArray[i]); |
|
i++; |
|
if (i != header.numberExtRef) |
{ | { |
fprintf(_out,"\n\nNo %u : '%s'",i, |
fprintf(_out,", "); |
(const char*)printUnionValue( |
} |
theClassKeyBindNodeArray[i].type, |
} |
ptr[i].data, |
fprintf(_out,"\n"); |
instbase).getCString()); |
|
} | } |
else | else |
{ | { |
fprintf(_out,"\n\nNo %u : Not Set",i); |
fprintf(_out,"\n extRefIndexArray=[NO INDEX]\n"); |
|
|
} | } |
} | } |
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\'", |
|
|
| |
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; |
| |
|
|
} | } |
else | else |
{ | { |
line = clshdr->propertySet.number%16; |
line = clshdr->propertySet.number & 15; |
} | } |
| |
| |
|
|
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"); |
|
|
| |
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)); |
| |
|
|
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"); |
|
|
| |
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; |
} | } |
| |
| |
|
|
| |
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: %s", | fprintf(_out,"\nValue was set: %s", |
|
|
} | } |
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; |
|
|
} | } |
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," "); |
} | } |
|
|
} | } |
} | } |
| |
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]; |
|
|
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 ) |
{ | { |
|
|
} | } |
| |
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; |
| |
|
|
STRLIT("FALSE)")); | STRLIT("FALSE)")); |
out.append(';'); | out.append(';'); |
} | } |
|
fprintf(_out,"\nThe values are: %s",out.getData()); |
break; | break; |
} | } |
| |
|
|
STRLIT("FALSE)")); | STRLIT("FALSE)")); |
out.append(';'); | out.append(';'); |
} | } |
|
fprintf(_out,"\nThe values are: %s",out.getData()); |
break; | break; |
} | } |
| |
|
|
STRLIT("FALSE)")); | STRLIT("FALSE)")); |
out.append(';'); | out.append(';'); |
} | } |
|
fprintf(_out,"\nThe values are: %s",out.getData()); |
break; | break; |
} | } |
| |
|
|
STRLIT("FALSE)")); | STRLIT("FALSE)")); |
out.append(';'); | out.append(';'); |
} | } |
|
fprintf(_out,"\nThe values are: %s",out.getData()); |
break; | break; |
} | } |
| |
|
|
STRLIT("FALSE)")); | STRLIT("FALSE)")); |
out.append(';'); | out.append(';'); |
} | } |
|
fprintf(_out,"\nThe values are: %s",out.getData()); |
break; | break; |
} | } |
| |
|
|
STRLIT("FALSE)")); | STRLIT("FALSE)")); |
out.append(';'); | out.append(';'); |
} | } |
|
fprintf(_out,"\nThe values are: %s",out.getData()); |
break; | break; |
} | } |
| |
|
|
STRLIT("FALSE)")); | STRLIT("FALSE)")); |
out.append(';'); | out.append(';'); |
} | } |
|
fprintf(_out,"\nThe values are: %s",out.getData()); |
break; | break; |
} | } |
| |
|
|
STRLIT("FALSE)")); | STRLIT("FALSE)")); |
out.append(';'); | out.append(';'); |
} | } |
|
fprintf(_out,"\nThe values are: %s",out.getData()); |
break; | break; |
} | } |
| |
|
|
STRLIT("FALSE)")); | STRLIT("FALSE)")); |
out.append(';'); | out.append(';'); |
} | } |
|
fprintf(_out,"\nThe values are: %s",out.getData()); |
break; | break; |
} | } |
| |
|
|
STRLIT("FALSE)")); | STRLIT("FALSE)")); |
out.append(';'); | out.append(';'); |
} | } |
|
fprintf(_out,"\nThe values are: %s",out.getData()); |
break; | break; |
} | } |
| |
|
|
STRLIT("FALSE)")); | STRLIT("FALSE)")); |
out.append(';'); | out.append(';'); |
} | } |
|
fprintf(_out,"\nThe values are: %s",out.getData()); |
break; | break; |
} | } |
| |
|
|
STRLIT("FALSE)")); | STRLIT("FALSE)")); |
out.append(';'); | 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++) |
{ | { |
if ( 0 != p[i].length) |
if ( 0 != p[i].stringValue.size) |
{ | { |
out.append('\''); | out.append('\''); |
out.append((const char*)_getCharString(p[i],base), |
out.append( |
p[i].length-1); |
(const char*)_getCharString(p[i].stringValue,base), |
|
p[i].stringValue.size-1); |
out.append('\''); | out.append('\''); |
} | } |
else | else |
|
|
} | } |
out.append(';'); | 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_OBJECT: | case CIMTYPE_OBJECT: |
case CIMTYPE_INSTANCE: | case CIMTYPE_INSTANCE: |
{ | { |
// TODO: has to dump SCMOInstance ... |
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); |
|
} |
|
|
|
} else |
|
{ |
|
fprintf(_out,"\nThe values are: "); |
|
|
|
for (Uint32 i = 0; i < size; i++) |
|
{ |
|
fprintf( |
|
_out, |
|
"Pointer to external Reference[%d] : \'%p\';", |
|
i,p[i].extRefPtr); |
|
} |
|
} |
|
|
break; | break; |
|
|
} | } |
default: | default: |
{ | { |
|
|
} | } |
} | } |
| |
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; |
|
|
case CIMTYPE_BOOLEAN: | case CIMTYPE_BOOLEAN: |
{ | { |
_toString(out,u.simple.val.bin); | _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.simple.val.u8); | _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.simple.val.s8); | _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.simple.val.u16); | _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.simple.val.s16); | _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.simple.val.u32); | _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.simple.val.s32); | _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.simple.val.u64); | _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.simple.val.s64); | _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.simple.val.r32); | _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.simple.val.r32); | _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.simple.val.c16); | _toString(out,u.simple.val.c16); |
|
fprintf(_out,"\nThe Value is: '%s'",out.getData()); |
break; | break; |
} | } |
| |
case CIMTYPE_STRING: | case CIMTYPE_STRING: |
{ | { |
if ( 0 != u.stringValue.length) |
if ( 0 != u.stringValue.size) |
{ | { |
out.append((const char*)_getCharString(u.stringValue,base), | out.append((const char*)_getCharString(u.stringValue,base), |
u.stringValue.length-1); |
u.stringValue.size-1); |
} | } |
|
fprintf(_out,"\nThe Value is: '%s'",out.getData()); |
break; | break; |
} | } |
| |
|
|
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_OBJECT: | case CIMTYPE_OBJECT: |
case CIMTYPE_INSTANCE: | case CIMTYPE_INSTANCE: |
{ | { |
// TODO: Has to dump SCMOInstance. |
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); |
|
} |
|
|
break; | break; |
} | } |
default: | default: |
|
|
} | } |
} | } |
| |
return out.getData(); |
return; |
} | } |
|
#endif // PEGASUS_DEBUG (class SCMODump only in debug builds available) |
| |
| |
/***************************************************************************** | /***************************************************************************** |
* The constant functions | * The constant functions |
*****************************************************************************/ | *****************************************************************************/ |
| |
static Boolean _equalUTF8Strings( |
|
const SCMBDataPtr& ptr_a, |
|
char* base, |
|
const char* name, |
|
Uint32 len) |
|
|
|
{ |
|
// size without trailing '\0' !! |
|
if (ptr_a.length-1 != len) |
|
{ |
|
return false; |
|
} |
|
const char* a = (const char*)_getCharString(ptr_a,base); |
|
|
|
// lets do a loop-unrolling optimized compare here |
|
while (len >= 8) |
|
{ |
|
if ((a[0] - name[0]) || (a[1] - name[1]) || |
|
(a[2] - name[2]) || (a[3] - name[3]) || |
|
(a[4] - name[4]) || (a[5] - name[5]) || |
|
(a[6] - name[6]) || (a[7] - name[7])) |
|
{ |
|
return false; |
|
} |
|
len -= 8; |
|
a += 8; |
|
name += 8; |
|
} |
|
while (len >= 4) |
|
{ |
|
if ((a[0] - name[0]) || (a[1] - name[1]) || |
|
(a[2] - name[2]) || (a[3] - name[3])) |
|
{ |
|
return false; |
|
} |
|
len -= 4; |
|
a += 4; |
|
name += 4; |
|
} |
|
while (len--) |
|
{ |
|
if (a[0] - name[0]) |
|
{ |
|
return false; |
|
} |
|
a++; |
|
name++; |
|
} |
|
return true; |
|
} |
|
|
|
|
|
static Boolean _equalNoCaseUTF8Strings( |
|
const SCMBDataPtr& ptr_a, |
|
char* base, |
|
const char* name, |
|
Uint32 len) |
|
|
|
{ |
|
|
|
//both are empty strings, so they are equal. |
|
if (ptr_a.length == 0 && len == 0) |
|
{ |
|
return true; |
|
} |
|
|
|
// size without trailing '\0' !! |
|
if (ptr_a.length-1 != len) |
|
{ |
|
return false; |
|
} |
|
|
|
const char* a = (const char*)_getCharString(ptr_a,base); |
|
|
|
#ifdef PEGASUS_HAS_ICU |
|
return ( _utf8ICUncasecmp(a,name,len)== 0); |
|
#else |
|
return ( strncasecmp(a,name,len )== 0 ); |
|
#endif |
|
} |
|
|
|
#ifdef PEGASUS_HAS_ICU | #ifdef PEGASUS_HAS_ICU |
static Uint32 _utf8ICUncasecmp( |
Uint32 _utf8ICUncasecmp( |
const char* a, | const char* a, |
const char* b, | const char* b, |
Uint32 len) | Uint32 len) |
|
|
* 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) == 0) |
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+=oldSize; | (*pmem)->freeBytes+=oldSize; |
(*pmem)->totalSize+=oldSize; | (*pmem)->totalSize+=oldSize; |
} | } |
| |
(*pmem)->freeBytes -= size; |
(*pmem)->freeBytes -= reqAlignSize; |
(*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) |
|
|
// 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) |
|
|
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 && theBuffer != 0) |
if (bufferSize != 0 && theBuffer != 0) |
{ | { |
| |
Uint64 start; | Uint64 start; |
|
|
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; |
|
} |
|
|
} | } |
} | } |
| |