version 1.2.2.67, 2009/11/13 14:37:50
|
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> |
|
|
*/ | */ |
#define NULLSTR(x) ((x) == 0 ? "" : (x)) | #define NULLSTR(x) ((x) == 0 ? "" : (x)) |
| |
#define NEWCIMSTR(ptr,base) \ |
|
((ptr).size == 0 ? \ |
|
(String()) : \ |
|
(String(&(base)[(ptr).start],((ptr).size)-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])) |
| |
|
|
|
/***************************************************************************** |
|
* The static declaration of the common SCMO memory functions. |
|
*****************************************************************************/ |
|
|
|
static Uint64 _getFreeSpace( |
|
SCMBDataPtr& ptr, |
|
Uint32 size, |
|
SCMBMgmt_Header** pmem); |
|
|
|
static void _setString( |
|
const String& theString, |
|
SCMBDataPtr& ptr, |
|
SCMBMgmt_Header** pmem); |
|
|
|
static void _setBinary( |
|
const void* theBuffer, |
|
Uint32 bufferSize, |
|
SCMBDataPtr& ptr, |
|
SCMBMgmt_Header** pmem); |
|
|
|
|
|
|
/***************************************************************************** | /***************************************************************************** |
* Internal inline functions. | * Internal inline functions. |
*****************************************************************************/ | *****************************************************************************/ |
| |
|
inline String _newCimString(const SCMBDataPtr & ptr, const char * base) |
|
{ |
|
if (ptr.size > 0) |
|
{ |
|
return String(&(base[ptr.start]),ptr.size-1); |
|
} |
|
else |
|
{ |
|
return String(); |
|
} |
|
} |
|
|
inline void _deleteArrayExtReference( | inline void _deleteArrayExtReference( |
SCMBDataPtr& theArray, | SCMBDataPtr& theArray, |
SCMBMgmt_Header** pmem ) | SCMBMgmt_Header** pmem ) |
|
|
} | } |
} | } |
| |
|
static void _deleteExternalReferenceInternal( |
|
SCMBMgmt_Header* memHdr, SCMOInstance *extRefPtr) |
|
{ |
|
Uint32 nuExtRef = memHdr->numberExtRef; |
|
char * base = ((char*)memHdr); |
|
Uint64* array = |
|
(Uint64*)&(base[memHdr->extRefIndexArray.start]); |
|
Uint32 extRefIndex = PEG_NOT_FOUND; |
|
|
|
for (Uint32 i = 0; i < nuExtRef; i++) |
|
{ |
|
if (((SCMBUnion*)(&(base[array[i]])))->extRefPtr == extRefPtr) |
|
{ |
|
extRefIndex = i; |
|
break; |
|
} |
|
} |
|
PEGASUS_ASSERT (extRefIndex != PEG_NOT_FOUND); |
|
|
|
// Shrink extRefIndexArray |
|
|
|
for (Uint32 i = extRefIndex + 1; i < nuExtRef; i++) |
|
{ |
|
array[i-1] = array[i]; |
|
} |
|
|
|
array[nuExtRef-1] = 0; |
|
memHdr->numberExtRef--; |
|
|
|
delete extRefPtr; |
|
} |
|
|
/***************************************************************************** | /***************************************************************************** |
* The SCMOClass methods | * The SCMOClass methods |
*****************************************************************************/ | *****************************************************************************/ |
|
|
return _getCharString(cls.hdr->superClassName,cls.base); | return _getCharString(cls.hdr->superClassName,cls.base); |
} | } |
| |
const char* SCMOClass::getSuperClassName_l(Uint64 & length) const |
const char* SCMOClass::getSuperClassName_l(Uint32 & length) const |
{ | { |
length = cls.hdr->superClassName.size; | length = cls.hdr->superClassName.size; |
if (0 == length) | if (0 == length) |
|
|
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 |
{ | { |
|
|
for (Uint32 i = 0, k = cls.hdr->keyBindingSet.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. |
keyNames.append(NEWCIMSTR(nodeArray[i].name,cls.base)); |
keyNames.append(_newCimString(nodeArray[i].name,cls.base)); |
} | } |
} | } |
| |
|
|
tag = _generateStringTag((const char*)name, len); | tag = _generateStringTag((const char*)name, len); |
// get the node index of the hash table | // get the node index of the hash table |
hashIdx = | hashIdx = |
cls.hdr->keyBindingSet.hashTable[tag%PEGASUS_KEYBINDIG_SCMB_HASHSIZE]; |
cls.hdr->keyBindingSet.hashTable[tag&(PEGASUS_KEYBINDIG_SCMB_HASHSIZE-1)]; |
// there is no entry in the hash table on this hash table index. | // there is no entry in the hash table on this hash table index. |
if (hashIdx == 0) | if (hashIdx == 0) |
{ | { |
|
|
tag = _generateStringTag((const char*)name, len); | tag = _generateStringTag((const char*)name, len); |
// get the node index of the hash table | // get the node index of the hash table |
hashIdx = | hashIdx = |
cls.hdr->propertySet.hashTable[tag%PEGASUS_PROPERTY_SCMB_HASHSIZE]; |
cls.hdr->propertySet.hashTable[tag&(PEGASUS_PROPERTY_SCMB_HASHSIZE -1)]; |
// there is no entry in the hash table on this hash table index. | // there is no entry in the hash table on this hash table index. |
if (hashIdx == 0) | if (hashIdx == 0) |
{ | { |
|
|
} 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 *hashTable = cls.hdr->keyBindingSet.hashTable; | Uint32 *hashTable = cls.hdr->keyBindingSet.hashTable; |
| |
// calculate the new hash index of the new property. | // calculate the new hash index of the new property. |
Uint32 hash = newKeyNode->nameHashTag % PEGASUS_KEYBINDIG_SCMB_HASHSIZE; |
Uint32 hash = newKeyNode->nameHashTag & |
|
(PEGASUS_KEYBINDIG_SCMB_HASHSIZE - 1); |
| |
// 0 is an invalid index in the hash table | // 0 is an invalid index in the hash table |
if (hashTable[hash] == 0) | if (hashTable[hash] == 0) |
|
|
Uint32 *hashTable = cls.hdr->propertySet.hashTable; | Uint32 *hashTable = cls.hdr->propertySet.hashTable; |
| |
// calcuate the new hash index of the new property. | // calcuate the new hash index of the new property. |
Uint32 hash = newPropNode->theProperty.nameHashTag % |
Uint32 hash = newPropNode->theProperty.nameHashTag & |
PEGASUS_PROPERTY_SCMB_HASHSIZE; |
(PEGASUS_PROPERTY_SCMB_HASHSIZE -1); |
| |
// 0 is an invalid index in the hash table | // 0 is an invalid index in the hash table |
if (hashTable[hash] == 0) | if (hashTable[hash] == 0) |
|
|
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]); |
|
|
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) |
|
|
SCMOInstance::SCMOInstance( | SCMOInstance::SCMOInstance( |
const CIMInstance& cimInstance, | const CIMInstance& cimInstance, |
const char* altNameSpace, | const char* altNameSpace, |
Uint64 altNSLen) |
Uint32 altNSLen) |
{ | { |
SCMOClass theSCMOClass = _getSCMOClass( | SCMOClass theSCMOClass = _getSCMOClass( |
cimInstance._rep->_reference, | cimInstance._rep->_reference, |
|
|
SCMOInstance::SCMOInstance( | SCMOInstance::SCMOInstance( |
const CIMObject& cimObject, | const CIMObject& cimObject, |
const char* altNameSpace, | const char* altNameSpace, |
Uint64 altNSLen) |
Uint32 altNSLen) |
{ | { |
if (cimObject.isClass()) | if (cimObject.isClass()) |
{ | { |
|
|
SCMOInstance::SCMOInstance( | SCMOInstance::SCMOInstance( |
const CIMObjectPath& cimObj, | const CIMObjectPath& cimObj, |
const char* altNameSpace, | const char* altNameSpace, |
Uint64 altNSLen) |
Uint32 altNSLen) |
{ | { |
SCMOClass theSCMOClass = _getSCMOClass( | SCMOClass theSCMOClass = _getSCMOClass( |
cimObj, | cimObj, |
|
|
} | } |
} | } |
| |
|
|
void SCMOInstance::_destroyExternalReferences() | void SCMOInstance::_destroyExternalReferences() |
{ | { |
_destroyExternalReferencesInternal(inst.mem); | _destroyExternalReferencesInternal(inst.mem); |
|
|
SCMOClass SCMOInstance::_getSCMOClass( | SCMOClass SCMOInstance::_getSCMOClass( |
const CIMObjectPath& theCIMObj, | const CIMObjectPath& theCIMObj, |
const char* altNS, | const char* altNS, |
Uint64 altNSlength) |
Uint32 altNSlength) |
{ | { |
SCMOClass theClass; | SCMOClass theClass; |
| |
|
|
| |
} | } |
| |
SCMOInstance* SCMOInstance::getExtRef(Uint32 idx) |
SCMOInstance* SCMOInstance::getExtRef(Uint32 idx) const |
{ | { |
Uint64* array = | Uint64* array = |
(Uint64*)&(inst.base[inst.mem->extRefIndexArray.start]); | (Uint64*)&(inst.base[inst.mem->extRefIndexArray.start]); |
|
|
void SCMOInstance::_destroyExternalKeyBindings() | void SCMOInstance::_destroyExternalKeyBindings() |
{ | { |
// 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 instanc key binding array. | // create a pointer to instanc key binding array. |
SCMBKeyBindingValue* theInstanceKeyBindingNodeArray = | SCMBKeyBindingValue* theInstanceKeyBindingNodeArray = |
|
|
// only references can be a key binding | // only references can be a key binding |
if (theClassKeyBindNodeArray[i].type == CIMTYPE_REFERENCE) | if (theClassKeyBindNodeArray[i].type == CIMTYPE_REFERENCE) |
{ | { |
delete theInstanceKeyBindingNodeArray[i].data.extRefPtr; |
_deleteExternalReferenceInternal( |
|
inst.mem, |
|
theInstanceKeyBindingNodeArray[i].data.extRefPtr); |
} | } |
} | } |
}// for all key bindings | }// for all key bindings |
|
|
// only references can be a key binding. | // only references can be a key binding. |
if (theUserDefKBElement->type == CIMTYPE_REFERENCE) | if (theUserDefKBElement->type == CIMTYPE_REFERENCE) |
{ | { |
delete theUserDefKBElement->value.data.extRefPtr; |
_deleteExternalReferenceInternal( |
|
inst.mem, |
|
theUserDefKBElement->value.data.extRefPtr); |
} | } |
} | } |
| |
|
|
{ | { |
| |
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 |
)); | )); |
} | } |
|
|
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 = |
|
|
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); |
} | } |
|
|
| |
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(); |
|
|
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(); |
_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); |
} | } |
|
|
} | } |
|
|
void SCMOInstance::_setCIMValueAtNodeIndex( | void SCMOInstance::_setCIMValueAtNodeIndex( |
Uint32 node, | Uint32 node, |
CIMValueRep* valRep, | CIMValueRep* valRep, |
|
|
| |
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); |
// copy including trailing '\0' |
|
_setBinary(hostName,len+1,inst.hdr->hostName,&inst.mem); |
|
return; |
|
|
|
} | } |
inst.hdr->hostName.start=0; |
|
inst.hdr->hostName.size=0; |
|
} |
|
|
|
void SCMOInstance::setHostName_l(const char* hostName, Uint64 len) |
|
{ |
|
// 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 _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; | length = inst.hdr->hostName.size; |
if (0 == length) | if (0 == length) |
|
|
void SCMOInstance::setClassName(const char* className) | void SCMOInstance::setClassName(const char* className) |
{ | { |
Uint32 len=0; | Uint32 len=0; |
|
|
|
_copyOnWrite(); |
|
|
// flag the instance as compromized | // flag the instance as compromized |
inst.hdr->flags.isCompromised=true; | inst.hdr->flags.isCompromised=true; |
if (className!=0) | if (className!=0) |
|
|
_setBinary(className,len+1,inst.hdr->instClassName,&inst.mem); | _setBinary(className,len+1,inst.hdr->instClassName,&inst.mem); |
} | } |
| |
void SCMOInstance::setClassName_l(const char* className, Uint64 len) |
void SCMOInstance::setClassName_l(const char* className, Uint32 len) |
{ | { |
|
_copyOnWrite(); |
|
|
// flag the instance as compromised | // flag the instance as compromised |
inst.hdr->flags.isCompromised=true; | inst.hdr->flags.isCompromised=true; |
// copy including trailing '\0' | // copy including trailing '\0' |
|
|
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.size; | length = inst.hdr->instClassName.size; |
if (0 == length) | if (0 == length) |
|
|
| |
void SCMOInstance::setNameSpace(const char* nameSpace) | void SCMOInstance::setNameSpace(const char* nameSpace) |
{ | { |
Uint32 len; |
Uint32 len = 0; |
|
|
|
_copyOnWrite(); |
| |
// flag the instance as compromized | // flag the instance as compromized |
inst.hdr->flags.isCompromised=true; | inst.hdr->flags.isCompromised=true; |
|
|
{ | { |
| |
len = strlen((const char*)nameSpace); | len = strlen((const char*)nameSpace); |
|
} |
// 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; |
|
} |
|
inst.hdr->instNameSpace.start=0; |
|
inst.hdr->instNameSpace.size=0; |
|
} | } |
| |
void SCMOInstance::setNameSpace_l(const char* nameSpace, Uint64 len) |
void SCMOInstance::setNameSpace_l(const char* nameSpace, Uint32 len) |
{ | { |
|
// Copy on Write is only necessary if a realloc() becomes necessary |
|
if (inst.mem->freeBytes < ((len+8) & ~7)) |
|
{ |
|
_copyOnWrite(); |
|
} |
// flag the instance as compromized | // flag the instance as compromized |
inst.hdr->flags.isCompromised=true; | inst.hdr->flags.isCompromised=true; |
// copy including trailing '\0' | // copy including trailing '\0' |
|
|
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; | length = inst.hdr->instNameSpace.size; |
if (0 == length) | if (0 == 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); |
|
} |
|
} |
| |
Uint32* theClassKeyPropList = |
|
(Uint32*) &((inst.hdr->theClass->cls.base) |
|
[(inst.hdr->theClass->cls.hdr->keyIndexList.start)]); |
|
|
|
SCMBKeyBindingValue* theKeyBindValueArray; |
|
SCMBValue* theInstPropNodeArray; |
|
| |
|
void SCMOInstance::buildKeyBindingsFromProperties() |
|
{ |
Uint32 propNode; | Uint32 propNode; |
|
// The theClassKeyPropList pointer will always be valid, |
|
// even after a realloc() caused by copyOnWrite() |
|
// as this is an absolute pointer to the class which does not change |
|
Uint32* theClassKeyPropList = |
|
(Uint32*) &((inst.hdr->theClass.ptr->cls.base) |
|
[(inst.hdr->theClass.ptr->cls.hdr->keyIndexList.start)]); |
| |
for (Uint32 i = 0, k = inst.hdr->numberKeyBindings; i < k; i++) |
SCMBKeyBindingValue* theKeyBindValueArray = |
{ |
|
// 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]); | (SCMBKeyBindingValue*)&(inst.base[inst.hdr->keyBindingArray.start]); |
|
SCMBValue* theInstPropNodeArray= |
theInstPropNodeArray = |
|
(SCMBValue*)&inst.base[inst.hdr->propertyArray.start]; | (SCMBValue*)&inst.base[inst.hdr->propertyArray.start]; |
| |
|
inst.hdr->numberKeyBindings = |
|
inst.hdr->theClass.ptr->cls.hdr->keyBindingSet.number; |
|
|
|
for (Uint32 i = 0, k = inst.hdr->numberKeyBindings; i < k; i++) |
|
{ |
// If the keybinding is not set. | // If the keybinding is not set. |
if (!theKeyBindValueArray[i].isSet) | if (!theKeyBindValueArray[i].isSet) |
{ | { |
|
|
if ( theInstPropNodeArray[propNode].flags.isSet && | if ( theInstPropNodeArray[propNode].flags.isSet && |
!theInstPropNodeArray[propNode].flags.isNull) | !theInstPropNodeArray[propNode].flags.isNull) |
{ | { |
|
_copyOnWrite(); |
|
// the instance pointers have to be recalculated as copyOnWrite |
|
// might change the absolute address of these pointers |
|
theInstPropNodeArray = |
|
(SCMBValue*)&inst.base[inst.hdr->propertyArray.start]; |
|
theKeyBindValueArray = |
|
(SCMBKeyBindingValue*) |
|
&(inst.base[inst.hdr->keyBindingArray.start]); |
|
|
_setKeyBindingFromSCMBUnion( | _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_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.size, | u.stringValue.size, |
keyData.data.stringValue, | keyData.data.stringValue, |
&inst.mem); | &inst.mem); |
|
} |
|
|
break; | break; |
} | } |
case CIMTYPE_REFERENCE: | case CIMTYPE_REFERENCE: |
|
|
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.size, |
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.size, |
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( |
|
|
{ | { |
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 |
|
{ |
|
PEG_TRACE((TRC_DISCARDED_DATA,Tracer::LEVEL2, |
|
"CIMProperty '%s' with type '%s' " |
|
"can not be set at SCMOInstance." |
|
"It is has not same type '%s' as defined in " |
|
"class '%s' of name space '%s'", |
|
cimTypeToString(propRep->_value._rep->type), |
|
(const char*)propRep->_name.getString().getCString(), |
|
cimTypeToString(realType), |
|
(const char*)instRep->_reference._rep-> |
|
_className.getString().getCString(), |
|
(const char*)instRep->_reference._rep-> |
|
_nameSpace.getString().getCString())); |
|
} |
|
|
} | } |
else | else |
{ | { |
throw PEGASUS_CIM_EXCEPTION(CIM_ERR_TYPE_MISMATCH, |
|
propRep->_name.getString()); |
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::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, |
|
|
CIMType type, | CIMType type, |
Uint32& n, | Uint32& n, |
Uint64 startNS, | Uint64 startNS, |
Uint64 sizeNS, |
Uint32 sizeNS, |
Union& u) | Union& u) |
{ | { |
SCMBUnion* scmoUnion = (SCMBUnion*)&(((char*)*pmem)[start]); | SCMBUnion* scmoUnion = (SCMBUnion*)&(((char*)*pmem)[start]); |
|
|
| |
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 = | ptargetUnion[i].extRefPtr = |
new SCMOInstance( | new SCMOInstance( |
theClass, |
cimClass, |
(&((const char*)*pmem)[startNS])); | (&((const char*)*pmem)[startNS])); |
// marke as class only ! | // marke as class only ! |
ptargetUnion[i].extRefPtr-> | ptargetUnion[i].extRefPtr-> |
|
|
SCMBMgmt_Header** pmem, | SCMBMgmt_Header** pmem, |
CIMType type, | CIMType type, |
Uint64 startNS, | Uint64 startNS, |
Uint64 sizeNS, |
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; |
|
|
} | } |
| |
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 = | scmoUnion->extRefPtr = |
new SCMOInstance( | new SCMOInstance( |
theClass, |
cimClass, |
(&((const char*)*pmem)[startNS])); | (&((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; |
|
|
(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( |
|
|
} | } |
| |
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]); |
| |
|
|
| |
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: |
|
|
} | } |
| |
return(ptr); | return(ptr); |
break; |
|
} | } |
default: | default: |
{ | { |
|
|
| |
void SCMOInstance::clearKeyBindings() | void SCMOInstance::clearKeyBindings() |
{ | { |
|
_copyOnWrite(); |
|
|
// First destroy all external references in the key bindings | // First destroy all external references in the key bindings |
_destroyExternalKeyBindings(); | _destroyExternalKeyBindings(); |
| |
|
|
inst.hdr->keyBindingArray, | inst.hdr->keyBindingArray, |
sizeof(SCMBKeyBindingValue)*inst.hdr->numberKeyBindings, | sizeof(SCMBKeyBindingValue)*inst.hdr->numberKeyBindings, |
&inst.mem); | &inst.mem); |
|
|
|
// Clear the keybindings after the allocation. Setting the keybindings |
|
// later causes this value to be reinitialized. |
|
inst.hdr->numberKeyBindings = 0; |
|
|
|
markAsCompromised(); |
} | } |
| |
Uint32 SCMOInstance::getKeyBindingCount() const | Uint32 SCMOInstance::getKeyBindingCount() const |
|
|
| |
*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; |
| |
|
|
pnameLen = theClassKeyBindNodeArray[node].name.size; | 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) |
|
|
| |
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; |
| |
|
|
return CIMTYPE_REAL64; | return CIMTYPE_REAL64; |
} | } |
} | } |
break; |
|
} | } |
| |
| |
case CIMKeyBinding::STRING: | case CIMKeyBinding::STRING: |
{ | { |
return CIMTYPE_STRING; | return CIMTYPE_STRING; |
break; |
|
} | } |
| |
case CIMKeyBinding::BOOLEAN: | case CIMKeyBinding::BOOLEAN: |
{ | { |
return CIMTYPE_BOOLEAN; | return CIMTYPE_BOOLEAN; |
break; |
|
} | } |
| |
case CIMKeyBinding::REFERENCE: | case CIMKeyBinding::REFERENCE: |
{ | { |
return CIMTYPE_REFERENCE; | return CIMTYPE_REFERENCE; |
break; |
|
} | } |
| |
default: | default: |
|
|
// Can cause reallocation ! | // Can cause reallocation ! |
_setString(kbs,scmoKBV.data.stringValue,&inst.mem); | _setString(kbs,scmoKBV.data.stringValue,&inst.mem); |
return true; | return true; |
break; |
|
} | } |
case CIMTYPE_REFERENCE: | case CIMTYPE_REFERENCE: |
{ | { |
|
|
{ | { |
// From PEP 194: EmbeddedObjects cannot be keys. | // From PEP 194: EmbeddedObjects cannot be keys. |
throw TypeMismatchException(); | throw TypeMismatchException(); |
break; |
|
} | } |
default: | default: |
{ | { |
|
|
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; |
|
|
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 |
{ | { |
|
|
kbValue.isSet=true; | kbValue.isSet=true; |
_setSCMBUnion(keyValue,classType,false, 0,kbValue.data); | _setSCMBUnion(keyValue,classType,false, 0,kbValue.data); |
return SCMO_OK; | return SCMO_OK; |
break; |
|
} | } |
default: | default: |
{ | { |
return SCMO_TYPE_MISSMATCH; | return SCMO_TYPE_MISSMATCH; |
break; |
|
} | } |
} | } |
} | } |
|
|
| |
} | } |
| |
static int _indexComp(const void* left, const void* right) |
// class SCMODump only in debug builds available |
{ |
#ifdef PEGASUS_DEBUG |
return((*(Uint32 *)left)-(*(Uint32 *)right)); |
|
} |
|
|
|
void SCMOInstance::setPropertyFilter(const char **propertyList) |
|
{ |
|
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); |
|
|
|
// Allocate the SCMBPropertyFilterIndexMap |
|
_getFreeSpace( |
|
inst.hdr->propertyFilterIndexMap, |
|
sizeof(Uint32)*inst.hdr->numberProperties, |
|
&inst.mem); |
|
} |
|
// Get absolut pointer to property filter index map of the instance |
|
Uint32* propertyFilterIndexMap = |
|
(Uint32*)&(inst.base[inst.hdr->propertyFilterIndexMap.start]); |
|
|
|
// All properties are accepted |
|
if (propertyList == 0) |
|
{ |
|
// Clear filtering: |
|
// Switch filtering off. |
|
inst.hdr->flags.isFiltered = false; |
|
|
|
// Clear filter index map |
|
memset( |
|
propertyFilterIndexMap, |
|
0, |
|
sizeof(Uint32)*inst.hdr->numberProperties); |
|
|
|
//reset number filter properties to all |
|
inst.hdr->filterProperties = inst.hdr->numberProperties; |
|
|
|
return; |
|
} |
|
|
|
// Switch filtering on. |
|
inst.hdr->flags.isFiltered = true; |
|
|
|
// intit the filter with the key properties |
|
inst.hdr->filterProperties=_initPropFilterWithKeys(); |
|
|
|
// add the properties to the filter. |
|
while (propertyList[i] != 0) |
|
{ |
|
// the hash index of the property if the property name is found |
|
rc = inst.hdr->theClass->_getProperyNodeIndex(node,propertyList[i]); |
|
|
|
// if property is already in the filter |
|
// ( eg. key properties ) do not add them ! |
|
if (rc == SCMO_OK && !_isPropertyInFilter(node)) |
|
{ |
|
// The property name was found. Otherwise ignore this property name. |
|
// insert the hash index into the filter index map |
|
propertyFilterIndexMap[inst.hdr->filterProperties]=node; |
|
// increase number of properties in filter. |
|
inst.hdr->filterProperties++; |
|
// set bit in the property filter |
|
_setPropertyInPropertyFilter(node); |
|
} |
|
// Proceed with the next property name. |
|
i++; |
|
} |
|
|
|
// sort the filter index to be in order as properties stored in the class. |
|
qsort( |
|
propertyFilterIndexMap, |
|
inst.hdr->filterProperties, |
|
sizeof(Uint32), |
|
_indexComp); |
|
} |
|
|
|
Uint32 SCMOInstance::_initPropFilterWithKeys() |
|
{ |
|
|
|
// Get absolut pointer to the key property mask of the class. |
|
Uint64 idx = inst.hdr->theClass->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 ; |
|
} |
|
|
|
Boolean SCMOInstance::_isPropertyInFilter(Uint32 i) const |
|
{ |
|
Uint64 *propertyFilter; |
|
|
|
// In which Uint64 of key mask is the bit for property i ? |
|
// Divide with the number of bits in a Uint64. |
|
// e.g. number of Properties = 68 |
|
// 47 / 64 = 0 --> The key bit for property i is in in keyMask[0]. |
|
Uint32 idx = i/64 ; |
|
|
|
// Create a filter to check if the bit is set: |
|
// Modulo division with 64. Shift left a bit by the remainder. |
|
Uint64 filter = ( (Uint64)1 << (i%64)); |
|
|
|
// Calculate the real pointer to the Uint64 array |
|
propertyFilter = (Uint64*)&(inst.base[inst.hdr->propertyFilter.start]); |
|
|
|
// If the bit is set the property is NOT filtered. |
|
// So the result has to be negated! |
|
return propertyFilter[idx] & filter ; |
|
|
|
} |
|
|
|
/****************************************************************************** | /****************************************************************************** |
* SCMODump Print and Dump functions | * SCMODump Print and Dump functions |
*****************************************************************************/ | *****************************************************************************/ |
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 |
|
{ |
|
SCMBInstance_Main* insthdr = testInst.inst.hdr; |
|
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( | void SCMODump::dumpInstanceProperties( |
SCMOInstance& testInst, | SCMOInstance& testInst, |
Boolean verbose) const | Boolean verbose) const |
|
|
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)) |
|
{ |
|
fprintf(_out,"\nProperty is filtered out!"); |
|
} |
|
else |
|
{ |
|
printSCMOValue(val[i],instbase,verbose); |
|
} |
|
} |
|
|
|
} |
|
|
|
void SCMODump::dumpPropertyFilterIndexMap(SCMOInstance& testInst) const |
|
{ |
|
|
|
SCMBInstance_Main* insthdr = testInst.inst.hdr; |
|
char* instbase = testInst.inst.base; |
|
|
|
if (!insthdr->flags.isFiltered) |
|
{ |
|
fprintf(_out,"\n\nNo propterty filter!\n\n"); |
|
return; |
|
} |
|
|
|
fprintf(_out,"\n\nProperty Filter Index Max:"); |
|
fprintf(_out,"\n==========================\n"); |
|
|
|
// Get absolut pointer to key index list of the class |
|
Uint32* keyIndex = |
|
(Uint32*)&(instbase)[insthdr->propertyFilterIndexMap.start]; |
|
|
|
Uint32 line,j,i,k = insthdr->filterProperties; |
|
|
|
for (j = 0; j < k; j = j + line) |
|
{ |
|
if ((insthdr->filterProperties-j)/16) |
|
{ |
|
line = 16 ; |
|
} |
|
else |
|
{ |
|
line = insthdr->filterProperties%16; |
|
} |
|
|
|
|
|
fprintf(_out,"Index :"); |
|
for (i = 0; i < line; i++) |
|
{ |
|
fprintf(_out," %3u",j+i); |
|
} |
|
|
|
fprintf(_out,"\nNode :"); |
|
for (i = 0; i < line; i++) |
|
{ |
|
fprintf(_out," %3u",keyIndex[j+i]); |
|
} |
|
|
|
fprintf(_out,"\n\n"); |
|
|
|
} |
|
|
|
} |
|
|
|
void SCMODump::dumpPropertyFilter(SCMOInstance& testInst) const |
|
{ |
|
|
|
SCMBInstance_Main* insthdr = testInst.inst.hdr; |
|
char* instbase = testInst.inst.base; |
|
|
|
if (!insthdr->flags.isFiltered) |
|
{ |
|
fprintf(_out,"\n\nNo propterty filter!"); |
|
return; |
|
} |
|
|
|
Uint64 *thePropertyFilter = |
|
(Uint64*)&(instbase[insthdr->propertyFilter.start]); |
|
Uint32 end, noProperties = insthdr->numberProperties; |
|
Uint32 noMasks = (noProperties-1)/64; |
|
Uint64 printMask = 1; |
|
|
|
for (Uint32 i = 0; i <= noMasks; i++ ) |
|
{ |
|
printMask = 1; |
|
if (i < noMasks) |
|
{ |
|
end = 64; |
|
} |
|
else |
|
{ |
|
end = noProperties%64; |
|
} |
|
| |
fprintf(_out,"\npropertyFilter[%02u]= ",i); |
printSCMOValue(val[i],instbase,verbose); |
|
|
for (Uint32 j = 0; j < end; j++) |
|
{ |
|
if (j > 0 && !(j%8)) |
|
{ |
|
fprintf(_out," "); |
|
} | } |
| |
if (thePropertyFilter[i] & printMask) |
|
{ |
|
fprintf(_out,"1"); |
|
} |
|
else |
|
{ |
|
fprintf(_out,"0"); |
|
} | } |
| |
printMask = printMask << 1; |
|
} |
|
fprintf(_out,"\n"); |
|
} |
|
} |
|
| |
void SCMODump::dumpSCMOInstanceKeyBindings( | void SCMODump::dumpSCMOInstanceKeyBindings( |
SCMOInstance& testInst, | SCMOInstance& testInst, |
|
|
char* instbase = testInst.inst.base; | char* instbase = testInst.inst.base; |
| |
// create a pointer to keybinding node array of the class. | // create a pointer to keybinding node array of the class. |
Uint64 idx = insthdr->theClass->cls.hdr->keyBindingSet.nodeArray.start; |
Uint64 idx = insthdr->theClass.ptr->cls.hdr->keyBindingSet.nodeArray.start; |
SCMBKeyBindingNode* theClassKeyBindNodeArray = | SCMBKeyBindingNode* theClassKeyBindNodeArray = |
(SCMBKeyBindingNode*)&((insthdr->theClass->cls.base)[idx]); |
(SCMBKeyBindingNode*)&((insthdr->theClass.ptr->cls.base)[idx]); |
| |
SCMBKeyBindingValue* ptr = | SCMBKeyBindingValue* ptr = |
(SCMBKeyBindingValue*) | (SCMBKeyBindingValue*) |
|
|
fprintf(_out,"\n\nName: '%s'\nType: '%s'", | fprintf(_out,"\n\nName: '%s'\nType: '%s'", |
NULLSTR(_getCharString( | NULLSTR(_getCharString( |
theClassKeyBindNodeArray[i].name, | theClassKeyBindNodeArray[i].name, |
insthdr->theClass->cls.base)), |
insthdr->theClass.ptr->cls.base)), |
cimTypeToString(theClassKeyBindNodeArray[i].type)); | cimTypeToString(theClassKeyBindNodeArray[i].type)); |
printUnionValue( | printUnionValue( |
theClassKeyBindNodeArray[i].type, | theClassKeyBindNodeArray[i].type, |
|
|
fprintf(_out,"\n\nName: '%s': Not Set", | fprintf(_out,"\n\nName: '%s': Not Set", |
NULLSTR(_getCharString( | NULLSTR(_getCharString( |
theClassKeyBindNodeArray[i].name, | theClassKeyBindNodeArray[i].name, |
insthdr->theClass->cls.base))); |
insthdr->theClass.ptr->cls.base))); |
} | } |
} | } |
| |
|
|
| |
} | } |
| |
void SCMODump::dumpSCMOClass(SCMOClass& testCls) const |
void SCMODump::_dumpSCMBMgmt_Header(SCMBMgmt_Header& header,char* base) const |
|
{ |
|
fprintf(_out,"\nThe Management Header:"); |
|
// The magic number |
|
fprintf(_out,"\n magic=%08X",header.magic); |
|
// Total size of the memory block( # bytes ) |
|
fprintf(_out,"\n totalSize=%llu",header.totalSize); |
|
// Free bytes in the block |
|
fprintf(_out,"\n freeBytes=%llu",header.freeBytes); |
|
// Index to the start of the free space in this SCMB memory block. |
|
fprintf(_out,"\n startOfFreeSpace=%llu",header.startOfFreeSpace); |
|
// Number of external references in this instance. |
|
fprintf(_out,"\n numberExtRef=%u",header.numberExtRef); |
|
// Size of external reference index array; |
|
fprintf(_out,"\n sizeExtRefIndexArray=%u",header.sizeExtRefIndexArray); |
|
|
|
if (header.numberExtRef > 0) |
|
{ |
|
fprintf(_out,"\n extRefIndexArray=["); |
|
Uint64* extRefIndexArray = |
|
(Uint64*)&(base[header.extRefIndexArray.start]); |
|
|
|
for (Uint32 i = 0; i < header.numberExtRef;) |
|
{ |
|
fprintf(_out,"%llu",extRefIndexArray[i]); |
|
i++; |
|
if (i != header.numberExtRef) |
|
{ |
|
fprintf(_out,", "); |
|
} |
|
} |
|
fprintf(_out,"\n"); |
|
} |
|
else |
|
{ |
|
fprintf(_out,"\n extRefIndexArray=[NO INDEX]\n"); |
|
} |
|
} |
|
|
|
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; |
} | } |
| |
| |
|
|
} | } |
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; |
| |
} | } |
} | } |
|
|
| |
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].size) |
if ( 0 != p[i].stringValue.size) |
{ | { |
out.append('\''); | out.append('\''); |
out.append((const char*)_getCharString(p[i],base), |
out.append( |
p[i].size-1); |
(const char*)_getCharString(p[i].stringValue,base), |
|
p[i].stringValue.size-1); |
out.append('\''); | out.append('\''); |
} | } |
else | else |
|
|
| |
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,"\n-----------> " | fprintf(_out,"\n-----------> " |
"Start of embedded external reference [%d]" | "Start of embedded external reference [%d]" |
" <-----------\n\n",i); | " <-----------\n\n",i); |
dumpSCMOInstance(*u.extRefPtr); |
dumpSCMOInstance(*(p[i].extRefPtr)); |
fprintf(_out,"\n-----------> " | fprintf(_out,"\n-----------> " |
"End of embedded external reference [%d]" | "End of embedded external reference [%d]" |
" <-----------\n\n",i); | " <-----------\n\n",i); |
|
|
| |
return; | return; |
} | } |
|
#endif // PEGASUS_DEBUG (class SCMODump only in debug builds available) |
| |
| |
/***************************************************************************** | /***************************************************************************** |
|
|
* 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) |
{ | { |
Uint64 oldSize, start; | Uint64 oldSize, start; |
|
Uint64 alignedStart, reqAlignSize; |
| |
if (size == 0) | if (size == 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.size = 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; |
| |
// Init memory to 0. |
// Init memory from unaligned start up to the size required with alignment |
memset(&((char*)(*pmem))[start],0,size); |
// to zero. |
|
memset(&((char*)(*pmem))[start],0,(size_t)reqAlignSize); |
|
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) |
|
|
} | } |
} | } |
| |
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) |
{ | { |
|
|
} | } |
} | } |
| |
static void _destroyExternalReferencesInternal(SCMBMgmt_Header* memHdr) |
void _destroyExternalReferencesInternal(SCMBMgmt_Header* memHdr) |
{ | { |
| |
Uint32 number = memHdr->numberExtRef; | Uint32 number = memHdr->numberExtRef; |