version 1.2.2.20, 2009/08/12 11:07:36
|
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/SCMOClass.h> | #include <Pegasus/Common/SCMOClass.h> |
#include <Pegasus/Common/SCMOInstance.h> | #include <Pegasus/Common/SCMOInstance.h> |
#include <Pegasus/Common/SCMODump.h> | #include <Pegasus/Common/SCMODump.h> |
|
#include <Pegasus/Common/SCMOClassCache.h> |
#include <Pegasus/Common/CharSet.h> | #include <Pegasus/Common/CharSet.h> |
#include <Pegasus/Common/CIMDateTimeRep.h> | #include <Pegasus/Common/CIMDateTimeRep.h> |
#include <Pegasus/Common/CIMPropertyRep.h> | #include <Pegasus/Common/CIMPropertyRep.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/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> |
#endif | #endif |
| |
|
#ifdef PEGASUS_HAS_ICU |
|
# include <unicode/platform.h> |
|
# include <unicode/urename.h> |
|
# include <unicode/ures.h> |
|
# include <unicode/ustring.h> |
|
# include <unicode/uchar.h> |
|
# include <unicode/ucnv.h> |
|
#endif |
|
|
PEGASUS_USING_STD; | PEGASUS_USING_STD; |
| |
#define SCMB_INITIAL_MEMORY_CHUNK_SIZE 4096 | #define SCMB_INITIAL_MEMORY_CHUNK_SIZE 4096 |
|
|
* for a string format specification, the string "(null)" is | * for a string format specification, the string "(null)" is |
* substituted. On other platforms no string "" is substituded. | * substituted. On other platforms no string "" is substituded. |
*/ | */ |
#define NULLSTR(x) ((x) == NULL ? "" : (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 |
| |
static StrLit _qualifierNameStrLit[] = |
#define PEGASUS_ARRAY_T SCMOInstance |
|
# include "ArrayImpl.h" |
|
#undef PEGASUS_ARRAY_T |
|
|
|
const StrLit SCMOClass::_qualifierNameStrLit[72] = |
{ | { |
STRLIT(""), | STRLIT(""), |
STRLIT("ABSTRACT"), | STRLIT("ABSTRACT"), |
|
|
#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. |
|
*****************************************************************************/ |
|
|
|
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( |
|
SCMBDataPtr& theArray, |
|
SCMBMgmt_Header** pmem ) |
|
{ |
|
SCMBUnion* ptr; |
|
// if the array was already set, |
|
// the previous references has to be deleted |
|
if(theArray.size != 0) |
|
{ |
|
Uint32 oldArraySize=(theArray.size/sizeof(SCMBUnion)); |
|
|
|
ptr = (SCMBUnion*)&(((char*)*pmem)[theArray.start]); |
|
for (Uint32 i = 0 ; i < oldArraySize ; i++) |
|
{ |
|
delete ptr[i].extRefPtr; |
|
ptr[i].extRefPtr = 0; |
|
} |
|
} |
|
} |
|
|
|
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 |
*****************************************************************************/ | *****************************************************************************/ |
SCMOClass::SCMOClass() | SCMOClass::SCMOClass() |
{ | { |
cls.mem = NULL; |
_initSCMOClass(); |
|
|
|
_setBinary("",1,cls.hdr->className,&cls.mem ); |
|
_setBinary("",1,cls.hdr->nameSpace,&cls.mem ); |
|
cls.hdr->flags.isEmpty=true; |
} | } |
| |
SCMOClass::SCMOClass(CIMClass& theCIMClass) |
inline void SCMOClass::_initSCMOClass() |
{ | { |
PEGASUS_ASSERT(SCMB_INITIAL_MEMORY_CHUNK_SIZE | PEGASUS_ASSERT(SCMB_INITIAL_MEMORY_CHUNK_SIZE |
- sizeof(SCMBClass_Main)>0); | - sizeof(SCMBClass_Main)>0); |
| |
cls.base = (char*)malloc(SCMB_INITIAL_MEMORY_CHUNK_SIZE); | cls.base = (char*)malloc(SCMB_INITIAL_MEMORY_CHUNK_SIZE); |
if (cls.base == NULL) |
if (cls.base == 0) |
{ | { |
// Not enough memory! | // Not enough memory! |
throw PEGASUS_STD(bad_alloc)(); | throw PEGASUS_STD(bad_alloc)(); |
} | } |
| |
|
memset(cls.base,0,sizeof(SCMBClass_Main)); |
|
|
// initalize eye catcher | // initalize eye catcher |
cls.hdr->header.magic=PEGASUS_SCMB_CLASS_MAGIC; | cls.hdr->header.magic=PEGASUS_SCMB_CLASS_MAGIC; |
cls.hdr->header.totalSize=SCMB_INITIAL_MEMORY_CHUNK_SIZE; | cls.hdr->header.totalSize=SCMB_INITIAL_MEMORY_CHUNK_SIZE; |
|
|
| |
cls.hdr->refCount=1; | cls.hdr->refCount=1; |
| |
|
} |
|
|
|
SCMOClass::SCMOClass(const char* className, const char* nameSpaceName ) |
|
{ |
|
Uint32 clsNameLen = strlen(className); |
|
Uint32 nsNameLen = strlen(nameSpaceName); |
|
|
|
if (0 == className ) |
|
{ |
|
String message("SCMOClass: Class name not set (null pointer)!"); |
|
throw CIMException(CIM_ERR_FAILED,message ); |
|
} |
|
|
|
if (0 == nameSpaceName) |
|
{ |
|
String message("SCMOClass: Name Space not set (null pointer)!"); |
|
throw CIMException(CIM_ERR_FAILED,message ); |
|
} |
|
|
|
_initSCMOClass(); |
|
|
|
_setBinary(className,clsNameLen+1,cls.hdr->className,&cls.mem ); |
|
|
|
_setBinary(nameSpaceName,nsNameLen+1,cls.hdr->nameSpace,&cls.mem ); |
|
|
|
cls.hdr->flags.isEmpty=true; |
|
|
|
} |
|
|
|
SCMOClass::SCMOClass( |
|
const CIMClass& theCIMClass, |
|
const char* nameSpaceName) |
|
{ |
|
|
|
_initSCMOClass(); |
|
|
try | try |
{ | { |
_setString(theCIMClass.getSuperClassName().getString(), | _setString(theCIMClass.getSuperClassName().getString(), |
|
|
{ | { |
// 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(); |
| |
//set name space | //set name space |
|
if (nameSpaceName) |
|
{ |
|
_setBinary(nameSpaceName, |
|
strlen(nameSpaceName)+1, |
|
cls.hdr->nameSpace, |
|
&cls.mem ); |
|
} |
|
else |
|
{ |
_setString(theObjectPath.getNameSpace().getString(), | _setString(theObjectPath.getNameSpace().getString(), |
cls.hdr->nameSpace, | cls.hdr->nameSpace, |
&cls.mem ); | &cls.mem ); |
|
} |
|
|
| |
//set class name | //set class name |
_setString(theObjectPath.getClassName().getString(), | _setString(theObjectPath.getClassName().getString(), |
cls.hdr->className, | cls.hdr->className, |
&cls.mem ); | &cls.mem ); |
| |
|
|
//set class Qualifiers | //set class Qualifiers |
_setClassQualifers(theCIMClass); |
_setClassQualifers(theCIMClass._rep->_qualifiers); |
| |
//set properties | //set properties |
_setClassProperties(theCIMClass); |
_setClassProperties(theCIMClass._rep->_properties); |
|
|
|
} |
|
|
|
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 |
|
{ |
|
CIMClass newCimClass( |
|
CIMNameCast(_newCimString(cls.hdr->className,cls.base)), |
|
CIMNameCast(_newCimString(cls.hdr->superClassName,cls.base))); |
|
|
|
// set the name space |
|
newCimClass._rep->_reference._rep->_nameSpace= |
|
CIMNamespaceNameCast(_newCimString(cls.hdr->nameSpace,cls.base)); |
|
|
|
// Add class qualifier if exist |
|
if (0 != cls.hdr->numberOfQualifiers) |
|
{ |
|
SCMBQualifier* qualiArray = |
|
(SCMBQualifier*)&(cls.base[cls.hdr->qualifierArray.start]); |
|
|
|
CIMQualifier theCimQualifier; |
|
|
|
Uint32 i, k = cls.hdr->numberOfQualifiers; |
|
for ( i = 0 ; i < k ; i++) |
|
{ |
|
_getCIMQualifierFromSCMBQualifier( |
|
theCimQualifier, |
|
qualiArray[i], |
|
cls.base); |
|
|
|
newCimClass._rep->_qualifiers.addUnchecked(theCimQualifier); |
|
} |
|
} |
|
|
|
// If properties are in that class |
|
if (0 != cls.hdr->propertySet.number) |
|
{ |
|
Uint32 i, k = cls.hdr->propertySet.number; |
|
for ( i = 0 ; i < k ; i++) |
|
{ |
|
newCimClass._rep->_properties.append( |
|
_getCIMPropertyAtNodeIndex(i)); |
|
} |
|
} |
|
|
|
cimClass = newCimClass; |
|
} |
|
|
|
CIMProperty SCMOClass::_getCIMPropertyAtNodeIndex(Uint32 nodeIdx) const |
|
{ |
|
CIMValue theCimValue; |
|
CIMProperty retCimProperty; |
|
|
|
SCMBClassPropertyNode& clsProp = |
|
((SCMBClassPropertyNode*) |
|
&(cls.base[cls.hdr->propertySet.nodeArray.start]))[nodeIdx]; |
|
|
|
// get the default value |
|
SCMOInstance::_getCIMValueFromSCMBValue( |
|
theCimValue, |
|
clsProp.theProperty.defaultValue, |
|
cls.base); |
|
|
|
// have to check if there is the origin class name set. |
|
// An empty origin class name is differnt then a NULL class name |
|
if (0 != clsProp.theProperty.originClassName.start) |
|
{ |
|
retCimProperty = CIMProperty( |
|
CIMNameCast(_newCimString(clsProp.theProperty.name,cls.base)), |
|
theCimValue, |
|
theCimValue.getArraySize(), |
|
CIMNameCast( |
|
_newCimString(clsProp.theProperty.refClassName,cls.base)), |
|
CIMNameCast( |
|
_newCimString(clsProp.theProperty.originClassName,cls.base)), |
|
clsProp.theProperty.flags.propagated); |
|
} |
|
else |
|
{ |
|
retCimProperty = CIMProperty( |
|
CIMNameCast(_newCimString(clsProp.theProperty.name,cls.base)), |
|
theCimValue, |
|
theCimValue.getArraySize(), |
|
CIMNameCast( |
|
_newCimString(clsProp.theProperty.refClassName,cls.base)), |
|
CIMName(), |
|
clsProp.theProperty.flags.propagated); |
|
} |
|
|
|
SCMBQualifier* qualiArray = |
|
(SCMBQualifier*) |
|
&(cls.base[clsProp.theProperty.qualifierArray.start]); |
|
|
|
CIMQualifier theCimQualifier; |
|
Uint32 i, k = clsProp.theProperty.numberOfQualifiers; |
|
for ( i = 0 ; i < k ; i++) |
|
{ |
|
_getCIMQualifierFromSCMBQualifier( |
|
theCimQualifier, |
|
qualiArray[i], |
|
cls.base); |
|
|
|
retCimProperty._rep->_qualifiers.addUnchecked(theCimQualifier); |
|
} |
|
|
|
return retCimProperty; |
|
|
|
} |
|
|
|
void SCMOClass::_getCIMQualifierFromSCMBQualifier( |
|
CIMQualifier& theCimQualifier, |
|
const SCMBQualifier& scmbQualifier, |
|
const char* base) |
|
|
|
{ |
|
|
|
CIMName theCimQualiName; |
|
CIMValue theCimValue; |
| |
|
SCMOInstance::_getCIMValueFromSCMBValue( |
|
theCimValue, |
|
scmbQualifier.value, |
|
base); |
|
|
|
if (scmbQualifier.name == QUALNAME_USERDEFINED) |
|
{ |
|
theCimQualiName = _newCimString(scmbQualifier.userDefName,base); |
|
} |
|
else |
|
{ |
|
theCimQualiName = String( |
|
SCMOClass::qualifierNameStrLit(scmbQualifier.name).str, |
|
SCMOClass::qualifierNameStrLit(scmbQualifier.name).size); |
|
} |
|
|
|
theCimQualifier = CIMQualifier( |
|
theCimQualiName, |
|
theCimValue, |
|
scmbQualifier.flavor, |
|
scmbQualifier.propagated); |
} | } |
| |
void SCMOClass::getKeyNamesAsString(Array<String>& keyNames) const | void SCMOClass::getKeyNamesAsString(Array<String>& keyNames) const |
|
|
| |
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; |
|
|
| |
} | } |
| |
|
|
SCMO_RC SCMOClass::_getProperyNodeIndex(Uint32& node, const char* name) const | SCMO_RC SCMOClass::_getProperyNodeIndex(Uint32& node, const char* name) const |
{ | { |
| |
|
|
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(CIMClass& theCIMClass) |
void SCMOClass::_setClassProperties(PropertySet& theCIMProperties) |
{ | { |
Uint32 noProps = theCIMClass.getPropertyCount(); |
Uint32 noProps = theCIMProperties.size(); |
Uint64 start, startKeyIndexList; | Uint64 start, startKeyIndexList; |
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) |
{ | { |
|
|
0, | 0, |
PEGASUS_PROPERTY_SCMB_HASHSIZE*sizeof(Uint32)); | PEGASUS_PROPERTY_SCMB_HASHSIZE*sizeof(Uint32)); |
| |
_clearKeyPropertyMask(); |
|
| |
for (Uint32 i = 0; i < noProps; i++) | for (Uint32 i = 0; i < noProps; i++) |
{ | { |
| |
_setProperty(start,&isKey ,theCIMClass.getProperty(i)); |
_setProperty(start,&isKey ,theCIMProperties[i]); |
if(isKey) | if(isKey) |
{ | { |
// if the property is a key | // if the property is a key |
|
|
// 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++) |
{ | { |
| |
_setClassKeyBinding(start,theCIMClass.getProperty(keyIndex[i])); |
_setClassKeyBinding(start,theCIMProperties[keyIndex[i]]); |
// Adjust ordered set management structures. | // Adjust ordered set management structures. |
_insertKeyBindingIntoOrderedSet(start,i); | _insertKeyBindingIntoOrderedSet(start,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(), |
|
|
// calculate the new hash tag | // calculate the new hash tag |
scmoKeyBindNode->nameHashTag = | scmoKeyBindNode->nameHashTag = |
_generateSCMOStringTag(scmoKeyBindNode->name,cls.base); | _generateSCMOStringTag(scmoKeyBindNode->name,cls.base); |
scmoKeyBindNode->type = _cimTypeToKeyBindType(propRep->_value.getType()); |
scmoKeyBindNode->type = propRep->_value.getType(); |
scmoKeyBindNode->hasNext=false; | scmoKeyBindNode->hasNext=false; |
scmoKeyBindNode->nextNode=0; | scmoKeyBindNode->nextNode=0; |
| |
} | } |
| |
void SCMOClass::_clearKeyPropertyMask() |
|
{ |
|
|
|
Uint64 *keyMask; |
|
|
|
// Calculate the real pointer to the Uint64 array |
|
keyMask = (Uint64*)&cls.base[cls.hdr->keyPropertyMask.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(keyMask,0, sizeof(Uint64)*(((cls.hdr->propertySet.number-1)/64)+1)); |
|
|
|
} |
|
|
|
void SCMOClass::_setPropertyAsKeyInMask(Uint32 i) | void SCMOClass::_setPropertyAsKeyInMask(Uint32 i) |
{ | { |
Uint64 *keyMask; | Uint64 *keyMask; |
|
|
| |
// 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]); |
| |
keyMask[idx] = keyMask[idx] | filter ; | keyMask[idx] = keyMask[idx] | filter ; |
} | } |
|
|
| |
// 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]); |
| |
return keyMask[idx] & filter ; | return keyMask[idx] & filter ; |
| |
|
|
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; |
} | } |
void SCMOClass::_setClassQualifers(CIMClass& theCIMClass) |
|
|
void SCMOClass::_setClassQualifers(const CIMQualifierList& theQualifierList) |
{ | { |
| |
Uint32 noQuali = theCIMClass.getQualifierCount(); |
Uint32 noQuali = theQualifierList.getCount(); |
Uint64 start; | Uint64 start; |
| |
cls.hdr->numberOfQualifiers = noQuali; | cls.hdr->numberOfQualifiers = noQuali; |
|
|
&cls.mem); | &cls.mem); |
for (Uint32 i = 0; i < noQuali; i++) | for (Uint32 i = 0; i < noQuali; i++) |
{ | { |
_setQualifier(start,theCIMClass.getQualifier(i)); |
_setQualifier(start,theQualifierList.getQualifier(i)); |
start = start + sizeof(SCMBQualifier); | start = start + sizeof(SCMBQualifier); |
| |
} | } |
|
|
else | else |
{ | { |
cls.hdr->qualifierArray.start=0; | cls.hdr->qualifierArray.start=0; |
cls.hdr->qualifierArray.length=0; |
cls.hdr->qualifierArray.size=0; |
} | } |
|
|
|
|
} | } |
| |
QualifierNameEnum SCMOClass::_setQualifier( | QualifierNameEnum SCMOClass::_setQualifier( |
|
|
return name; | return name; |
} | } |
| |
void SCMOClass::_setValue(Uint64 start, const CIMValue& theCIMValue) |
void SCMOClass::_setValue( |
|
Uint64 start, |
|
const CIMValue& theCIMValue) |
{ | { |
Uint64 valueStart; | Uint64 valueStart; |
| |
|
|
scmoValue->valueArraySize = 0; | scmoValue->valueArraySize = 0; |
scmoValue->flags.isNull = rep->isNull; | scmoValue->flags.isNull = rep->isNull; |
scmoValue->flags.isArray = rep->isArray; | scmoValue->flags.isArray = rep->isArray; |
// Only initalized by for completeness. |
|
scmoValue->flags.isSet = false; | scmoValue->flags.isSet = false; |
| |
if (rep->isNull) | if (rep->isNull) |
|
|
| |
if (scmoValue->flags.isArray) | if (scmoValue->flags.isArray) |
{ | { |
SCMOInstance::_setArrayValue( |
SCMOInstance::_setUnionArrayValue( |
valueStart, | valueStart, |
&cls.mem, | &cls.mem, |
rep->type, | rep->type, |
// 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.size, |
rep->u); | rep->u); |
} | } |
else | else |
|
|
valueStart, | valueStart, |
&cls.mem, | &cls.mem, |
rep->type, | rep->type, |
|
cls.hdr->nameSpace.start, |
|
cls.hdr->nameSpace.size, |
rep->u); | rep->u); |
} | } |
} | } |
|
|
// list. | // list. |
for (Uint32 i = 1; i < _NUM_QUALIFIER_NAMES; i++) | for (Uint32 i = 1; i < _NUM_QUALIFIER_NAMES; i++) |
{ | { |
if (_qualifierNameStrLit[i].size == length) |
if (qualifierNameStrLit(i).size == length) |
{ | { |
// TBD: Make it more efficent... | // TBD: Make it more efficent... |
if(String::equalNoCase( | if(String::equalNoCase( |
theCIMName.getString(), | theCIMName.getString(), |
_qualifierNameStrLit[i].str)) |
qualifierNameStrLit(i).str)) |
{ | { |
return (QualifierNameEnum)i; | return (QualifierNameEnum)i; |
} | } |
|
|
(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, |
len)); | len)); |
} | } |
| |
inline SCMO_RC SCMOClass::_isNodeSameType( |
SCMO_RC SCMOClass::_isNodeSameType( |
Uint32 node, | Uint32 node, |
CIMType type, | CIMType type, |
Boolean isArray) const |
Boolean isArray, |
|
CIMType& realType) const |
{ | { |
|
|
SCMBClassPropertyNode* nodeArray = | SCMBClassPropertyNode* nodeArray = |
(SCMBClassPropertyNode*) | (SCMBClassPropertyNode*) |
&(cls.base[cls.hdr->propertySet.nodeArray.start]); | &(cls.base[cls.hdr->propertySet.nodeArray.start]); |
| |
|
// The type stored in the class information is set on realType. |
|
// It must be used in further calls to guaranty consistence. |
|
realType = nodeArray[node].theProperty.defaultValue.valueType; |
| |
if(nodeArray[node].theProperty.defaultValue.valueType != type) | if(nodeArray[node].theProperty.defaultValue.valueType != type) |
{ | { |
|
// Accept an property of type instance also |
|
// for an CIMTYPE_OBJECT property. |
|
if (!(type == CIMTYPE_INSTANCE && |
|
nodeArray[node].theProperty.defaultValue.valueType |
|
== CIMTYPE_OBJECT)) |
|
{ |
return SCMO_WRONG_TYPE; | return SCMO_WRONG_TYPE; |
} | } |
|
} |
| |
if (isArray) | if (isArray) |
{ | { |
|
|
return SCMO_OK; | return SCMO_OK; |
| |
} | } |
|
|
/***************************************************************************** | /***************************************************************************** |
* The SCMOInstance methods | * The SCMOInstance methods |
*****************************************************************************/ | *****************************************************************************/ |
| |
SCMOInstance::SCMOInstance() | SCMOInstance::SCMOInstance() |
{ | { |
inst.base = NULL; |
inst.base = 0; |
} | } |
| |
SCMOInstance::SCMOInstance(SCMOClass baseClass) |
SCMOInstance::SCMOInstance(SCMOClass& baseClass) |
{ | { |
_initSCMOInstance(new SCMOClass(baseClass),false,false); |
_initSCMOInstance(new SCMOClass(baseClass)); |
} | } |
| |
SCMOInstance::SCMOInstance( | SCMOInstance::SCMOInstance( |
SCMOClass baseClass, |
SCMOClass& baseClass, |
Boolean includeQualifiers, | Boolean includeQualifiers, |
Boolean includeClassOrigin, |
Boolean includeClassOrigin) |
const char** propertyList) |
|
{ | { |
| |
_initSCMOInstance( |
_initSCMOInstance(new SCMOClass(baseClass)); |
new SCMOClass(baseClass), |
|
includeQualifiers, |
|
includeClassOrigin); |
|
| |
setPropertyFilter(propertyList); |
inst.hdr->flags.includeQualifiers=includeQualifiers; |
|
inst.hdr->flags.includeClassOrigin=includeClassOrigin; |
| |
} | } |
| |
SCMOInstance::SCMOInstance(SCMOClass baseClass, const CIMObjectPath& cimObj) |
SCMOInstance::SCMOInstance(SCMOClass& baseClass, const CIMObjectPath& cimObj) |
{ | { |
_initSCMOInstance(new SCMOClass(baseClass),false,false); |
_initSCMOInstance(new SCMOClass(baseClass)); |
| |
_setCIMObjectPath(cimObj); | _setCIMObjectPath(cimObj); |
|
|
} | } |
| |
SCMOInstance::SCMOInstance(SCMOClass baseClass, const CIMInstance& cimInstance) |
SCMOInstance::SCMOInstance(SCMOClass& baseClass, const CIMInstance& cimInstance) |
{ | { |
| |
CIMPropertyRep* propRep; |
_initSCMOInstance(new SCMOClass(baseClass)); |
Uint32 propNode; |
|
Uint64 valueStart; |
|
SCMO_RC rc; |
|
|
|
CIMInstanceRep* instRep = cimInstance._rep; |
|
Boolean hasQualifiers = (instRep->_qualifiers.getCount()>0); |
|
Boolean hasClassOrigin = false; |
|
| |
_initSCMOInstance(new SCMOClass(baseClass),hasQualifiers,hasClassOrigin); |
_setCIMInstance(cimInstance); |
| |
_setCIMObjectPath(instRep->_reference); |
} |
| |
// Copy all properties |
SCMOInstance::SCMOInstance(CIMClass& theCIMClass, const char* altNameSpace) |
for (Uint32 i = 0, k = instRep->_properties.size(); i < k; i++) |
|
{ |
|
propRep = instRep->_properties[i]._rep; |
|
// if not already detected that qualifiers are specified and |
|
// there are qualifers at that property. |
|
if (!hasQualifiers && propRep->getQualifierCount() > 0) |
|
{ | { |
includeQualifiers(); |
_initSCMOInstance(new SCMOClass(theCIMClass,altNameSpace)); |
|
|
} | } |
// if not already detected that class origins are specified and |
|
// there is a class origin specified at that property. |
SCMOInstance::SCMOInstance( |
if (!hasClassOrigin && !propRep->_classOrigin.isNull()) |
const CIMInstance& cimInstance, |
|
const char* altNameSpace, |
|
Uint32 altNSLen) |
{ | { |
includeClassOrigins(); |
SCMOClass theSCMOClass = _getSCMOClass( |
} |
cimInstance._rep->_reference, |
|
altNameSpace, |
|
altNSLen); |
| |
// get the property node index for the property |
_initSCMOInstance( new SCMOClass(theSCMOClass)); |
rc = inst.hdr->theClass->_getProperyNodeIndex( |
|
propNode, |
|
(const char*)propRep->_name.getString().getCString()); |
|
| |
if (rc != SCMO_OK) |
if(theSCMOClass.isEmpty()) |
{ |
|
throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NO_SUCH_PROPERTY, |
|
propRep->_name.getString()); |
|
} |
|
rc = inst.hdr->theClass->_isNodeSameType( |
|
propNode, |
|
propRep->_value._rep->type, |
|
propRep->_value._rep->isArray); |
|
if (rc == SCMO_OK) |
|
{ | { |
_setCIMValueAtNodeIndex(propNode, propRep->_value._rep); |
// flag the instance as compromized |
|
inst.hdr->flags.isCompromised=true; |
} | } |
else | else |
{ | { |
throw PEGASUS_CIM_EXCEPTION(CIM_ERR_TYPE_MISMATCH, |
_setCIMInstance(cimInstance); |
propRep->_name.getString()); |
|
} | } |
} | } |
| |
} |
SCMOInstance::SCMOInstance( |
|
const CIMObject& cimObject, |
SCMO_RC SCMOInstance::getCIMInstance(CIMInstance& cimInstance) const |
const char* altNameSpace, |
|
Uint32 altNSLen) |
{ | { |
|
if (cimObject.isClass()) |
|
{ |
|
CIMClass cimClass(cimObject); |
| |
SCMO_RC rc = SCMO_OK; |
_initSCMOInstance(new SCMOClass(cimClass,altNameSpace)); |
Uint32 noProps; |
|
CIMObjectPath objPath; |
|
|
|
// For better usability define pointers to SCMO Class data structures. |
|
SCMBClass_Main* clshdr = inst.hdr->theClass->cls.hdr; |
|
char* clsbase = inst.hdr->theClass->cls.base; |
|
|
|
_getCIMObjectPath(objPath); |
|
|
|
cimInstance._rep = new CIMInstanceRep(objPath); |
|
| |
if (inst.hdr->flags.includeQualifiers) |
inst.hdr->flags.isClassOnly=true; |
|
} |
|
else |
{ | { |
SCMBQualifier* qualiArray = |
CIMInstance cimInstance(cimObject); |
(SCMBQualifier*)&(clsbase[clshdr->qualifierArray.start]); |
|
|
|
CIMName qualiName; |
|
CIMValue theValue; |
|
| |
Uint32 i, k = clshdr->numberOfQualifiers; |
SCMOClass theSCMOClass = _getSCMOClass( |
|
cimInstance._rep->_reference, |
|
altNameSpace, |
|
altNSLen); |
| |
for ( i = 0 ; i < k ; i++) |
_initSCMOInstance( new SCMOClass(theSCMOClass)); |
{ |
|
_getCIMValueFromSCMBValue(theValue,qualiArray[i].value,clsbase); |
|
| |
if (qualiArray[i].name == QUALNAME_USERDEFINED) |
if(theSCMOClass.isEmpty()) |
{ | { |
qualiName = NEWCIMSTR(qualiArray[i].userDefName,clsbase); |
// flag the instance as compromized |
|
inst.hdr->flags.isCompromised=true; |
} | } |
else | else |
{ | { |
qualiName = String( |
_setCIMInstance(cimInstance); |
_qualifierNameStrLit[qualiArray[i].name].str, |
|
_qualifierNameStrLit[qualiArray[i].name].size); |
|
} | } |
|
|
cimInstance._rep->_qualifiers.addUnchecked( |
|
CIMQualifier( |
|
qualiName, |
|
theValue, |
|
qualiArray[i].flavor, |
|
qualiArray[i].propagated)); |
|
} | } |
} | } |
| |
if (inst.hdr->flags.isFiltered) |
SCMOInstance::SCMOInstance( |
|
const CIMObjectPath& cimObj, |
|
const char* altNameSpace, |
|
Uint32 altNSLen) |
|
{ |
|
SCMOClass theSCMOClass = _getSCMOClass( |
|
cimObj, |
|
altNameSpace, |
|
altNSLen); |
|
|
|
_initSCMOInstance( new SCMOClass(theSCMOClass)); |
|
|
|
if(theSCMOClass.isEmpty()) |
|
{ |
|
// flag the instance as compromized |
|
inst.hdr->flags.isCompromised=true; |
|
} |
|
else |
|
{ |
|
_setCIMObjectPath(cimObj); |
|
} |
|
} |
|
|
|
void SCMOInstance::_destroyExternalReferences() |
{ | { |
// Get absolut pointer to property filter index map of the instance |
_destroyExternalReferencesInternal(inst.mem); |
Uint32* propertyFilterIndexMap = |
} |
(Uint32*)&(inst.base[inst.hdr->propertyFilterIndexMap.start]); |
|
| |
for(Uint32 i = 0, k = inst.hdr->filterProperties; i<k; i++) |
SCMOClass SCMOInstance::_getSCMOClass( |
|
const CIMObjectPath& theCIMObj, |
|
const char* altNS, |
|
Uint32 altNSlength) |
{ | { |
// Get absolut pointer to property filter index map |
SCMOClass theClass; |
// of the instance get the real node index of the property. |
|
CIMProperty theProperty=_getCIMPropertyAtNodeIndex( |
|
propertyFilterIndexMap[i]); |
|
| |
cimInstance._rep->_properties.append(theProperty); |
if (theCIMObj.getClassName().isNull()) |
|
{ |
|
return SCMOClass(); |
} | } |
| |
|
if (theCIMObj.getNameSpace().isNull()) |
|
{ |
|
// the name space of the object path is empty, |
|
// 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 | else |
{ | { |
|
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; |
|
} |
|
|
|
#define PEGASUS_SIZE_REFERENCE_INDEX_ARRAY 8 |
|
|
|
void SCMOInstance::_setExtRefIndex(SCMBUnion* pInst, SCMBMgmt_Header** pmem) |
|
{ |
|
|
|
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) |
|
{ |
|
Uint64 oldArrayStart = memHdr->extRefIndexArray.start; |
|
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++) |
|
{ |
|
newArray[i] = oldArray[i]; |
|
} |
|
} |
|
|
|
// Get absolute pointer to the array |
|
Uint64* array = |
|
(Uint64*)&(((char*)(*pmem))[memHdr->extRefIndexArray.start]); |
|
// 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++; |
|
|
|
} |
|
|
|
SCMOInstance* SCMOInstance::getExtRef(Uint32 idx) const |
|
{ |
|
Uint64* array = |
|
(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() |
|
{ |
|
Uint32 number = inst.mem->numberExtRef; |
|
|
|
if (0 != number) |
|
{ |
|
SCMBUnion* pUnion; |
|
Uint64* array = |
|
(Uint64*)&(inst.base[inst.mem->extRefIndexArray.start]); |
|
for (Uint32 i = 0; i < number; i++) |
|
{ |
|
pUnion = (SCMBUnion*)(&(inst.base[array[i]])); |
|
if (0 != pUnion) |
|
{ |
|
pUnion->extRefPtr = new SCMOInstance(*(pUnion->extRefPtr)); |
|
} |
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
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++) |
|
{ |
|
if (theInstanceKeyBindingNodeArray[i].isSet) |
|
{ |
|
// only references can be a key binding |
|
if (theClassKeyBindNodeArray[i].type == CIMTYPE_REFERENCE) |
|
{ |
|
_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 rc = SCMO_OK; |
|
CIMObjectPath objPath; |
|
|
|
// For better usability define pointers to SCMO Class data structures. |
|
SCMBClass_Main* clshdr = inst.hdr->theClass.ptr->cls.hdr; |
|
char* clsbase = inst.hdr->theClass.ptr->cls.base; |
|
|
|
getCIMObjectPath(objPath); |
|
|
|
CIMInstance newInstance; |
|
newInstance._rep = new CIMInstanceRep(objPath); |
|
|
|
if (inst.hdr->flags.includeQualifiers) |
|
{ |
|
SCMBQualifier* qualiArray = |
|
(SCMBQualifier*)&(clsbase[clshdr->qualifierArray.start]); |
|
|
|
|
|
CIMQualifier theCimQualifier; |
|
Uint32 i, k = clshdr->numberOfQualifiers; |
|
|
|
for ( i = 0 ; i < k ; i++) |
|
{ |
|
SCMOClass::_getCIMQualifierFromSCMBQualifier( |
|
theCimQualifier, |
|
qualiArray[i], |
|
clsbase); |
|
|
|
newInstance._rep->_qualifiers.addUnchecked(theCimQualifier); |
|
} |
|
} |
|
|
|
if (inst.hdr->flags.exportSetOnly) |
|
{ |
for(Uint32 i = 0, k = inst.hdr->numberProperties; i<k; i++) | for(Uint32 i = 0, k = inst.hdr->numberProperties; i<k; i++) |
{ | { |
|
SCMBValue* theInstPropArray = |
|
(SCMBValue*)&(inst.base[inst.hdr->propertyArray.start]); |
|
|
|
// was the property set by the provider ? |
|
if(theInstPropArray[i].flags.isSet) |
|
{ |
// no filtering. Counter is node index | // no filtering. Counter is node index |
CIMProperty theProperty=_getCIMPropertyAtNodeIndex(i); | CIMProperty theProperty=_getCIMPropertyAtNodeIndex(i); |
| |
cimInstance._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; |
|
|
return rc; | return rc; |
} | } |
| |
void SCMOInstance::_getCIMObjectPath(CIMObjectPath& cimObj) const |
void SCMOInstance::getCIMObjectPath(CIMObjectPath& cimObj) const |
{ | { |
|
Array<CIMKeyBinding> keys; |
|
|
// 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 = |
(SCMBKeyBindingNode*)&clsbase[clshdr->keyBindingSet.nodeArray.start]; |
(SCMBKeyBindingNode*)&(clsbase[clshdr->keyBindingSet.nodeArray.start]); |
| |
// Address the instance keybinding information | // Address the instance keybinding information |
SCMBInstanceKeyBinding* scmoInstArray = |
SCMBKeyBindingValue* scmoInstArray = |
(SCMBInstanceKeyBinding*)&inst.base[inst.hdr->keyBindingArray.start]; |
(SCMBKeyBindingValue*)&(inst.base[inst.hdr->keyBindingArray.start]); |
| |
Uint32 numberKeyBindings = inst.hdr->numberKeyBindings; | Uint32 numberKeyBindings = inst.hdr->numberKeyBindings; |
| |
|
CIMValue theKeyBindingValue; |
|
|
for (Uint32 i = 0; i < numberKeyBindings; i ++) | for (Uint32 i = 0; i < numberKeyBindings; i ++) |
{ | { |
if (scmoInstArray[i].isSet) | if (scmoInstArray[i].isSet) |
{ | { |
cimObj._rep->_keyBindings.append( |
_getCIMValueFromSCMBUnion( |
|
theKeyBindingValue, |
|
scmoClassArray[i].type, |
|
false, // can never be a null value |
|
false, // can never be an array |
|
0, |
|
scmoInstArray[i].data, |
|
inst.base); |
|
keys.append( |
|
CIMKeyBinding( |
|
CIMNameCast(_newCimString(scmoClassArray[i].name,clsbase)), |
|
theKeyBindingValue |
|
)); |
|
} |
|
} |
|
|
|
// 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) |
|
{ |
|
_getCIMValueFromSCMBUnion( |
|
theKeyBindingValue, |
|
theUserDefKBElement->type, |
|
false, // can never be a null value |
|
false, // can never be an array |
|
0, |
|
theUserDefKBElement->value.data, |
|
inst.base); |
|
|
|
keys.append( |
CIMKeyBinding( | CIMKeyBinding( |
CIMNameCast(NEWCIMSTR(scmoClassArray[i].name,clsbase)), |
CIMNameCast( |
NEWCIMSTR(scmoInstArray[i].value,inst.base), |
_newCimString(theUserDefKBElement->name,inst.base)), |
scmoClassArray[i].type)); |
theKeyBindingValue)); |
} | } |
|
theUserDefKBElement = |
|
(SCMBUserKeyBindingElement*) |
|
&(inst.base[theUserDefKBElement->nextElement.start]); |
|
} // for all user def. key bindings. |
} | } |
| |
cimObj._rep->_host = NEWCIMSTR(inst.hdr->hostName,inst.base); |
String host = _newCimString(inst.hdr->hostName,inst.base); |
cimObj._rep->_nameSpace = |
|
CIMNamespaceNameCast(NEWCIMSTR(clshdr->nameSpace,clsbase)); |
// Use name space and class name of the instance |
cimObj._rep->_className=CIMNameCast(NEWCIMSTR(clshdr->className,clsbase)); |
CIMNamespaceName nameSpace = |
|
CIMNamespaceNameCast(_newCimString(inst.hdr->instNameSpace,inst.base)); |
|
|
|
CIMName className = |
|
CIMNameCast(_newCimString(inst.hdr->instClassName,inst.base)); |
|
|
|
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); |
} | } |
|
|
(SCMBQualifier*) | (SCMBQualifier*) |
&(clsbase[clsProp.theProperty.qualifierArray.start]); | &(clsbase[clsProp.theProperty.qualifierArray.start]); |
| |
CIMName qualiName; |
CIMQualifier theCimQualifier; |
| |
Uint32 i, k = clsProp.theProperty.numberOfQualifiers; | Uint32 i, k = clsProp.theProperty.numberOfQualifiers; |
for ( i = 0 ; i < k ; i++) | for ( i = 0 ; i < k ; i++) |
{ | { |
_getCIMValueFromSCMBValue(theValue,qualiArray[i].value,clsbase); |
SCMOClass::_getCIMQualifierFromSCMBQualifier( |
|
theCimQualifier, |
if (qualiArray[i].name == QUALNAME_USERDEFINED) |
qualiArray[i], |
{ |
clsbase); |
qualiName = NEWCIMSTR(qualiArray[i].userDefName,clsbase); |
|
} |
|
else |
|
{ |
|
qualiName = String( |
|
_qualifierNameStrLit[qualiArray[i].name].str, |
|
_qualifierNameStrLit[qualiArray[i].name].size); |
|
} |
|
| |
retProperty._rep->_qualifiers.addUnchecked( |
retProperty._rep->_qualifiers.addUnchecked(theCimQualifier); |
CIMQualifier( |
|
qualiName, |
|
theValue, |
|
qualiArray[i].flavor, |
|
qualiArray[i].propagated)); |
|
} | } |
} | } |
| |
return retProperty; | return retProperty; |
|
|
} | } |
| |
void SCMOInstance::_getCIMValueFromSCMBValue( |
void SCMOInstance::_getCIMValueFromSCMBUnion( |
CIMValue& cimV, | CIMValue& cimV, |
const SCMBValue& scmbV, |
const CIMType type, |
const char * base) const |
const Boolean isNull, |
|
const Boolean isArray, |
|
const Uint32 arraySize, |
|
const SCMBUnion& scmbUn, |
|
const char * base) |
{ | { |
if (scmbV.flags.isNull) |
|
|
const SCMBUnion* pscmbArrayUn = 0; |
|
|
|
if (isNull) |
{ | { |
cimV.setNullValue( |
cimV.setNullValue(type,isArray,arraySize); |
scmbV.valueType, |
|
scmbV.flags.isArray, |
|
scmbV.valueArraySize); |
|
return; | return; |
} | } |
| |
switch (scmbV.valueType) |
if (isArray) |
|
{ |
|
pscmbArrayUn =(SCMBUnion*)&(base[scmbUn.arrayValue.start]); |
|
} |
|
|
|
switch (type) |
{ | { |
| |
case CIMTYPE_UINT8: | case CIMTYPE_UINT8: |
{ | { |
if (scmbV.flags.isArray) |
if (isArray) |
{ | { |
const Uint8* u=(Uint8*)&(base[scmbV.value._arrayValue.start]); |
|
Array<Uint8> x; | Array<Uint8> x; |
x.append(u,scmbV.valueArraySize); |
for (Uint32 i = 0, k = arraySize; i < k ; i++) |
|
{ |
|
x.append(pscmbArrayUn[i].simple.val.u8); |
|
} |
cimV.set(x); | cimV.set(x); |
} | } |
else | else |
{ | { |
cimV.set(scmbV.value._uint8Value); |
cimV.set(scmbUn.simple.val.u8); |
} | } |
break; | break; |
} | } |
| |
case CIMTYPE_UINT16: | case CIMTYPE_UINT16: |
{ | { |
if (scmbV.flags.isArray) |
if (isArray) |
{ | { |
const Uint16* u=(Uint16*)&(base[scmbV.value._arrayValue.start]); |
|
Array<Uint16> x; | Array<Uint16> x; |
x.append(u,scmbV.valueArraySize); |
for (Uint32 i = 0, k = arraySize; i < k ; i++) |
|
{ |
|
x.append(pscmbArrayUn[i].simple.val.u16); |
|
} |
cimV.set(x); | cimV.set(x); |
} | } |
else | else |
{ | { |
cimV.set(scmbV.value._uint16Value); |
cimV.set(scmbUn.simple.val.u16); |
} | } |
break; | break; |
} | } |
| |
case CIMTYPE_UINT32: | case CIMTYPE_UINT32: |
{ | { |
if (scmbV.flags.isArray) |
if (isArray) |
{ | { |
const Uint32* u=(Uint32*)&(base[scmbV.value._arrayValue.start]); |
|
Array<Uint32> x; | Array<Uint32> x; |
x.append(u,scmbV.valueArraySize); |
for (Uint32 i = 0, k = arraySize; i < k ; i++) |
|
{ |
|
x.append(pscmbArrayUn[i].simple.val.u32); |
|
} |
cimV.set(x); | cimV.set(x); |
} | } |
else | else |
{ | { |
cimV.set(scmbV.value._uint32Value); |
cimV.set(scmbUn.simple.val.u32); |
} | } |
break; | break; |
} | } |
| |
case CIMTYPE_UINT64: | case CIMTYPE_UINT64: |
{ | { |
if (scmbV.flags.isArray) |
if (isArray) |
{ | { |
const Uint64* u=(Uint64*)&(base[scmbV.value._arrayValue.start]); |
|
Array<Uint64> x; | Array<Uint64> x; |
x.append(u,scmbV.valueArraySize); |
for (Uint32 i = 0, k = arraySize; i < k ; i++) |
|
{ |
|
x.append(pscmbArrayUn[i].simple.val.u64); |
|
} |
cimV.set(x); | cimV.set(x); |
} | } |
else | else |
{ | { |
cimV.set(scmbV.value._uint64Value); |
cimV.set(scmbUn.simple.val.u64); |
} | } |
break; | break; |
} | } |
| |
case CIMTYPE_SINT8: | case CIMTYPE_SINT8: |
{ | { |
if (scmbV.flags.isArray) |
if (isArray) |
{ | { |
const Sint8* u=(Sint8*)&(base[scmbV.value._arrayValue.start]); |
|
Array<Sint8> x; | Array<Sint8> x; |
x.append(u,scmbV.valueArraySize); |
for (Uint32 i = 0, k = arraySize; i < k ; i++) |
|
{ |
|
x.append(pscmbArrayUn[i].simple.val.s8); |
|
} |
cimV.set(x); | cimV.set(x); |
} | } |
else | else |
{ | { |
cimV.set(scmbV.value._sint8Value); |
cimV.set(scmbUn.simple.val.s8); |
} | } |
break; | break; |
} | } |
| |
case CIMTYPE_SINT16: | case CIMTYPE_SINT16: |
{ | { |
if (scmbV.flags.isArray) |
if (isArray) |
{ | { |
const Sint16* u=(Sint16*)&(base[scmbV.value._arrayValue.start]); |
|
Array<Sint16> x; | Array<Sint16> x; |
x.append(u,scmbV.valueArraySize); |
for (Uint32 i = 0, k = arraySize; i < k ; i++) |
|
{ |
|
x.append(pscmbArrayUn[i].simple.val.s16); |
|
} |
cimV.set(x); | cimV.set(x); |
} | } |
else | else |
{ | { |
cimV.set(scmbV.value._sint16Value); |
cimV.set(scmbUn.simple.val.s16); |
} | } |
break; | break; |
} | } |
| |
case CIMTYPE_SINT32: | case CIMTYPE_SINT32: |
{ | { |
if (scmbV.flags.isArray) |
if (isArray) |
{ | { |
const Sint32* u=(Sint32*)&(base[scmbV.value._arrayValue.start]); |
|
Array<Sint32> x; | Array<Sint32> x; |
x.append(u,scmbV.valueArraySize); |
for (Uint32 i = 0, k = arraySize; i < k ; i++) |
|
{ |
|
x.append(pscmbArrayUn[i].simple.val.s32); |
|
} |
cimV.set(x); | cimV.set(x); |
} | } |
else | else |
{ | { |
cimV.set(scmbV.value._sint32Value); |
cimV.set(scmbUn.simple.val.s32); |
} | } |
break; | break; |
} | } |
| |
case CIMTYPE_SINT64: | case CIMTYPE_SINT64: |
{ | { |
if (scmbV.flags.isArray) |
if (isArray) |
{ | { |
const Sint64* u=(Sint64*)&(base[scmbV.value._arrayValue.start]); |
|
Array<Sint64> x; | Array<Sint64> x; |
x.append(u,scmbV.valueArraySize); |
for (Uint32 i = 0, k = arraySize; i < k ; i++) |
|
{ |
|
x.append(pscmbArrayUn[i].simple.val.s64); |
|
} |
cimV.set(x); | cimV.set(x); |
} | } |
else | else |
{ | { |
cimV.set(scmbV.value._sint64Value); |
cimV.set(scmbUn.simple.val.s64); |
} | } |
break; | break; |
} | } |
| |
case CIMTYPE_REAL32: | case CIMTYPE_REAL32: |
{ | { |
if (scmbV.flags.isArray) |
if (isArray) |
{ | { |
const Real32* u=(Real32*)&(base[scmbV.value._arrayValue.start]); |
|
Array<Real32> x; | Array<Real32> x; |
x.append(u,scmbV.valueArraySize); |
for (Uint32 i = 0, k = arraySize; i < k ; i++) |
|
{ |
|
x.append(pscmbArrayUn[i].simple.val.r32); |
|
} |
cimV.set(x); | cimV.set(x); |
} | } |
else | else |
{ | { |
cimV.set(scmbV.value._real32Value); |
cimV.set(scmbUn.simple.val.r32); |
} | } |
break; | break; |
} | } |
| |
case CIMTYPE_REAL64: | case CIMTYPE_REAL64: |
{ | { |
if (scmbV.flags.isArray) |
if (isArray) |
{ | { |
const Real64* u=(Real64*)&(base[scmbV.value._arrayValue.start]); |
|
Array<Real64> x; | Array<Real64> x; |
x.append(u,scmbV.valueArraySize); |
for (Uint32 i = 0, k = arraySize; i < k ; i++) |
|
{ |
|
x.append(pscmbArrayUn[i].simple.val.r64); |
|
} |
cimV.set(x); | cimV.set(x); |
} | } |
else | else |
{ | { |
cimV.set(scmbV.value._real64Value); |
cimV.set(scmbUn.simple.val.r64); |
} | } |
break; | break; |
} | } |
| |
case CIMTYPE_CHAR16: | case CIMTYPE_CHAR16: |
{ | { |
if (scmbV.flags.isArray) |
if (isArray) |
{ | { |
const Char16* u=(Char16*)&(base[scmbV.value._arrayValue.start]); |
|
Array<Char16> x; | Array<Char16> x; |
x.append(u,scmbV.valueArraySize); |
for (Uint32 i = 0, k = arraySize; i < k ; i++) |
|
{ |
|
x.append(Char16(pscmbArrayUn[i].simple.val.c16)); |
|
} |
cimV.set(x); | cimV.set(x); |
} | } |
else | else |
{ | { |
cimV.set(scmbV.value._char16Value); |
cimV.set(Char16(scmbUn.simple.val.c16)); |
} | } |
break; | break; |
} | } |
| |
case CIMTYPE_BOOLEAN: | case CIMTYPE_BOOLEAN: |
{ | { |
if (scmbV.flags.isArray) |
if (isArray) |
{ | { |
const Boolean* u= |
|
(Boolean*)&(base[scmbV.value._arrayValue.start]); |
|
Array<Boolean> x; | Array<Boolean> x; |
x.append(u,scmbV.valueArraySize); |
for (Uint32 i = 0, k = arraySize; i < k ; i++) |
|
{ |
|
x.append(pscmbArrayUn[i].simple.val.bin); |
|
} |
cimV.set(x); | cimV.set(x); |
} | } |
else | else |
{ | { |
cimV.set(scmbV.value._booleanValue); |
cimV.set(scmbUn.simple.val.bin); |
} | } |
break; | break; |
} | } |
| |
case CIMTYPE_STRING: | case CIMTYPE_STRING: |
{ | { |
if (scmbV.flags.isArray) |
if (isArray) |
{ | { |
// get the pointer to the array of relative SCMB pointers |
|
const SCMBDataPtr *ptr = |
|
(SCMBDataPtr*)&(base[scmbV.value._arrayValue.start]); |
|
| |
Array<String> x; | Array<String> x; |
| |
for (Uint32 i = 0, k = scmbV.valueArraySize; i < k ; i++) |
for (Uint32 i = 0, k = arraySize; i < k ; i++) |
{ | { |
x.append(NEWCIMSTR(ptr[i],base)); |
x.append(_newCimString(pscmbArrayUn[i].stringValue,base)); |
} | } |
cimV.set(x); | cimV.set(x); |
} | } |
else | else |
{ | { |
cimV.set(NEWCIMSTR(scmbV.value._stringValue,base)); |
cimV.set(_newCimString(scmbUn.stringValue,base)); |
} | } |
break; | break; |
} | } |
| |
case CIMTYPE_DATETIME: | case CIMTYPE_DATETIME: |
{ | { |
if (scmbV.flags.isArray) |
if (isArray) |
{ | { |
// get the pointer to the array of SCMBDateTime |
|
const SCMBDateTime *ptr = |
|
(SCMBDateTime*)&(base[scmbV.value._arrayValue.start]); |
|
|
|
Array<CIMDateTime> x; | Array<CIMDateTime> x; |
| |
for (Uint32 i = 0, k = scmbV.valueArraySize; i < k ; i++) |
for (Uint32 i = 0, k = arraySize; i < k ; i++) |
{ | { |
x.append(CIMDateTime(&(ptr[i]))); |
x.append(CIMDateTime(&(pscmbArrayUn[i].dateTimeValue))); |
} | } |
cimV.set(x); | cimV.set(x); |
} | } |
else | else |
{ | { |
cimV.set(CIMDateTime(&scmbV.value._dateTimeValue)); |
cimV.set(CIMDateTime(&scmbUn.dateTimeValue)); |
} | } |
break; | break; |
| |
} | } |
| |
case CIMTYPE_REFERENCE: | case CIMTYPE_REFERENCE: |
|
{ |
|
CIMObjectPath theObjPath; |
| |
break; |
if(isArray) |
|
{ |
case CIMTYPE_OBJECT: |
Array<CIMObjectPath> x; |
|
for (Uint32 i = 0, k = arraySize; i < k ; i++) |
break; |
{ |
|
if (0 != pscmbArrayUn[i].extRefPtr) |
case CIMTYPE_INSTANCE: |
{ |
|
pscmbArrayUn[i].extRefPtr->getCIMObjectPath(theObjPath); |
break; |
x.append(theObjPath); |
} | } |
|
else |
|
{ |
|
// set an empty object |
|
x.append(CIMObjectPath()); |
} | } |
|
} |
void SCMOInstance::_setCIMObjectPath(const CIMObjectPath& cimObj) |
cimV.set(x); |
|
} |
|
else |
{ | { |
CIMObjectPathRep* objRep = cimObj._rep; |
|
SCMO_RC rc; |
|
|
|
// For better usability define pointers to SCMO Class data structures. |
|
SCMBClass_Main* clshdr = inst.hdr->theClass->cls.hdr; |
|
char* clsbase = inst.hdr->theClass->cls.base; |
|
| |
CString className = objRep->_className.getString().getCString(); |
if (0 != scmbUn.extRefPtr) |
CString nameSpace = objRep->_nameSpace.getString().getCString(); |
|
|
|
// Is the instance from the same class and name space ? |
|
if (!(_equalNoCaseUTF8Strings( |
|
clshdr->className, |
|
clsbase, |
|
(const char*)className, |
|
strlen(className)) && |
|
_equalNoCaseUTF8Strings( |
|
clshdr->nameSpace, |
|
clsbase, |
|
(const char*)nameSpace, |
|
strlen(nameSpace))) |
|
) |
|
{ | { |
throw PEGASUS_CIM_EXCEPTION(CIM_ERR_INVALID_CLASS, |
scmbUn.extRefPtr->getCIMObjectPath(theObjPath); |
objRep->_className.getString()); |
cimV.set(theObjPath); |
} | } |
|
else |
//set host name |
|
_setString(objRep->_host,inst.hdr->hostName,&inst.mem ); |
|
|
|
if (inst.hdr->numberKeyBindings < objRep->_keyBindings.size()) |
|
{ | { |
String message("CIMObjectPath has more keybindings " |
cimV.set(CIMObjectPath()); |
"than the associatied class key propertties."); |
|
throw CIMException(CIM_ERR_FAILED, message); |
|
} | } |
|
} |
for (Uint32 i = 0, k = objRep->_keyBindings.size(); i < k; i++) |
break; |
|
} |
|
case CIMTYPE_OBJECT: |
{ | { |
|
CIMInstance cimInstance; |
|
CIMClass cimClass; |
| |
rc = setKeyBinding( |
if(isArray) |
(const char*) |
|
objRep->_keyBindings[i].getName().getString().getCString(), |
|
objRep->_keyBindings[i].getType(), |
|
(const char*) objRep->_keyBindings[i].getValue().getCString()); |
|
|
|
if (rc != SCMO_OK) |
|
{ | { |
switch (rc) |
Array<CIMObject> x; |
|
for (Uint32 i = 0, k = arraySize; i < k ; i++) |
{ | { |
case SCMO_NOT_FOUND: |
if (0 != pscmbArrayUn[i].extRefPtr) |
{ | { |
String message("CIMObjectPath key binding "); |
// check if the Object is an emedded instance or class |
message.append( |
if(pscmbArrayUn[i].extRefPtr-> |
objRep->_keyBindings[i].getName().getString()); |
inst.hdr->flags.isClassOnly) |
message.append(" not found."); |
|
throw CIMException(CIM_ERR_FAILED, message); |
|
} |
|
default: |
|
{ | { |
String message("CIMObjectPath key binding "); |
pscmbArrayUn[i].extRefPtr-> |
message.append( |
inst.hdr->theClass.ptr->getCIMClass(cimClass); |
objRep->_keyBindings[i].getName().getString()); |
x.append(CIMObject(cimClass)); |
message.append(" does not match class definition!"); |
|
throw CIMException(CIM_ERR_FAILED, message); |
|
} | } |
|
else |
|
{ |
|
pscmbArrayUn[i].extRefPtr-> |
|
getCIMInstance(cimInstance); |
|
x.append(CIMObject(cimInstance)); |
|
} |
|
} |
|
else |
|
{ |
|
// set an empty object |
|
x.append(CIMObject()); |
|
} |
|
} |
|
cimV.set(x); |
|
} |
|
else |
|
{ |
|
|
|
if (0 != scmbUn.extRefPtr) |
|
{ |
|
// check if the Object is an emedded instance or class |
|
if(scmbUn.extRefPtr->inst.hdr->flags.isClassOnly) |
|
{ |
|
scmbUn.extRefPtr-> |
|
inst.hdr->theClass.ptr->getCIMClass(cimClass); |
|
cimV.set(CIMObject(cimClass)); |
|
} |
|
else |
|
{ |
|
scmbUn.extRefPtr->getCIMInstance(cimInstance); |
|
cimV.set(CIMObject(cimInstance)); |
|
} |
|
} |
|
else |
|
{ |
|
cimV.set(CIMObject()); |
|
} |
|
} |
|
break; |
|
} |
|
|
|
case CIMTYPE_INSTANCE: |
|
{ |
|
CIMInstance theInstance; |
|
|
|
if(isArray) |
|
{ |
|
Array<CIMInstance> x; |
|
for (Uint32 i = 0, k = arraySize; i < k ; i++) |
|
{ |
|
if (0 != pscmbArrayUn[i].extRefPtr) |
|
{ |
|
pscmbArrayUn[i].extRefPtr-> |
|
getCIMInstance(theInstance); |
|
x.append(theInstance); |
|
} |
|
else |
|
{ |
|
// set an empty object |
|
x.append(CIMInstance()); |
|
} |
|
} |
|
cimV.set(x); |
|
} |
|
else |
|
{ |
|
|
|
if (0 != scmbUn.extRefPtr) |
|
{ |
|
scmbUn.extRefPtr->getCIMInstance(theInstance); |
|
cimV.set(theInstance); |
|
} |
|
else |
|
{ |
|
cimV.set(CIMInstance()); |
} | } |
} | } |
|
break; |
|
} |
|
default: |
|
{ |
|
PEGASUS_ASSERT(false); |
|
break; |
|
} |
|
} |
|
} |
|
|
|
void SCMOInstance::_getCIMValueFromSCMBValue( |
|
CIMValue& cimV, |
|
const SCMBValue& scmbV, |
|
const char * base) |
|
{ |
|
SCMOInstance::_getCIMValueFromSCMBUnion( |
|
cimV, |
|
scmbV.valueType, |
|
scmbV.flags.isNull, |
|
scmbV.flags.isArray, |
|
scmbV.valueArraySize, |
|
scmbV.value, |
|
base); |
|
} |
|
|
|
|
|
void SCMOInstance::_setCIMObjectPath(const CIMObjectPath& cimObj) |
|
{ |
|
CString className = cimObj.getClassName().getString().getCString(); |
|
|
|
// Is the instance from the same class ? |
|
if (!(_equalNoCaseUTF8Strings( |
|
inst.hdr->instClassName, |
|
inst.base, |
|
(const char*)className, |
|
strlen(className)))) |
|
{ |
|
throw PEGASUS_CIM_EXCEPTION(CIM_ERR_INVALID_CLASS, |
|
cimObj.getClassName().getString()); |
} | } |
| |
|
//set host name |
|
_setString(cimObj.getHost(),inst.hdr->hostName,&inst.mem ); |
|
|
|
const Array<CIMKeyBinding> & keys=cimObj.getKeyBindings(); |
|
for (Uint32 i = 0, k = keys.size(); i < k; i++) |
|
{ |
|
String key = keys[i].getValue(); |
|
_setKeyBindingFromString( |
|
(const char*) keys[i].getName().getString().getCString(), |
|
_CIMTypeFromKeyBindingType( |
|
(const char*)key.getCString(), |
|
keys[i].getType()), |
|
key); |
|
} |
} | } |
void SCMOInstance::_setCIMValueAtNodeIndex(Uint32 node, CIMValueRep* valRep) |
|
|
void SCMOInstance::_setCIMValueAtNodeIndex( |
|
Uint32 node, |
|
CIMValueRep* valRep, |
|
CIMType realType) |
{ | { |
SCMBValue* theInstPropNodeArray = | SCMBValue* theInstPropNodeArray = |
(SCMBValue*)&inst.base[inst.hdr->propertyArray.start]; |
(SCMBValue*)&(inst.base[inst.hdr->propertyArray.start]); |
| |
| |
SCMBValue& theInstProp = theInstPropNodeArray[node]; | SCMBValue& theInstProp = theInstPropNodeArray[node]; |
| |
theInstProp.valueType=valRep->type; |
theInstProp.valueType=realType; |
theInstProp.flags.isNull=valRep->isNull; | theInstProp.flags.isNull=valRep->isNull; |
theInstProp.flags.isArray=valRep->isArray; | theInstProp.flags.isArray=valRep->isArray; |
theInstProp.flags.isSet=true; | theInstProp.flags.isSet=true; |
|
|
| |
if (valRep->isArray) | if (valRep->isArray) |
{ | { |
_setArrayValue( |
_setUnionArrayValue( |
start, | start, |
&inst.mem, | &inst.mem, |
valRep->type, |
realType, |
// 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.size, |
valRep->u); | valRep->u); |
} | } |
else | else |
{ | { |
_setUnionValue(start,&inst.mem,valRep->type,valRep->u); |
_setUnionValue( |
|
start, |
|
&inst.mem, |
|
realType, |
|
inst.hdr->instNameSpace.start, |
|
inst.hdr->instNameSpace.size, |
|
valRep->u); |
} | } |
} | } |
| |
|
|
return inst.base == theInstance.inst.base; | return inst.base == theInstance.inst.base; |
} | } |
| |
|
void SCMOInstance::setHostName(const char* hostName) |
|
{ |
|
Uint32 len = 0; |
|
|
|
_copyOnWrite(); |
|
|
|
if (hostName!=0) |
|
{ |
|
|
|
len = strlen((const char*)hostName); |
|
} |
|
// copy including trailing '\0' |
|
_setBinary(hostName,len+1,inst.hdr->hostName,&inst.mem); |
|
} |
|
|
const char* SCMOInstance::getHostName() const | const char* SCMOInstance::getHostName() const |
{ | { |
return _getCharString(inst.hdr->hostName,inst.base); | return _getCharString(inst.hdr->hostName,inst.base); |
} | } |
| |
void SCMOInstance::buildKeyBindingsFromProperties() |
const char* SCMOInstance::getHostName_l(Uint32& length) const |
{ | { |
|
length = inst.hdr->hostName.size; |
|
if (0 == length) |
|
{ |
|
return 0; |
|
} |
|
else |
|
{ |
|
length--; |
|
} |
|
return _getCharString(inst.hdr->hostName,inst.base); |
|
} |
| |
Uint32* theClassKeyPropList = |
void SCMOInstance::setClassName(const char* className) |
(Uint32*) &((inst.hdr->theClass->cls.base) |
{ |
[(inst.hdr->theClass->cls.hdr->keyIndexList.start)]); |
Uint32 len=0; |
|
|
SCMBInstanceKeyBinding* theInstKeyBindNodeArray; |
|
SCMBValue* theInstPropNodeArray; |
|
| |
Uint32 propNode; |
_copyOnWrite(); |
| |
for (Uint32 i = 0, k = inst.hdr->numberKeyBindings; i < k; i++) |
// flag the instance as compromized |
|
inst.hdr->flags.isCompromised=true; |
|
if (className!=0) |
{ | { |
// the instance pointers has to be reinitialized eache time, |
len = strlen((const char*)className); |
// because in _setKeyBindingFromSCMBUnion() |
} |
// a reallocation can take place. |
// copy including trailing '\0' |
theInstKeyBindNodeArray = |
// _setBinary also sets the name to 0 if either className==0 or len+1==1 |
(SCMBInstanceKeyBinding*)&inst.base[inst.hdr->keyBindingArray.start]; |
_setBinary(className,len+1,inst.hdr->instClassName,&inst.mem); |
|
} |
theInstPropNodeArray = |
|
(SCMBValue*)&inst.base[inst.hdr->propertyArray.start]; |
|
| |
// If the keybinding is not set. |
void SCMOInstance::setClassName_l(const char* className, Uint32 len) |
if (!theInstKeyBindNodeArray[i].isSet) |
|
{ | { |
// get the node index for this key binding form class |
_copyOnWrite(); |
propNode = theClassKeyPropList[i]; |
|
| |
// if property was not set by the provider or it is null. |
// flag the instance as compromised |
if (!theInstPropNodeArray[propNode].flags.isSet || |
inst.hdr->flags.isCompromised=true; |
theInstPropNodeArray[propNode].flags.isNull) |
// copy including trailing '\0' |
{ |
// _setBinary also sets the name to 0 if either className==0 or len+1==1 |
const char * propName = |
_setBinary(className,len+1,inst.hdr->instClassName,&inst.mem); |
inst.hdr->theClass->_getPropertyNameAtNode(propNode); |
|
throw NoSuchProperty(String(propName)); |
|
} | } |
| |
_setKeyBindingFromSCMBUnion( |
const char* SCMOInstance::getClassName() const |
theInstPropNodeArray[propNode].valueType, |
{ |
theInstPropNodeArray[propNode].value, |
return _getCharString(inst.hdr->instClassName,inst.base); |
theInstKeyBindNodeArray[i].value); |
} |
| |
theInstKeyBindNodeArray[i].isSet=true; |
const char* SCMOInstance::getClassName_l(Uint32 & length) const |
|
{ |
|
length = inst.hdr->instClassName.size; |
|
if (0 == length) |
|
{ |
|
return 0; |
} | } |
|
else |
|
{ |
|
length--; |
} | } |
|
return _getCharString(inst.hdr->instClassName,inst.base); |
} | } |
| |
void SCMOInstance::_setKeyBindingFromSCMBUnion( |
void SCMOInstance::setNameSpace(const char* nameSpace) |
CIMType type, |
|
SCMBUnion& u, |
|
SCMBDataPtr& keyNode) |
|
{ | { |
Uint32 outputLength=0; |
Uint32 len = 0; |
const char * output; |
|
| |
switch (type) |
_copyOnWrite(); |
{ |
|
case CIMTYPE_UINT8: |
// flag the instance as compromized |
|
inst.hdr->flags.isCompromised=true; |
|
|
|
if (nameSpace!=0) |
{ | { |
char buffer[22]; |
|
output = Uint8ToString(buffer, u._uint8Value, outputLength); |
len = strlen((const char*)nameSpace); |
// including trailing '\0' ! |
} |
_setBinary(output,outputLength+1,keyNode,&inst.mem); |
// copy including trailing '\0' |
break; |
_setBinary(nameSpace,len+1,inst.hdr->instNameSpace,&inst.mem); |
} | } |
| |
case CIMTYPE_UINT16: |
void SCMOInstance::setNameSpace_l(const char* nameSpace, Uint32 len) |
{ | { |
char buffer[22]; |
// Copy on Write is only necessary if a realloc() becomes necessary |
output = Uint16ToString(buffer, u._uint16Value, outputLength); |
if (inst.mem->freeBytes < ((len+8) & ~7)) |
// including trailing '\0' ! |
{ |
_setBinary(output,outputLength+1,keyNode,&inst.mem); |
_copyOnWrite(); |
break; |
} |
|
// flag the instance as compromized |
|
inst.hdr->flags.isCompromised=true; |
|
// copy including trailing '\0' |
|
_setBinary(nameSpace,len+1,inst.hdr->instNameSpace,&inst.mem); |
} | } |
| |
case CIMTYPE_UINT32: |
const char* SCMOInstance::getNameSpace() const |
{ | { |
char buffer[22]; |
return _getCharString(inst.hdr->instNameSpace,inst.base); |
output = Uint32ToString(buffer, u._uint32Value, outputLength); |
|
// including trailing '\0' ! |
|
_setBinary(output,outputLength+1,keyNode,&inst.mem); |
|
break; |
|
} | } |
| |
case CIMTYPE_UINT64: |
const char* SCMOInstance::getNameSpace_l(Uint32 & length) const |
{ | { |
char buffer[22]; |
length = inst.hdr->instNameSpace.size; |
output = Uint64ToString(buffer, u._uint64Value, outputLength); |
if (0 == length) |
// including trailing '\0' ! |
{ |
_setBinary(output,outputLength+1,keyNode,&inst.mem); |
return 0; |
break; |
|
} | } |
|
else |
case CIMTYPE_SINT8: |
|
{ | { |
char buffer[22]; |
length--; |
output = Sint8ToString(buffer, u._sint8Value, outputLength); |
} |
// including trailing '\0' ! |
return _getCharString(inst.hdr->instNameSpace,inst.base); |
_setBinary(output,outputLength+1,keyNode,&inst.mem); |
|
break; |
|
} | } |
| |
case CIMTYPE_SINT16: |
void SCMOInstance::completeHostNameAndNamespace( |
|
const char* hn, |
|
Uint32 hnLen, |
|
const char* ns, |
|
Uint32 nsLen) |
{ | { |
char buffer[22]; |
// hostName is Null or empty String ? |
output = Sint16ToString(buffer, u._sint16Value, outputLength); |
if (0 == inst.hdr->hostName.size || |
// including trailing '\0' ! |
0 == inst.base[inst.hdr->hostName.start]) |
_setBinary(output,outputLength+1,keyNode,&inst.mem); |
{ |
break; |
// Copy on Write is only necessary if a realloc() becomes necessary |
|
if (inst.mem->freeBytes < ((hnLen+8) & ~7)) |
|
{ |
|
_copyOnWrite(); |
} | } |
|
// copy including trailing '\0' |
case CIMTYPE_SINT32: |
_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]) |
{ | { |
char buffer[22]; |
setNameSpace_l(ns,nsLen); |
output = Sint32ToString(buffer, u._sint32Value, outputLength); |
} |
// including trailing '\0' ! |
|
_setBinary(output,outputLength+1,keyNode,&inst.mem); |
|
break; |
|
} | } |
| |
case CIMTYPE_SINT64: |
|
|
void SCMOInstance::buildKeyBindingsFromProperties() |
{ | { |
char buffer[22]; |
Uint32 propNode; |
output = Sint64ToString(buffer, u._sint64Value, outputLength); |
// The theClassKeyPropList pointer will always be valid, |
// including trailing '\0' ! |
// even after a realloc() caused by copyOnWrite() |
_setBinary(output,outputLength+1,keyNode,&inst.mem); |
// as this is an absolute pointer to the class which does not change |
break; |
Uint32* theClassKeyPropList = |
} |
(Uint32*) &((inst.hdr->theClass.ptr->cls.base) |
|
[(inst.hdr->theClass.ptr->cls.hdr->keyIndexList.start)]); |
| |
case CIMTYPE_REAL32: |
SCMBKeyBindingValue* theKeyBindValueArray = |
|
(SCMBKeyBindingValue*)&(inst.base[inst.hdr->keyBindingArray.start]); |
|
SCMBValue* theInstPropNodeArray= |
|
(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++) |
{ | { |
char buffer[128]; |
// If the keybinding is not set. |
output = Real32ToString(buffer, u._real32Value, outputLength); |
if (!theKeyBindValueArray[i].isSet) |
// including trailing '\0' ! |
{ |
_setBinary(output,outputLength+1,keyNode,&inst.mem); |
// get the node index for this key binding form class |
break; |
propNode = theClassKeyPropList[i]; |
|
|
|
// if property was set by the provider and it is not null. |
|
if ( theInstPropNodeArray[propNode].flags.isSet && |
|
!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( |
|
theInstPropNodeArray[propNode].valueType, |
|
theInstPropNodeArray[propNode].value, |
|
inst.base, |
|
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]; |
|
|
|
} |
|
} |
|
} |
} | } |
| |
|
void SCMOInstance::_setKeyBindingFromSCMBUnion( |
|
CIMType type, |
|
const SCMBUnion& u, |
|
const char * uBase, |
|
SCMBKeyBindingValue& keyData) |
|
{ |
|
switch (type) |
|
{ |
|
case CIMTYPE_UINT8: |
|
case CIMTYPE_UINT16: |
|
case CIMTYPE_UINT32: |
|
case CIMTYPE_UINT64: |
|
case CIMTYPE_SINT8: |
|
case CIMTYPE_SINT16: |
|
case CIMTYPE_SINT32: |
|
case CIMTYPE_SINT64: |
|
case CIMTYPE_REAL32: |
case CIMTYPE_REAL64: | case CIMTYPE_REAL64: |
|
case CIMTYPE_CHAR16: |
|
case CIMTYPE_BOOLEAN: |
{ | { |
char buffer[128]; |
memcpy(&keyData.data,&u,sizeof(SCMBUnion)); |
output = Real64ToString(buffer, u._real64Value, outputLength); |
keyData.data.simple.hasValue=true; |
// including trailing '\0' ! |
keyData.isSet=true; |
_setBinary(output,outputLength+1,keyNode,&inst.mem); |
|
break; |
|
break; | break; |
} | } |
|
case CIMTYPE_DATETIME: |
case CIMTYPE_CHAR16: |
|
{ | { |
Buffer out; |
memcpy(&keyData.data,&u,sizeof(SCMBUnion)); |
_toString(out,u._char16Value); |
keyData.isSet=true; |
// including trailing '\0' ! |
|
_setBinary(out.getData(),out.size()+1,keyNode,&inst.mem); |
|
break; | break; |
} | } |
|
case CIMTYPE_STRING: |
case CIMTYPE_BOOLEAN: |
|
{ |
|
if (u._booleanValue) |
|
{ | { |
_setBinary("TRUE",strlen("TRUE")+1,keyNode,&inst.mem); |
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 | else |
{ | { |
_setBinary("FALSE",strlen("FLASE")+1,keyNode,&inst.mem); |
keyData.data.stringValue.size=0; |
} |
keyData.data.stringValue.start=0; |
break; |
|
} | } |
| |
case CIMTYPE_STRING: |
} |
|
else |
{ | { |
_setBinary( | _setBinary( |
&inst.base[u._stringValue.start], |
&uBase[u.stringValue.start], |
u._stringValue.length, |
u.stringValue.size, |
keyNode, |
keyData.data.stringValue, |
&inst.mem); | &inst.mem); |
break; |
|
} | } |
| |
case CIMTYPE_DATETIME: |
|
{ |
|
_setString( |
|
CIMDateTime(&u._dateTimeValue).toString(), |
|
keyNode, |
|
&inst.mem); |
|
break; | break; |
} | } |
|
|
case CIMTYPE_REFERENCE: | case CIMTYPE_REFERENCE: |
|
{ |
|
if(0 != keyData.data.extRefPtr) |
|
{ |
|
delete keyData.data.extRefPtr; |
|
} |
| |
|
if(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 |
|
{ |
|
keyData.isSet=true; |
|
keyData.data.extRefPtr=0; |
|
} |
break; | break; |
|
} |
case CIMTYPE_OBJECT: | case CIMTYPE_OBJECT: |
case CIMTYPE_INSTANCE: | case CIMTYPE_INSTANCE: |
|
{ |
// From PEP 194: EmbeddedObjects cannot be keys. | // From PEP 194: EmbeddedObjects cannot be keys. |
throw TypeMismatchException(); | throw TypeMismatchException(); |
break; | break; |
} | } |
|
default: |
|
|
|
|
} |
|
|
|
void SCMOInstance::setHostName(const char* hostName) |
|
{ |
|
Uint32 len; |
|
|
|
if (hostName!=NULL) |
|
{ |
|
|
|
len = strlen((const char*)hostName); |
|
if(len != 0) |
|
{ | { |
|
PEGASUS_ASSERT(false); |
// copy including trailing '\0' |
break; |
_setBinary(hostName,len+1,inst.hdr->hostName,&inst.mem); |
|
return; |
|
} |
|
|
|
} |
|
inst.hdr->hostName.start=0; |
|
inst.hdr->hostName.length=0; |
|
} | } |
|
|
const char* SCMOInstance::getClassName() const |
|
{ |
|
return _getCharString( |
|
inst.hdr->theClass->cls.hdr->className, |
|
inst.hdr->theClass->cls.base); |
|
} | } |
|
|
const char* SCMOInstance::getNameSpace() const |
|
{ |
|
return _getCharString( |
|
inst.hdr->theClass->cls.hdr->nameSpace, |
|
inst.hdr->theClass->cls.base); |
|
} | } |
| |
void SCMOInstance::_initSCMOInstance( |
void SCMOInstance::_initSCMOInstance(SCMOClass* pClass) |
SCMOClass* pClass, |
|
Boolean inclQual, |
|
Boolean inclOrigin) |
|
{ | { |
PEGASUS_ASSERT(SCMB_INITIAL_MEMORY_CHUNK_SIZE | PEGASUS_ASSERT(SCMB_INITIAL_MEMORY_CHUNK_SIZE |
- sizeof(SCMBInstance_Main)>0); | - sizeof(SCMBInstance_Main)>0); |
| |
| |
inst.base = (char*)malloc(SCMB_INITIAL_MEMORY_CHUNK_SIZE); | inst.base = (char*)malloc(SCMB_INITIAL_MEMORY_CHUNK_SIZE); |
if (inst.base == NULL) |
if (inst.base == 0) |
{ | { |
// Not enough memory! | // Not enough memory! |
throw PEGASUS_STD(bad_alloc)(); | throw PEGASUS_STD(bad_alloc)(); |
} | } |
| |
|
memset(inst.base,0,sizeof(SCMBInstance_Main)); |
|
|
// initalize eye catcher | // initalize eye catcher |
inst.hdr->header.magic=PEGASUS_SCMB_INSTANCE_MAGIC; | inst.hdr->header.magic=PEGASUS_SCMB_INSTANCE_MAGIC; |
inst.hdr->header.totalSize=SCMB_INITIAL_MEMORY_CHUNK_SIZE; | inst.hdr->header.totalSize=SCMB_INITIAL_MEMORY_CHUNK_SIZE; |
|
|
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; |
| |
// Init flags |
// Copy name space name and class name of the class |
inst.hdr->flags.includeQualifiers=inclQual; |
_setBinary( |
inst.hdr->flags.includeClassOrigin=inclOrigin; |
_getCharString(inst.hdr->theClass.ptr->cls.hdr->className, |
inst.hdr->flags.isFiltered=false; |
inst.hdr->theClass.ptr->cls.base), |
|
inst.hdr->theClass.ptr->cls.hdr->className.size, |
|
inst.hdr->instClassName, |
|
&inst.mem); |
| |
inst.hdr->hostName.start=0; |
_setBinary( |
inst.hdr->hostName.length=0; |
_getCharString(inst.hdr->theClass.ptr->cls.hdr->nameSpace, |
|
inst.hdr->theClass.ptr->cls.base), |
|
inst.hdr->theClass.ptr->cls.hdr->nameSpace.size, |
|
inst.hdr->instNameSpace, |
|
&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(SCMBInstanceKeyBinding)*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); |
|
|
} |
|
|
|
void SCMOInstance::_setCIMInstance(const CIMInstance& cimInstance) |
|
{ |
|
CIMPropertyRep* propRep; |
|
Uint32 propNode; |
|
SCMO_RC rc; |
|
CIMType realType; |
|
|
|
CIMInstanceRep* instRep = cimInstance._rep; |
|
|
|
// Test if the instance has qualifiers. |
|
// The instance level qualifiers are stored on the associated SCMOClass. |
|
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); |
|
|
|
// Copy all properties |
|
for (Uint32 i = 0, k = instRep->_properties.size(); i < k; i++) |
|
{ |
|
propRep = instRep->_properties[i]._rep; |
|
// if not already detected that qualifiers are specified and |
|
// there are qualifers at that property. |
|
if (!inst.hdr->flags.includeQualifiers && |
|
propRep->getQualifierCount() > 0) |
|
{ |
|
includeQualifiers(); |
|
} |
|
// if not already detected that class origins are specified and |
|
// there is a class origin specified at that property. |
|
if (!inst.hdr->flags.includeClassOrigin && |
|
!propRep->_classOrigin.isNull()) |
|
{ |
|
includeClassOrigins(); |
|
} |
|
|
|
// get the property node index for the property |
|
rc = inst.hdr->theClass.ptr->_getProperyNodeIndex( |
|
propNode, |
|
(const char*)propRep->_name.getString().getCString()); |
| |
inst.hdr->propertyFilter.start=0; |
if (rc == SCMO_OK) |
inst.hdr->propertyFilter.length=0; |
{ |
inst.hdr->propertyFilterIndexMap.start=0; |
// The type stored in the class information is set on realType. |
inst.hdr->propertyFilterIndexMap.length=0; |
// It must be used in further calls to guaranty consistence. |
|
rc = inst.hdr->theClass.ptr->_isNodeSameType( |
|
propNode, |
|
propRep->_value._rep->type, |
|
propRep->_value._rep->isArray, |
|
realType); |
|
if (rc == SCMO_OK) |
|
{ |
|
_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 |
|
{ |
| |
|
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())); |
|
} |
|
} |
} | } |
| |
SCMO_RC SCMOInstance::getProperty( | SCMO_RC SCMOInstance::getProperty( |
const char* name, | const char* name, |
CIMType& type, | CIMType& type, |
const void** pvalue, |
const SCMBUnion** pOutVal, |
Boolean& isArray, | Boolean& isArray, |
Uint32& size ) const | Uint32& size ) const |
{ | { |
|
|
const char* pname; | const char* pname; |
SCMO_RC rc = SCMO_OK; | SCMO_RC rc = SCMO_OK; |
| |
*pvalue = NULL; |
*pOutVal = 0; |
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 ? |
return _getPropertyAtNodeIndex(node,&pname,type,pOutVal,isArray,size); |
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,pvalue,isArray,size); |
|
} | } |
| |
SCMO_RC SCMOInstance::getPropertyAt( | SCMO_RC SCMOInstance::getPropertyAt( |
Uint32 idx, | Uint32 idx, |
const char** pname, | const char** pname, |
CIMType& type, | CIMType& type, |
const void** pvalue, |
const SCMBUnion** pOutVal, |
Boolean& isArray, | Boolean& isArray, |
Uint32& size ) const | Uint32& size ) const |
{ | { |
*pname = NULL; |
*pname = 0; |
*pvalue = NULL; |
*pOutVal = 0; |
isArray = false; | isArray = false; |
size = 0; | size = 0; |
Uint32 node; |
|
|
|
// is filtering on ? |
|
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; |
|
} |
|
| |
// Get absolut pointer to property filter index map of the instance |
if (idx >= inst.hdr->numberProperties) |
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 SCMO_INDEX_OUT_OF_BOUND; |
} | } |
} |
|
| |
return _getPropertyAtNodeIndex(node,pname,type,pvalue,isArray,size); |
return _getPropertyAtNodeIndex(idx,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 |
{ | { |
SCMO_RC rc; | SCMO_RC rc; |
if(name==NULL) |
if(name==0) |
{ | { |
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; |
| |
} | } |
|
|
SCMO_RC SCMOInstance::setPropertyWithOrigin( | SCMO_RC SCMOInstance::setPropertyWithOrigin( |
const char* name, | const char* name, |
CIMType type, | CIMType type, |
void* value, |
const SCMBUnion* pInVal, |
Boolean isArray, | Boolean isArray, |
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; |
| |
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 ? |
rc = inst.hdr->theClass->_isNodeSameType(node,type,isArray); |
// The type stored in the class information is set on realType. |
|
// It must be used in further calls to guaranty consistence. |
|
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!= NULL) |
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; |
} | } |
} | } |
| |
| |
_setPropertyAtNodeIndex(node,type,value,isArray,size); |
_setPropertyAtNodeIndex(node,realType,pInVal,isArray,size); |
| |
return SCMO_OK; | return SCMO_OK; |
} | } |
|
|
SCMO_RC SCMOInstance::setPropertyWithNodeIndex( | SCMO_RC SCMOInstance::setPropertyWithNodeIndex( |
Uint32 node, | Uint32 node, |
CIMType type, | CIMType type, |
void* value, |
const SCMBUnion* pInVal, |
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; |
| |
if (node >= inst.hdr->numberProperties) | if (node >= inst.hdr->numberProperties) |
{ | { |
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 ? |
rc = inst.hdr->theClass->_isNodeSameType(node,type,isArray); |
// The type stored in the class information is set on realType. |
|
// It must be used in further calls to guaranty consistence. |
|
rc = inst.hdr->theClass.ptr->_isNodeSameType(node,type,isArray,realType); |
if (rc != SCMO_OK) | if (rc != SCMO_OK) |
{ | { |
return rc; | return rc; |
} | } |
| |
_setPropertyAtNodeIndex(node,type,value,isArray,size); |
_setPropertyAtNodeIndex(node,realType,pInVal,isArray,size); |
| |
return SCMO_OK; | return SCMO_OK; |
} | } |
|
|
void SCMOInstance::_setPropertyAtNodeIndex( | void SCMOInstance::_setPropertyAtNodeIndex( |
Uint32 node, | Uint32 node, |
CIMType type, | CIMType type, |
void* value, |
const SCMBUnion* pInVal, |
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]); |
| |
| |
theInstPropNodeArray[node].flags.isSet=true; | theInstPropNodeArray[node].flags.isSet=true; |
|
|
theInstPropNodeArray[node].valueArraySize=size; | theInstPropNodeArray[node].valueArraySize=size; |
} | } |
| |
if (value==NULL) |
if (pInVal==0) |
{ | { |
theInstPropNodeArray[node].flags.isNull=true; | theInstPropNodeArray[node].flags.isNull=true; |
} | } |
else | else |
{ | { |
Uint64 start = |
theInstPropNodeArray[node].flags.isNull=false; |
(const char*)&(theInstPropNodeArray[node].value)-inst.base; |
_setSCMBUnion( |
|
pInVal, |
_setSCMBUnion(value,type,isArray,size,start); |
type, |
|
isArray, |
|
size, |
|
theInstPropNodeArray[node].value); |
} | } |
} | } |
| |
void SCMOInstance::_setSCMBUnion( | void SCMOInstance::_setSCMBUnion( |
void* value, |
const SCMBUnion* pInVal, |
CIMType type, | CIMType type, |
Boolean isArray, | Boolean isArray, |
Uint32 size, | Uint32 size, |
Uint64 start) |
SCMBUnion & u) |
{ | { |
SCMBUnion* u = (SCMBUnion*)&(inst.base[start]); |
|
| |
switch (type) | switch (type) |
{ | { |
case CIMTYPE_BOOLEAN: | case CIMTYPE_BOOLEAN: |
|
case CIMTYPE_UINT8: |
|
case CIMTYPE_SINT8: |
|
case CIMTYPE_UINT16: |
|
case CIMTYPE_SINT16: |
|
case CIMTYPE_UINT32: |
|
case CIMTYPE_SINT32: |
|
case CIMTYPE_UINT64: |
|
case CIMTYPE_SINT64: |
|
case CIMTYPE_REAL32: |
|
case CIMTYPE_REAL64: |
|
case CIMTYPE_CHAR16: |
{ | { |
if (isArray) | if (isArray) |
{ | { |
_setBinary(value,size*sizeof(Boolean), |
_setBinary(pInVal,size*sizeof(SCMBUnion), |
u->_arrayValue, |
u.arrayValue, |
&inst.mem ); | &inst.mem ); |
} | } |
else | else |
{ | { |
u->_booleanValue = *((Boolean*)value); |
memcpy(&u,pInVal,sizeof(SCMBUnion)); |
|
u.simple.hasValue=true; |
} | } |
break; | break; |
} | } |
|
case CIMTYPE_DATETIME: |
case CIMTYPE_UINT8: |
|
{ | { |
if (isArray) | if (isArray) |
{ | { |
_setBinary(value,size*sizeof(Uint8), |
_setBinary(pInVal,size*sizeof(SCMBUnion), |
u->_arrayValue, |
u.arrayValue, |
&inst.mem ); | &inst.mem ); |
} | } |
else | else |
{ | { |
u->_uint8Value = *((Uint8*)value); |
memcpy(&u,pInVal,sizeof(SCMBUnion)); |
|
|
} | } |
break; | break; |
} | } |
|
case CIMTYPE_STRING: |
case CIMTYPE_SINT8: |
|
{ | { |
if (isArray) | if (isArray) |
{ | { |
_setBinary(value,size*sizeof(Sint8), |
SCMBUnion* ptr; |
u->_arrayValue, |
Uint64 startPtr; |
|
|
|
startPtr = _getFreeSpace( |
|
u.arrayValue, |
|
size*sizeof(SCMBUnion), |
&inst.mem ); | &inst.mem ); |
} |
|
else |
|
{ |
|
u->_sint8Value = *((Sint8*)value); |
|
} |
|
break; |
|
} |
|
| |
case CIMTYPE_UINT16: |
for (Uint32 i = 0; i < size; i++) |
{ |
|
if (isArray) |
|
{ | { |
_setBinary(value,size*sizeof(Uint16), |
ptr = (SCMBUnion*)&(inst.base[startPtr]); |
u->_arrayValue, |
// Copy the sting including the trailing '\0' |
|
_setBinary( |
|
pInVal[i].extString.pchar, |
|
pInVal[i].extString.length+1, |
|
ptr[i].stringValue, |
&inst.mem ); | &inst.mem ); |
} | } |
|
} |
else | else |
{ | { |
u->_uint16Value = *((Uint16*)value); |
// Copy the sting including the trailing '\0' |
|
_setBinary( |
|
pInVal->extString.pchar, |
|
pInVal->extString.length+1, |
|
u.stringValue, |
|
&inst.mem ); |
} | } |
break; | break; |
} | } |
| |
case CIMTYPE_SINT16: |
case CIMTYPE_REFERENCE: |
|
case CIMTYPE_OBJECT: |
|
case CIMTYPE_INSTANCE: |
{ | { |
if (isArray) | if (isArray) |
{ | { |
_setBinary(value,size*sizeof(Sint16), |
SCMBUnion* ptr; |
u->_arrayValue, |
Uint64 startPtr; |
|
|
|
// if the array was previously set, delete the references ! |
|
_deleteArrayExtReference(u.arrayValue,&inst.mem); |
|
|
|
// get new array |
|
startPtr = _getFreeSpace( |
|
u.arrayValue, |
|
size*sizeof(SCMBUnion), |
&inst.mem ); | &inst.mem ); |
|
|
|
ptr = (SCMBUnion*)&(inst.base[startPtr]); |
|
|
|
for (Uint32 i = 0 ; i < size ; i++) |
|
{ |
|
if(pInVal[i].extRefPtr) |
|
{ |
|
ptr[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 |
{ | { |
u->_sint16Value = *((Sint16*)value); |
ptr[i].extRefPtr = 0; |
} | } |
break; |
|
} | } |
| |
case CIMTYPE_UINT32: |
|
{ |
|
if (isArray) |
|
{ |
|
_setBinary(value,size*sizeof(Uint32), |
|
u->_arrayValue, |
|
&inst.mem ); |
|
} | } |
else | else |
{ | { |
u->_uint32Value = *((Uint32*)value); |
if(0 != u.extRefPtr) |
} |
{ |
break; |
delete u.extRefPtr; |
} | } |
| |
case CIMTYPE_SINT32: |
if(pInVal->extRefPtr) |
{ | { |
if (isArray) |
u.extRefPtr = new SCMOInstance(*(pInVal->extRefPtr)); |
{ |
// This function can cause a reallocation ! |
_setBinary(value,size*sizeof(Sint32), |
// Pointers can be invalid after the call. |
u->_arrayValue, |
_setExtRefIndex(&u,&inst.mem); |
&inst.mem ); |
|
} | } |
else | else |
{ | { |
u->_sint32Value = *((Sint32*)value); |
u.extRefPtr = 0; |
|
} |
} | } |
break; | break; |
} | } |
|
default: |
case CIMTYPE_UINT64: |
|
{ |
|
if (isArray) |
|
{ | { |
_setBinary(value,size*sizeof(Uint64), |
PEGASUS_ASSERT(false); |
u->_arrayValue, |
break; |
&inst.mem ); |
|
} | } |
else |
|
{ |
|
u->_uint64Value = *((Uint64*)value); |
|
} | } |
break; |
|
} | } |
| |
case CIMTYPE_SINT64: |
void SCMOInstance::_setUnionArrayValue( |
|
Uint64 start, |
|
SCMBMgmt_Header** pmem, |
|
CIMType type, |
|
Uint32& n, |
|
Uint64 startNS, |
|
Uint32 sizeNS, |
|
Union& u) |
{ | { |
if (isArray) |
SCMBUnion* scmoUnion = (SCMBUnion*)&(((char*)*pmem)[start]); |
|
SCMBUnion* ptargetUnion; |
|
Uint64 arrayStart; |
|
Uint32 loop; |
|
|
|
switch (type) |
{ | { |
_setBinary(value,size*sizeof(Sint64), |
case CIMTYPE_BOOLEAN: |
u->_arrayValue, |
{ |
&inst.mem ); |
Array<Boolean> *x = reinterpret_cast<Array<Boolean>*>(&u); |
} |
// n can be invalid after re-allocation in _getFreeSpace ! |
else |
loop = n = x->size(); |
|
arrayStart = _getFreeSpace( |
|
scmoUnion->arrayValue, |
|
loop*sizeof(SCMBUnion), |
|
pmem); |
|
|
|
ConstArrayIterator<Boolean> iterator(*x); |
|
|
|
ptargetUnion = (SCMBUnion*)&(((char*)*pmem)[arrayStart]); |
|
for (Uint32 i = 0; i < loop; i++) |
{ | { |
u->_sint64Value = *((Sint64*)value); |
ptargetUnion[i].simple.val.bin = iterator[i]; |
|
ptargetUnion[i].simple.hasValue = true; |
} | } |
break; | break; |
} | } |
| |
case CIMTYPE_REAL32: |
case CIMTYPE_UINT8: |
{ |
|
if (isArray) |
|
{ | { |
_setBinary(value,size*sizeof(Real32), |
Array<Uint8> *x = reinterpret_cast<Array<Uint8>*>(&u); |
u->_arrayValue, |
// n can be invalid after re-allocation in _getFreeSpace ! |
&inst.mem ); |
loop = n = x->size(); |
} |
arrayStart = _getFreeSpace( |
else |
scmoUnion->arrayValue, |
|
loop*sizeof(SCMBUnion), |
|
pmem); |
|
|
|
ConstArrayIterator<Uint8> iterator(*x); |
|
|
|
ptargetUnion = (SCMBUnion*)&(((char*)*pmem)[arrayStart]); |
|
for (Uint32 i = 0; i < loop; i++) |
{ | { |
u->_real32Value = *((Real32*)value); |
ptargetUnion[i].simple.val.u8 = iterator[i]; |
|
ptargetUnion[i].simple.hasValue = true; |
} | } |
break; | break; |
} | } |
| |
case CIMTYPE_REAL64: |
case CIMTYPE_SINT8: |
{ |
|
if (isArray) |
|
{ | { |
_setBinary(value,size*sizeof(Real64), |
Array<Sint8> *x = reinterpret_cast<Array<Sint8>*>(&u); |
u->_arrayValue, |
// n can be invalid after re-allocation in _getFreeSpace ! |
&inst.mem ); |
loop = n = x->size(); |
} |
arrayStart = _getFreeSpace( |
else |
scmoUnion->arrayValue, |
|
loop*sizeof(SCMBUnion), |
|
pmem); |
|
|
|
ConstArrayIterator<Sint8> iterator(*x); |
|
|
|
ptargetUnion = (SCMBUnion*)&(((char*)*pmem)[arrayStart]); |
|
for (Uint32 i = 0; i < loop; i++) |
{ | { |
u->_real64Value = *((Real64*)value); |
ptargetUnion[i].simple.val.s8 = iterator[i]; |
|
ptargetUnion[i].simple.hasValue = true; |
} | } |
break; | break; |
} | } |
| |
case CIMTYPE_CHAR16: |
case CIMTYPE_UINT16: |
{ |
|
if (isArray) |
|
{ | { |
_setBinary(value,size*sizeof(Char16), |
Array<Uint16> *x = reinterpret_cast<Array<Uint16>*>(&u); |
u->_arrayValue, |
// n can be invalid after re-allocation in _getFreeSpace ! |
&inst.mem ); |
loop = n = x->size(); |
} |
arrayStart = _getFreeSpace( |
else |
scmoUnion->arrayValue, |
|
loop*sizeof(SCMBUnion), |
|
pmem); |
|
|
|
ConstArrayIterator<Uint16> iterator(*x); |
|
|
|
ptargetUnion = (SCMBUnion*)&(((char*)*pmem)[arrayStart]); |
|
for (Uint32 i = 0; i < loop; i++) |
{ | { |
u->_char16Value = *((Char16*)value); |
ptargetUnion[i].simple.val.u16 = iterator[i]; |
|
ptargetUnion[i].simple.hasValue = true; |
} | } |
break; | break; |
} | } |
| |
case CIMTYPE_DATETIME: |
case CIMTYPE_SINT16: |
{ | { |
if (isArray) |
Array<Sint16> *x = reinterpret_cast<Array<Sint16>*>(&u); |
{ |
// n can be invalid after re-allocation in _getFreeSpace ! |
_setBinary(value,size*sizeof(SCMBDateTime), |
loop = n = x->size(); |
u->_arrayValue, |
|
&inst.mem ); |
|
} |
|
else |
|
{ |
|
u->_dateTimeValue = *((SCMBDateTime*)value); |
|
} |
|
break; |
|
} |
|
|
|
case CIMTYPE_STRING: |
|
{ |
|
if (isArray) |
|
{ |
|
SCMBDataPtr* ptr; |
|
char** tmp; |
|
Uint64 startPtr; |
|
|
|
startPtr = _getFreeSpace( |
|
u->_arrayValue, |
|
size*sizeof(SCMBDataPtr), |
|
&inst.mem,false); |
|
// the value is pointer to an array of char* |
|
tmp = (char**)value; |
|
|
|
for (Uint32 i = 0; i < size; i++) |
|
{ |
|
ptr = (SCMBDataPtr*)&(inst.base[startPtr]); |
|
// Copy the sting including the trailing '\0' |
|
_setBinary(tmp[i],strlen(tmp[i])+1,ptr[i],&inst.mem ); |
|
} |
|
} |
|
else |
|
{ |
|
// Copy the sting including the trailing '\0' |
|
_setBinary( |
|
value, |
|
strlen((char*)value)+1, |
|
u->_stringValue, |
|
&inst.mem ); |
|
} |
|
break; |
|
} |
|
|
|
case CIMTYPE_REFERENCE: |
|
|
|
break; |
|
|
|
case CIMTYPE_OBJECT: |
|
|
|
break; |
|
case CIMTYPE_INSTANCE: |
|
|
|
break; |
|
} |
|
} |
|
|
|
void SCMOInstance::_setArrayValue( |
|
Uint64 start, |
|
SCMBMgmt_Header** pmem, |
|
CIMType type, |
|
Uint32& n, |
|
Union& u) |
|
{ |
|
SCMBUnion* scmoUnion = (SCMBUnion*)&(((char*)*pmem)[start]); |
|
Uint64 arrayStart; |
|
|
|
switch (type) |
|
{ |
|
case CIMTYPE_BOOLEAN: |
|
{ |
|
Array<Boolean> *x = reinterpret_cast<Array<Boolean>*>(&u); |
|
n = x->size(); |
|
arrayStart = _getFreeSpace( | arrayStart = _getFreeSpace( |
scmoUnion->_arrayValue, |
scmoUnion->arrayValue, |
n*sizeof(Boolean), |
loop*sizeof(SCMBUnion), |
pmem); | pmem); |
memcpy( |
|
&((char*)*pmem)[arrayStart],x->getData(),n * sizeof(Boolean)); |
|
break; |
|
} |
|
| |
case CIMTYPE_UINT8: |
ConstArrayIterator<Sint16> iterator(*x); |
{ |
|
Array<Uint8> *x = reinterpret_cast<Array<Uint8>*>(&u); |
|
n = x->size(); |
|
arrayStart = _getFreeSpace( |
|
scmoUnion->_arrayValue, |
|
n*sizeof(Uint8), |
|
pmem); |
|
memcpy(&((char*)*pmem)[arrayStart],x->getData(),n * sizeof(Uint8)); |
|
break; |
|
} |
|
| |
case CIMTYPE_SINT8: |
ptargetUnion = (SCMBUnion*)&(((char*)*pmem)[arrayStart]); |
|
for (Uint32 i = 0; i < loop; i++) |
{ | { |
Array<Sint8> *x = reinterpret_cast<Array<Sint8>*>(&u); |
ptargetUnion[i].simple.val.s16 = iterator[i]; |
n = x->size(); |
ptargetUnion[i].simple.hasValue = true; |
arrayStart = _getFreeSpace( |
} |
scmoUnion->_arrayValue, |
|
n*sizeof(Sint8), |
|
pmem); |
|
memcpy(&((char*)*pmem)[arrayStart],x->getData(),n * sizeof(Sint8)); |
|
break; | break; |
} | } |
| |
case CIMTYPE_UINT16: |
case CIMTYPE_UINT32: |
{ | { |
Array<Uint16> *x = reinterpret_cast<Array<Uint16>*>(&u); |
Array<Uint32> *x = reinterpret_cast<Array<Uint32>*>(&u); |
n = x->size(); |
// n can be invalid after re-allocation in _getFreeSpace ! |
|
loop = n = x->size(); |
arrayStart = _getFreeSpace( | arrayStart = _getFreeSpace( |
scmoUnion->_arrayValue, |
scmoUnion->arrayValue, |
n*sizeof(Uint16), |
loop*sizeof(SCMBUnion), |
pmem); | pmem); |
memcpy(&((char*)*pmem)[arrayStart],x->getData(),n * sizeof(Uint16)); |
|
| |
break; |
ConstArrayIterator<Uint32> iterator(*x); |
} |
|
| |
case CIMTYPE_SINT16: |
ptargetUnion = (SCMBUnion*)&(((char*)*pmem)[arrayStart]); |
|
for (Uint32 i = 0; i < loop; i++) |
{ | { |
Array<Sint16> *x = reinterpret_cast<Array<Sint16>*>(&u); |
ptargetUnion[i].simple.val.u32 = iterator[i]; |
n = x->size(); |
ptargetUnion[i].simple.hasValue = true; |
arrayStart = _getFreeSpace( |
|
scmoUnion->_arrayValue, |
|
n*sizeof(Sint16), |
|
pmem); |
|
memcpy(&((char*)*pmem)[arrayStart],x->getData(),n * sizeof(Sint16)); |
|
break; |
|
} | } |
|
|
case CIMTYPE_UINT32: |
|
{ |
|
Array<Uint32> *x = reinterpret_cast<Array<Uint32>*>(&u); |
|
n = x->size(); |
|
arrayStart = _getFreeSpace( |
|
scmoUnion->_arrayValue, |
|
n*sizeof(Uint32), |
|
pmem); |
|
memcpy(&((char*)*pmem)[arrayStart],x->getData(),n * sizeof(Uint32)); |
|
break; | break; |
} | } |
| |
case CIMTYPE_SINT32: | case CIMTYPE_SINT32: |
{ | { |
Array<Sint32> *x = reinterpret_cast<Array<Sint32>*>(&u); | Array<Sint32> *x = reinterpret_cast<Array<Sint32>*>(&u); |
n = x->size(); |
// n can be invalid after re-allocation in _getFreeSpace ! |
|
loop = n = x->size(); |
arrayStart = _getFreeSpace( | arrayStart = _getFreeSpace( |
scmoUnion->_arrayValue, |
scmoUnion->arrayValue, |
n*sizeof(Sint32), |
loop*sizeof(SCMBUnion), |
pmem); | pmem); |
memcpy(&((char*)*pmem)[arrayStart],x->getData(),n * sizeof(Sint32)); |
|
|
ConstArrayIterator<Sint32> iterator(*x); |
|
|
|
ptargetUnion = (SCMBUnion*)&(((char*)*pmem)[arrayStart]); |
|
for (Uint32 i = 0; i < loop; i++) |
|
{ |
|
ptargetUnion[i].simple.val.s32 = iterator[i]; |
|
ptargetUnion[i].simple.hasValue = true; |
|
} |
break; | break; |
} | } |
| |
case CIMTYPE_UINT64: | case CIMTYPE_UINT64: |
{ | { |
Array<Uint64> *x = reinterpret_cast<Array<Uint64>*>(&u); | Array<Uint64> *x = reinterpret_cast<Array<Uint64>*>(&u); |
n = x->size(); |
// n can be invalid after re-allocation in _getFreeSpace ! |
|
loop = n = x->size(); |
arrayStart = _getFreeSpace( | arrayStart = _getFreeSpace( |
scmoUnion->_arrayValue, |
scmoUnion->arrayValue, |
n*sizeof(Uint64), |
loop*sizeof(SCMBUnion), |
pmem); | pmem); |
memcpy(&((char*)*pmem)[arrayStart],x->getData(),n * sizeof(Uint64)); |
|
|
ConstArrayIterator<Uint64> iterator(*x); |
|
|
|
ptargetUnion = (SCMBUnion*)&(((char*)*pmem)[arrayStart]); |
|
for (Uint32 i = 0; i < loop; i++) |
|
{ |
|
ptargetUnion[i].simple.val.u64 = iterator[i]; |
|
ptargetUnion[i].simple.hasValue = true; |
|
} |
break; | break; |
} | } |
| |
case CIMTYPE_SINT64: | case CIMTYPE_SINT64: |
{ | { |
Array<Sint64> *x = reinterpret_cast<Array<Sint64>*>(&u); | Array<Sint64> *x = reinterpret_cast<Array<Sint64>*>(&u); |
n = x->size(); |
// n can be invalid after re-allocation in _getFreeSpace ! |
|
loop = n = x->size(); |
arrayStart = _getFreeSpace( | arrayStart = _getFreeSpace( |
scmoUnion->_arrayValue, |
scmoUnion->arrayValue, |
n*sizeof(Sint64), |
loop*sizeof(SCMBUnion), |
pmem); | pmem); |
memcpy(&((char*)*pmem)[arrayStart],x->getData(),n * sizeof(Sint64)); |
|
|
ConstArrayIterator<Sint64> iterator(*x); |
|
|
|
ptargetUnion = (SCMBUnion*)&(((char*)*pmem)[arrayStart]); |
|
for (Uint32 i = 0; i < loop; i++) |
|
{ |
|
ptargetUnion[i].simple.val.s64 = iterator[i]; |
|
ptargetUnion[i].simple.hasValue = true; |
|
} |
break; | break; |
} | } |
| |
case CIMTYPE_REAL32: | case CIMTYPE_REAL32: |
{ | { |
Array<Real32> *x = reinterpret_cast<Array<Real32>*>(&u); | Array<Real32> *x = reinterpret_cast<Array<Real32>*>(&u); |
n = x->size(); |
// n can be invalid after re-allocation in _getFreeSpace ! |
|
loop = n = x->size(); |
arrayStart = _getFreeSpace( | arrayStart = _getFreeSpace( |
scmoUnion->_arrayValue, |
scmoUnion->arrayValue, |
n*sizeof(Real32), |
loop*sizeof(SCMBUnion), |
pmem); | pmem); |
memcpy(&((char*)*pmem)[arrayStart],x->getData(),n * sizeof(Real32)); |
|
|
ConstArrayIterator<Real32> iterator(*x); |
|
|
|
ptargetUnion = (SCMBUnion*)&(((char*)*pmem)[arrayStart]); |
|
for (Uint32 i = 0; i < loop; i++) |
|
{ |
|
ptargetUnion[i].simple.val.r32 = iterator[i]; |
|
ptargetUnion[i].simple.hasValue = true; |
|
} |
break; | break; |
} | } |
| |
case CIMTYPE_REAL64: | case CIMTYPE_REAL64: |
{ | { |
Array<Real64> *x = reinterpret_cast<Array<Real64>*>(&u); | Array<Real64> *x = reinterpret_cast<Array<Real64>*>(&u); |
n = x->size(); |
// n can be invalid after re-allocation in _getFreeSpace ! |
|
loop = n = x->size(); |
arrayStart = _getFreeSpace( | arrayStart = _getFreeSpace( |
scmoUnion->_arrayValue, |
scmoUnion->arrayValue, |
n*sizeof(Real64), |
loop*sizeof(SCMBUnion), |
pmem); | pmem); |
memcpy(&((char*)*pmem)[arrayStart],x->getData(),n * sizeof(Real64)); |
|
|
ConstArrayIterator<Real64> iterator(*x); |
|
|
|
ptargetUnion = (SCMBUnion*)&(((char*)*pmem)[arrayStart]); |
|
for (Uint32 i = 0; i < loop; i++) |
|
{ |
|
ptargetUnion[i].simple.val.r64 = iterator[i]; |
|
ptargetUnion[i].simple.hasValue = true; |
|
} |
break; | break; |
} | } |
| |
case CIMTYPE_CHAR16: | case CIMTYPE_CHAR16: |
{ | { |
Array<Char16> *x = reinterpret_cast<Array<Char16>*>(&u); | Array<Char16> *x = reinterpret_cast<Array<Char16>*>(&u); |
n = x->size(); |
// n can be invalid after re-allocation in _getFreeSpace ! |
|
loop = n = x->size(); |
arrayStart = _getFreeSpace( | arrayStart = _getFreeSpace( |
scmoUnion->_arrayValue, |
scmoUnion->arrayValue, |
n*sizeof(Char16), |
loop*sizeof(SCMBUnion), |
pmem); | pmem); |
memcpy(&((char*)*pmem)[arrayStart],x->getData(),n * sizeof(Char16)); |
|
|
ConstArrayIterator<Char16> iterator(*x); |
|
|
|
ptargetUnion = (SCMBUnion*)&(((char*)*pmem)[arrayStart]); |
|
for (Uint32 i = 0; i < loop; i++) |
|
{ |
|
ptargetUnion[i].simple.val.c16 = iterator[i]; |
|
ptargetUnion[i].simple.hasValue = true; |
|
} |
break; | break; |
} | } |
| |
case CIMTYPE_STRING: | case CIMTYPE_STRING: |
{ | { |
SCMBDataPtr *ptr; |
|
|
|
Array<String> *x = reinterpret_cast<Array<String>*>(&u); | Array<String> *x = reinterpret_cast<Array<String>*>(&u); |
|
// n can be invalid after re-allocation in _getFreeSpace ! |
|
loop = n = x->size(); |
| |
n = x->size(); |
|
arrayStart = _getFreeSpace( | arrayStart = _getFreeSpace( |
scmoUnion->_arrayValue, |
scmoUnion->arrayValue, |
n*sizeof(SCMBDataPtr), |
loop*sizeof(SCMBUnion), |
pmem); | pmem); |
| |
for (Uint32 i = 0; i < n ; i++) |
ConstArrayIterator<String> iterator(*x); |
|
|
|
for (Uint32 i = 0; i < loop ; i++) |
{ | { |
// the pointer has to be set eache loop, | // the pointer has to be set eache loop, |
// because a reallocation may take place. | // because a reallocation may take place. |
ptr = (SCMBDataPtr*)(&((char*)*pmem)[arrayStart]); |
ptargetUnion = (SCMBUnion*)(&((char*)*pmem)[arrayStart]); |
_setString( (*x)[i],ptr[i], pmem ); |
_setString( iterator[i],ptargetUnion[i].stringValue, pmem ); |
} | } |
| |
break; | break; |
|
|
| |
case CIMTYPE_DATETIME: | case CIMTYPE_DATETIME: |
{ | { |
SCMBDateTime *ptr; |
|
Array<CIMDateTime> *x = reinterpret_cast<Array<CIMDateTime>*>(&u); | Array<CIMDateTime> *x = reinterpret_cast<Array<CIMDateTime>*>(&u); |
n = x->size(); |
// n can be invalid after reallocation in _getFreeSpace ! |
|
loop = n = x->size(); |
|
|
arrayStart = _getFreeSpace( | arrayStart = _getFreeSpace( |
scmoUnion->_arrayValue, |
scmoUnion->arrayValue, |
n*sizeof(SCMBDateTime), |
loop*sizeof(SCMBUnion), |
pmem); | pmem); |
| |
ptr=(SCMBDateTime*)(&((char*)*pmem)[arrayStart]); |
ConstArrayIterator<CIMDateTime> iterator(*x); |
| |
for (Uint32 i = 0; i < n ; i++) |
ptargetUnion = (SCMBUnion*)(&((char*)*pmem)[arrayStart]); |
|
|
|
for (Uint32 i = 0; i < loop ; i++) |
{ | { |
memcpy(&(ptr[i]),(*x)[i]._rep,sizeof(SCMBDateTime)); |
memcpy( |
|
&(ptargetUnion[i].dateTimeValue), |
|
iterator[i]._rep, |
|
sizeof(SCMBDateTime)); |
} | } |
break; | break; |
} | } |
| |
case CIMTYPE_REFERENCE: | case CIMTYPE_REFERENCE: |
|
{ |
|
Array<CIMObjectPath> *x = |
|
reinterpret_cast<Array<CIMObjectPath>*>(&u); |
| |
break; |
// if the array was previously set, delete the references ! |
|
_deleteArrayExtReference(scmoUnion->arrayValue,pmem); |
| |
case CIMTYPE_OBJECT: |
// n can be invalid after reallocation in _getFreeSpace ! |
|
loop = n = x->size(); |
|
|
|
arrayStart = _getFreeSpace( |
|
scmoUnion->arrayValue, |
|
loop*sizeof(SCMBUnion), |
|
pmem); |
|
|
|
ConstArrayIterator<CIMObjectPath> iterator(*x); |
|
|
|
ptargetUnion = (SCMBUnion*)(&((char*)*pmem)[arrayStart]); |
|
|
|
for (Uint32 i = 0; i < loop ; i++) |
|
{ |
|
|
|
ptargetUnion[i].extRefPtr = |
|
new SCMOInstance( |
|
iterator[i], |
|
&(((const char*)*pmem)[startNS]), |
|
sizeNS-1); |
|
// Was the conversion successful? |
|
if (ptargetUnion[i].extRefPtr->isEmpty()) |
|
{ |
|
// N0, delete the SCMOInstance. |
|
delete ptargetUnion[i].extRefPtr; |
|
ptargetUnion[i].extRefPtr = 0; |
|
} |
|
else |
|
{ |
|
_setExtRefIndex(&(ptargetUnion[i]),pmem); |
|
} |
|
} |
| |
break; | break; |
|
} |
|
case CIMTYPE_OBJECT: |
|
{ |
|
Array<CIMObject> *x = |
|
reinterpret_cast<Array<CIMObject>*>(&u); |
|
|
|
// if the array was previously set, delete the references ! |
|
_deleteArrayExtReference(scmoUnion->arrayValue,pmem); |
|
|
|
// n can be invalid after reallocation in _getFreeSpace ! |
|
loop = n = x->size(); |
|
|
|
arrayStart = _getFreeSpace( |
|
scmoUnion->arrayValue, |
|
loop*sizeof(SCMBUnion), |
|
pmem); |
|
|
|
ConstArrayIterator<CIMObject> iterator(*x); |
|
|
|
ptargetUnion = (SCMBUnion*)(&((char*)*pmem)[arrayStart]); |
|
|
|
for (Uint32 i = 0; i < loop ; i++) |
|
{ |
|
if (iterator[i].isUninitialized()) |
|
{ |
|
// the Object was empty. |
|
ptargetUnion[i].extRefPtr = 0; |
|
} |
|
else |
|
{ |
|
if (iterator[i].isClass()) |
|
{ |
|
CIMClass cimClass(iterator[i]); |
|
|
|
ptargetUnion[i].extRefPtr = |
|
new SCMOInstance( |
|
cimClass, |
|
(&((const char*)*pmem)[startNS])); |
|
// marke as class only ! |
|
ptargetUnion[i].extRefPtr-> |
|
inst.hdr->flags.isClassOnly=true; |
|
|
|
// This function can cause a reallocation ! |
|
// Pointers can be invalid after the call. |
|
_setExtRefIndex(&(ptargetUnion[i]),pmem); |
|
} |
|
else |
|
{ |
|
CIMInstance theInst(iterator[i]); |
| |
|
ptargetUnion[i].extRefPtr = |
|
new SCMOInstance( |
|
theInst, |
|
&(((const char*)*pmem)[startNS]), |
|
sizeNS-1); |
|
// Was the conversion successful? |
|
if (ptargetUnion[i].extRefPtr->isEmpty()) |
|
{ |
|
// N0, delete the SCMOInstance. |
|
delete ptargetUnion[i].extRefPtr; |
|
ptargetUnion[i].extRefPtr = 0; |
|
} |
|
else |
|
{ |
|
// This function can cause a reallocation ! |
|
// Pointers can be invalid after the call. |
|
_setExtRefIndex(&(ptargetUnion[i]),pmem); |
|
} |
|
} |
|
} |
|
} |
|
|
|
break; |
|
} |
case CIMTYPE_INSTANCE: | case CIMTYPE_INSTANCE: |
|
{ |
|
Array<CIMInstance> *x = |
|
reinterpret_cast<Array<CIMInstance>*>(&u); |
|
|
|
// if the array was previously set, delete the references ! |
|
_deleteArrayExtReference(scmoUnion->arrayValue,pmem); |
|
|
|
// n can be invalid after reallocation in _getFreeSpace ! |
|
loop = n = x->size(); |
|
|
|
arrayStart = _getFreeSpace( |
|
scmoUnion->arrayValue, |
|
loop*sizeof(SCMBUnion), |
|
pmem); |
|
|
|
ConstArrayIterator<CIMInstance> iterator(*x); |
|
|
|
ptargetUnion = (SCMBUnion*)(&((char*)*pmem)[arrayStart]); |
|
|
|
for (Uint32 i = 0; i < loop ; i++) |
|
{ |
|
if (iterator[i].isUninitialized()) |
|
{ |
|
// the Instance was empty. |
|
ptargetUnion[i].extRefPtr = 0; |
|
} |
|
else |
|
{ |
|
ptargetUnion[i].extRefPtr = |
|
new SCMOInstance( |
|
iterator[i], |
|
&(((const char*)*pmem)[startNS]), |
|
sizeNS-1); |
|
// Was the conversion successful? |
|
if (ptargetUnion[i].extRefPtr->isEmpty()) |
|
{ |
|
// N0, delete the SCMOInstance. |
|
delete ptargetUnion[i].extRefPtr; |
|
ptargetUnion[i].extRefPtr = 0; |
|
} |
|
else |
|
{ |
|
// This function can cause a reallocation ! |
|
// Pointers can be invalid after the call. |
|
_setExtRefIndex(&(ptargetUnion[i]),pmem); |
|
} |
|
|
|
} |
|
} |
| |
break; | break; |
} | } |
|
default: |
|
{ |
|
PEGASUS_ASSERT(false); |
|
break; |
|
} |
|
} |
} | } |
| |
| |
|
|
Uint64 start, | Uint64 start, |
SCMBMgmt_Header** pmem, | SCMBMgmt_Header** pmem, |
CIMType type, | CIMType type, |
|
Uint64 startNS, |
|
Uint32 sizeNS, |
Union& u) | Union& u) |
{ | { |
SCMBUnion* scmoUnion = (SCMBUnion*)&(((char*)*pmem)[start]); | SCMBUnion* scmoUnion = (SCMBUnion*)&(((char*)*pmem)[start]); |
|
|
{ | { |
case CIMTYPE_BOOLEAN: | case CIMTYPE_BOOLEAN: |
{ | { |
scmoUnion->_booleanValue = u._booleanValue; |
scmoUnion->simple.val.bin = u._booleanValue; |
|
scmoUnion->simple.hasValue=true; |
break; | break; |
} | } |
| |
case CIMTYPE_UINT8: | case CIMTYPE_UINT8: |
{ | { |
scmoUnion->_uint8Value = u._uint8Value; |
scmoUnion->simple.val.u8 = u._uint8Value; |
|
scmoUnion->simple.hasValue=true; |
break; | break; |
} | } |
| |
case CIMTYPE_SINT8: | case CIMTYPE_SINT8: |
{ | { |
scmoUnion->_sint8Value = u._sint8Value; |
scmoUnion->simple.val.s8 = u._sint8Value; |
|
scmoUnion->simple.hasValue=true; |
break; | break; |
} | } |
| |
case CIMTYPE_UINT16: | case CIMTYPE_UINT16: |
{ | { |
scmoUnion->_uint16Value = u._uint16Value; |
scmoUnion->simple.val.u16 = u._uint16Value; |
|
scmoUnion->simple.hasValue=true; |
break; | break; |
} | } |
| |
case CIMTYPE_SINT16: | case CIMTYPE_SINT16: |
{ | { |
scmoUnion->_sint16Value = u._sint16Value; |
scmoUnion->simple.val.s16 = u._sint16Value; |
|
scmoUnion->simple.hasValue=true; |
break; | break; |
} | } |
| |
case CIMTYPE_UINT32: | case CIMTYPE_UINT32: |
{ | { |
scmoUnion->_uint32Value = u._uint32Value; |
scmoUnion->simple.val.u32 = u._uint32Value; |
|
scmoUnion->simple.hasValue=true; |
break; | break; |
} | } |
| |
case CIMTYPE_SINT32: | case CIMTYPE_SINT32: |
{ | { |
scmoUnion->_sint32Value = u._sint32Value; |
scmoUnion->simple.val.s32 = u._sint32Value; |
|
scmoUnion->simple.hasValue=true; |
break; | break; |
} | } |
| |
case CIMTYPE_UINT64: | case CIMTYPE_UINT64: |
{ | { |
scmoUnion->_uint64Value = u._uint64Value; |
scmoUnion->simple.val.u64 = u._uint64Value; |
|
scmoUnion->simple.hasValue=true; |
break; | break; |
} | } |
| |
case CIMTYPE_SINT64: | case CIMTYPE_SINT64: |
{ | { |
scmoUnion->_sint64Value = u._sint64Value; |
scmoUnion->simple.val.s64 = u._sint64Value; |
|
scmoUnion->simple.hasValue=true; |
break; | break; |
} | } |
| |
case CIMTYPE_REAL32: | case CIMTYPE_REAL32: |
{ | { |
scmoUnion->_real32Value = u._real32Value; |
scmoUnion->simple.val.r32 = u._real32Value; |
|
scmoUnion->simple.hasValue=true; |
break; | break; |
} | } |
| |
case CIMTYPE_REAL64: | case CIMTYPE_REAL64: |
{ | { |
scmoUnion->_real64Value = u._real64Value; |
scmoUnion->simple.val.r64 = u._real64Value; |
|
scmoUnion->simple.hasValue=true; |
break; | break; |
} | } |
| |
case CIMTYPE_CHAR16: | case CIMTYPE_CHAR16: |
{ | { |
scmoUnion->_char16Value = u._char16Value; |
scmoUnion->simple.val.c16 = u._char16Value; |
|
scmoUnion->simple.hasValue=true; |
break; | break; |
} | } |
| |
case CIMTYPE_STRING: | case CIMTYPE_STRING: |
{ | { |
_setString(*((String*)((void*)&u)), |
CString cstr = ((String*)((void*)&u))->getCString(); |
scmoUnion->_stringValue, |
const char *cptr = (const char*)cstr; |
|
_setBinary( |
|
cptr, |
|
strlen(cptr) + 1, |
|
scmoUnion->stringValue, |
pmem ); | pmem ); |
break; | break; |
} | } |
| |
case CIMTYPE_DATETIME: | case CIMTYPE_DATETIME: |
{ | { |
|
|
memcpy( | memcpy( |
&scmoUnion->_dateTimeValue, |
&scmoUnion->dateTimeValue, |
(*((CIMDateTime*)((void*)&u)))._rep, | (*((CIMDateTime*)((void*)&u)))._rep, |
sizeof(SCMBDateTime)); | sizeof(SCMBDateTime)); |
break; | break; |
} | } |
| |
case CIMTYPE_REFERENCE: | case CIMTYPE_REFERENCE: |
|
{ |
|
if (0 != scmoUnion->extRefPtr) |
|
{ |
|
delete scmoUnion->extRefPtr; |
|
scmoUnion->extRefPtr = 0; |
|
} |
| |
break; |
if (0 == u._referenceValue) |
|
{ |
|
scmoUnion->extRefPtr = 0; |
|
return; |
|
} |
| |
case CIMTYPE_OBJECT: |
CIMObjectPath* theCIMObj = |
|
(CIMObjectPath*)((void*)&u._referenceValue); |
| |
break; |
scmoUnion->extRefPtr = |
case CIMTYPE_INSTANCE: |
new SCMOInstance( |
|
*theCIMObj, |
|
&(((const char*)*pmem)[startNS]), |
|
sizeNS-1); |
| |
break; |
// Was the conversion successful? |
|
if (scmoUnion->extRefPtr->isEmpty()) |
|
{ |
|
// N0, delete the SCMOInstance. |
|
delete scmoUnion->extRefPtr; |
|
scmoUnion->extRefPtr = 0; |
} | } |
|
else |
|
{ |
|
// This function can cause a reallocation ! |
|
// Pointers can be invalid after the call. |
|
_setExtRefIndex(scmoUnion,pmem); |
} | } |
| |
SCMO_RC SCMOInstance::_getPropertyAtNodeIndex( |
break; |
Uint32 node, |
} |
const char** pname, |
case CIMTYPE_OBJECT: |
CIMType& type, |
|
const void** pvalue, |
|
Boolean& isArray, |
|
Uint32& size ) const |
|
{ | { |
SCMBValue* theInstPropNodeArray = |
if (0 != scmoUnion->extRefPtr) |
(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]; |
|
|
|
// the property name is always from the class. |
|
// return the absolut pointer to the property name, |
|
// the caller has to copy the name! |
|
*pname=_getCharString( |
|
theClassPropNodeArray[node].theProperty.name, |
|
inst.hdr->theClass->cls.base); |
|
|
|
// the property was set by the provider. |
|
if (theInstPropNodeArray[node].flags.isSet) |
|
{ | { |
|
delete scmoUnion->extRefPtr; |
|
scmoUnion->extRefPtr = 0; |
|
} |
| |
type = theInstPropNodeArray[node].valueType; |
if (0 == u._referenceValue) |
isArray = theInstPropNodeArray[node].flags.isArray; |
|
if (isArray) |
|
{ | { |
size = theInstPropNodeArray[node].valueArraySize; |
scmoUnion->extRefPtr=0; |
|
return; |
} | } |
| |
if (theInstPropNodeArray[node].flags.isNull) |
CIMObject* theCIMObject =(CIMObject*)((void*)&u._objectValue); |
|
|
|
if (theCIMObject->isUninitialized()) |
{ | { |
return SCMO_NULL_VALUE; |
// the Object was empty. |
|
scmoUnion->extRefPtr = 0; |
} | } |
|
else |
|
{ |
|
if (theCIMObject->isClass()) |
|
{ |
|
CIMClass cimClass(*theCIMObject); |
| |
// calculate the relative index for the value. |
scmoUnion->extRefPtr = |
Uint64 start = |
new SCMOInstance( |
(const char*)&(theInstPropNodeArray[node].value) - |
cimClass, |
inst.base; |
(&((const char*)*pmem)[startNS])); |
|
// marke as class only ! |
|
scmoUnion->extRefPtr->inst.hdr->flags.isClassOnly=true; |
| |
// the caller has to copy the value ! |
// This function can cause a reallocation ! |
*pvalue = _getSCMBUnion(type,isArray,size,start,inst.base); |
// Pointers can be invalid after the call. |
|
_setExtRefIndex(scmoUnion,pmem); |
|
} |
|
else |
|
{ |
|
CIMInstance theCIMInst(*theCIMObject); |
|
|
|
scmoUnion->extRefPtr = |
|
new SCMOInstance( |
|
theCIMInst, |
|
&(((const char*)*pmem)[startNS]), |
|
sizeNS-1); |
|
|
|
// Was the conversion successful? |
|
if (scmoUnion->extRefPtr->isEmpty()) |
|
{ |
|
// N0, delete the SCMOInstance. |
|
delete scmoUnion->extRefPtr; |
|
scmoUnion->extRefPtr = 0; |
|
} |
|
else |
|
{ |
|
// This function can cause a reallocation ! |
|
// Pointers can be invalid after the call. |
|
_setExtRefIndex(scmoUnion,pmem); |
|
} |
|
} |
|
} |
|
break; |
|
} |
|
case CIMTYPE_INSTANCE: |
|
{ |
|
if (0 != scmoUnion->extRefPtr) |
|
{ |
|
delete scmoUnion->extRefPtr; |
|
scmoUnion->extRefPtr = 0; |
|
} |
|
|
|
if (0 == u._referenceValue) |
|
{ |
|
scmoUnion->extRefPtr=0; |
|
return; |
|
} |
|
|
|
CIMInstance* theCIMInst = |
|
(CIMInstance*)((void*)&u._instanceValue); |
|
|
|
if (theCIMInst->isUninitialized()) |
|
{ |
|
// the Instance was empty. |
|
scmoUnion->extRefPtr = 0; |
|
} |
|
else |
|
{ |
|
scmoUnion->extRefPtr = |
|
new SCMOInstance( |
|
*theCIMInst, |
|
&(((const char*)*pmem)[startNS]), |
|
sizeNS-1); |
|
|
|
// Was the conversion successful? |
|
if (scmoUnion->extRefPtr->isEmpty()) |
|
{ |
|
// N0, delete the SCMOInstance. |
|
delete scmoUnion->extRefPtr; |
|
scmoUnion->extRefPtr = 0; |
|
} |
|
else |
|
{ |
|
// This function can cause a reallocation ! |
|
// Pointers can be invalid after the call. |
|
_setExtRefIndex(scmoUnion,pmem); |
|
} |
|
} |
|
break; |
|
} |
|
default: |
|
{ |
|
PEGASUS_ASSERT(false); |
|
break; |
|
} |
|
} |
|
} |
|
|
|
SCMO_RC SCMOInstance::_getPropertyAtNodeIndex( |
|
Uint32 node, |
|
const char** pname, |
|
CIMType& type, |
|
const SCMBUnion** pvalue, |
|
Boolean& isArray, |
|
Uint32& size ) const |
|
{ |
|
SCMBValue* theInstPropNodeArray = |
|
(SCMBValue*)&inst.base[inst.hdr->propertyArray.start]; |
|
|
|
// create a pointer to property node array of the class. |
|
Uint64 idx = inst.hdr->theClass.ptr->cls.hdr->propertySet.nodeArray.start; |
|
SCMBClassPropertyNode* theClassPropNodeArray = |
|
(SCMBClassPropertyNode*)&(inst.hdr->theClass.ptr->cls.base)[idx]; |
|
|
|
// the property name is always from the class. |
|
// return the absolut pointer to the property name, |
|
// the caller has to copy the name! |
|
*pname=_getCharString( |
|
theClassPropNodeArray[node].theProperty.name, |
|
inst.hdr->theClass.ptr->cls.base); |
|
|
|
// the property was set by the provider. |
|
if (theInstPropNodeArray[node].flags.isSet) |
|
{ |
|
|
|
type = theInstPropNodeArray[node].valueType; |
|
isArray = theInstPropNodeArray[node].flags.isArray; |
|
if (isArray) |
|
{ |
|
size = theInstPropNodeArray[node].valueArraySize; |
|
} |
|
|
|
if (theInstPropNodeArray[node].flags.isNull) |
|
{ |
|
return SCMO_NULL_VALUE; |
|
} |
|
|
|
// calculate the relative index for the value. |
|
Uint64 start = |
|
(const char*)&(theInstPropNodeArray[node].value) - |
|
inst.base; |
|
|
|
// the caller has to copy the value ! |
|
*pvalue = _resolveSCMBUnion(type,isArray,size,start,inst.base); |
| |
return SCMO_OK; | return SCMO_OK; |
} | } |
|
|
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 = _getSCMBUnion( |
*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 == NULL ) |
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. |
// kepp the ref counter of the class correct ! |
inst.base = newBase; |
newInst.inst.hdr->theClass = new SCMOClass(*(this->inst.hdr->theClass)); |
// reset the refcounter of this instance |
|
inst.hdr->refCount = 1; |
|
// keep the ref counter of the class correct ! |
|
inst.hdr->theClass.ptr = new SCMOClass(*(inst.hdr->theClass.ptr)); |
|
// keep the ref count for external references |
|
_copyExternalReferences(); |
| |
return newInst; |
|
} | } |
| |
void SCMOInstance::_copyKeyBindings(SCMOInstance& targetInst) const | void SCMOInstance::_copyKeyBindings(SCMOInstance& targetInst) const |
{ | { |
Uint32 noBindings = inst.hdr->numberKeyBindings; | Uint32 noBindings = inst.hdr->numberKeyBindings; |
SCMBInstanceKeyBinding* sourceArray = |
|
(SCMBInstanceKeyBinding*)&inst.base[inst.hdr->keyBindingArray.start]; |
|
| |
SCMBInstanceKeyBinding* targetArray; |
SCMBKeyBindingValue* sourceArray = |
|
(SCMBKeyBindingValue*)&(inst.base[inst.hdr->keyBindingArray.start]); |
|
|
|
// Address the class keybinding information |
|
const SCMBClass_Main* clshdr = inst.hdr->theClass.ptr->cls.hdr; |
|
const char * clsbase = inst.hdr->theClass.ptr->cls.base; |
|
SCMBKeyBindingNode* scmoClassArray = |
|
(SCMBKeyBindingNode*)&(clsbase[clshdr->keyBindingSet.nodeArray.start]); |
|
|
|
SCMBKeyBindingValue* targetArray; |
| |
for (Uint32 i = 0; i < noBindings; i++) | for (Uint32 i = 0; i < noBindings; i++) |
{ | { |
// hast to be set every time, because of reallocation. | // hast to be set every time, because of reallocation. |
targetArray=(SCMBInstanceKeyBinding*)&targetInst.inst.base |
targetArray=(SCMBKeyBindingValue*)&(targetInst.inst.base) |
[targetInst.inst.hdr->keyBindingArray.start]; | [targetInst.inst.hdr->keyBindingArray.start]; |
if(sourceArray[i].isSet) | if(sourceArray[i].isSet) |
{ | { |
_setBinary( |
// this has to be done on the target instance to keep constantness. |
_resolveDataPtr(sourceArray[i].value,inst.base), |
targetInst._setKeyBindingFromSCMBUnion( |
sourceArray[i].value.length, |
scmoClassArray[i].type, |
targetArray[i].value, |
sourceArray[i].data, |
&targetInst.inst.mem); |
inst.base, |
|
targetArray[i]); |
|
} |
|
} |
|
|
|
// 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) |
|
{ |
|
targetInst._setUserDefinedKeyBinding(*theUserDefKBElement, |
|
inst.base); |
|
} |
| |
targetArray[i].isSet=true; |
theUserDefKBElement = |
|
(SCMBUserKeyBindingElement*) |
|
&(inst.base[theUserDefKBElement->nextElement.start]); |
|
} // for all user def. key bindings. |
} | } |
} | } |
| |
|
|
|
void SCMOInstance::_setUserDefinedKeyBinding( |
|
SCMBUserKeyBindingElement& theInsertElement, |
|
char* elementBase) |
|
{ |
|
|
|
SCMBUserKeyBindingElement* ptrNewElement; |
|
|
|
// get an exsiting or new user defined key binding |
|
ptrNewElement = _getUserDefinedKeyBinding( |
|
_getCharString(theInsertElement.name,elementBase), |
|
// lenght is without the trailing '\0' |
|
theInsertElement.name.size-1, |
|
theInsertElement.type); |
|
|
|
// Copy the data |
|
_setKeyBindingFromSCMBUnion( |
|
theInsertElement.type, |
|
theInsertElement.value.data, |
|
elementBase, |
|
ptrNewElement->value); |
|
|
} | } |
Uint32 SCMOInstance::getPropertyCount() const |
|
|
|
|
SCMBUserKeyBindingElement* SCMOInstance::_getUserDefinedKeyBindingAt( |
|
Uint32 index ) const |
{ | { |
if (inst.hdr->flags.isFiltered) |
|
|
// Get the start element |
|
SCMBUserKeyBindingElement *ptrNewElement = |
|
(SCMBUserKeyBindingElement*) |
|
&(inst.base[inst.hdr->userKeyBindingElement.start]); |
|
|
|
// calculate the index within the user defined key bindings |
|
index = index - inst.hdr->numberKeyBindings; |
|
|
|
// traverse trough the user defindes key binding nodes. |
|
for (Uint32 i = 0; i < index; i ++) |
{ | { |
return(inst.hdr->filterProperties); |
PEGASUS_ASSERT(ptrNewElement->nextElement.start != 0); |
|
ptrNewElement = (SCMBUserKeyBindingElement*) |
|
&(inst.base[ptrNewElement->nextElement.start]); |
|
} |
|
|
|
return ptrNewElement; |
} | } |
| |
|
SCMBUserKeyBindingElement* SCMOInstance::_getUserDefinedKeyBinding( |
|
const char* name, |
|
Uint32 nameLen, |
|
CIMType type) |
|
{ |
|
SCMBDataPtr newElement; |
|
SCMBUserKeyBindingElement* ptrNewElement; |
|
Uint32 node; |
|
|
|
// is the key binding already stored as user defind in the instance ? |
|
if (SCMO_OK == _getUserKeyBindingNodeIndex(node,name)) |
|
{ |
|
ptrNewElement = _getUserDefinedKeyBindingAt(node); |
|
} |
|
else // Not found, create a new user defined key binding. |
|
{ |
|
|
|
_getFreeSpace(newElement, |
|
sizeof(SCMBUserKeyBindingElement), |
|
&inst.mem); |
|
|
|
ptrNewElement = |
|
(SCMBUserKeyBindingElement*)&(inst.base[newElement.start]); |
|
|
|
// link new first user defined key binding element into chain: |
|
// - Assing the start point of user key binding element chain |
|
// to the next element of the new element. |
|
ptrNewElement->nextElement.start = |
|
inst.hdr->userKeyBindingElement.start; |
|
ptrNewElement->nextElement.size = |
|
inst.hdr->userKeyBindingElement.size; |
|
// - Assing the the new element |
|
// to the start point of user key binding element chain |
|
inst.hdr->userKeyBindingElement.start = newElement.start; |
|
inst.hdr->userKeyBindingElement.size = newElement.size; |
|
// Adjust the couter of user defined key bindings. |
|
inst.hdr->numberUserKeyBindings++; |
|
|
|
|
|
// Copy the type |
|
ptrNewElement->type = type; |
|
ptrNewElement->value.isSet=false; |
|
|
|
// Copy the key binding name including the trailing '\0' |
|
_setBinary(name,nameLen+1,ptrNewElement->name,&inst.mem); |
|
|
|
// reset the pointer. May the instance was reallocated. |
|
ptrNewElement = |
|
(SCMBUserKeyBindingElement*)&(inst.base[newElement.start]); |
|
|
|
} |
|
|
|
|
|
return ptrNewElement; |
|
|
|
} |
|
|
|
Uint32 SCMOInstance::getPropertyCount() const |
|
{ |
return(inst.hdr->numberProperties); | return(inst.hdr->numberProperties); |
} | } |
| |
void* SCMOInstance::_getSCMBUnion( |
SCMBUnion * SCMOInstance::_resolveSCMBUnion( |
CIMType type, | CIMType type, |
Boolean isArray, | Boolean isArray, |
Uint32 size, | Uint32 size, |
|
|
| |
SCMBUnion* u = (SCMBUnion*)&(base[start]); | SCMBUnion* u = (SCMBUnion*)&(base[start]); |
| |
void* av = NULL; |
SCMBUnion* av = 0; |
| |
if (isArray) | if (isArray) |
{ | { |
if (size == 0) | if (size == 0) |
{ | { |
return NULL; |
return 0; |
} | } |
av = (void*)&base[u->_arrayValue.start]; |
av = (SCMBUnion*)&(base[u->arrayValue.start]); |
} | } |
| |
|
|
switch (type) | switch (type) |
{ | { |
case CIMTYPE_BOOLEAN: | case CIMTYPE_BOOLEAN: |
|
|
case CIMTYPE_REAL64: | case CIMTYPE_REAL64: |
case CIMTYPE_CHAR16: | case CIMTYPE_CHAR16: |
case CIMTYPE_DATETIME: | case CIMTYPE_DATETIME: |
|
case CIMTYPE_REFERENCE: |
|
case CIMTYPE_OBJECT: |
|
case CIMTYPE_INSTANCE: |
{ | { |
if(isArray) | if(isArray) |
{ | { |
return ((void*)av); |
return (av); |
} | } |
else | else |
{ | { |
return((void*)u); |
return(u); |
} | } |
break; |
|
} | } |
| |
case CIMTYPE_STRING: | case CIMTYPE_STRING: |
{ | { |
SCMBDataPtr *ptr; |
SCMBUnion *ptr; |
char** tmp=NULL; |
|
| |
if (isArray) | if (isArray) |
{ | { |
// allocate an array of char* pointers. |
|
tmp = (char**)malloc(size*sizeof(char*)); |
ptr = (SCMBUnion*)malloc(size*sizeof(SCMBUnion)); |
if (tmp == NULL ) |
if (ptr == 0 ) |
{ | { |
throw PEGASUS_STD(bad_alloc)(); | throw PEGASUS_STD(bad_alloc)(); |
} | } |
| |
// use temporary variables to avoid casting |
|
ptr = (SCMBDataPtr*)av; |
|
|
|
for(Uint32 i = 0; i < size; i++) | for(Uint32 i = 0; i < size; i++) |
{ | { |
// resolv relative pointer to absolute pointer | // resolv relative pointer to absolute pointer |
tmp[i] = (char*)_getCharString(ptr[i],base); |
ptr[i].extString.pchar = |
|
(char*)_getCharString(av[i].stringValue,base); |
|
// lenght with out the trailing /0 ! |
|
ptr[i].extString.length = av[i].stringValue.size-1; |
|
} |
|
} |
|
else |
|
{ |
|
ptr = (SCMBUnion*)malloc(sizeof(SCMBUnion)); |
|
ptr->extString.pchar = |
|
(char*)_getCharString(u->stringValue,base); |
|
// lenght with out the trailing /0 ! |
|
ptr->extString.length = u->stringValue.size-1; |
|
} |
|
|
|
return(ptr); |
|
} |
|
default: |
|
{ |
|
PEGASUS_ASSERT(false); |
|
break; |
|
} |
|
} |
|
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 |
|
{ |
|
// count of class keys + user definded keys |
|
return(inst.hdr->numberKeyBindings+ |
|
inst.hdr->numberUserKeyBindings); |
} | } |
| |
return((void*)tmp); |
|
|
SCMO_RC SCMOInstance::getKeyBindingAt( |
|
Uint32 node, |
|
const char** pname, |
|
CIMType& type, |
|
const SCMBUnion** pvalue) const |
|
{ |
|
SCMO_RC rc; |
|
const SCMBUnion* pdata=0; |
|
Uint32 pnameLen=0; |
|
|
|
*pname = 0; |
|
*pvalue = 0; |
|
|
|
// count of class keys + user definded keys |
|
if (node >= (inst.hdr->numberKeyBindings+ |
|
inst.hdr->numberUserKeyBindings)) |
|
{ |
|
return SCMO_INDEX_OUT_OF_BOUND; |
|
} |
|
|
|
rc = _getKeyBindingDataAtNodeIndex(node,pname,pnameLen,type,&pdata); |
|
if (rc != SCMO_OK) |
|
{ |
|
return rc; |
|
} |
|
|
|
*pvalue = _resolveSCMBUnion( |
|
type, |
|
false, // A key binding can never be an array. |
|
0, |
|
(char*)pdata-inst.base, |
|
inst.base); |
|
|
|
return SCMO_OK; |
|
|
|
} |
|
|
|
SCMO_RC SCMOInstance::getKeyBinding( |
|
const char* name, |
|
CIMType& type, |
|
const SCMBUnion** pvalue) const |
|
{ |
|
SCMO_RC rc; |
|
Uint32 node; |
|
const char* pname=0; |
|
const SCMBUnion* pdata=0; |
|
Uint32 pnameLen=0; |
|
|
|
*pvalue = 0; |
|
|
|
rc = inst.hdr->theClass.ptr->_getKeyBindingNodeIndex(node,name); |
|
if (rc != SCMO_OK) |
|
{ |
|
// look at the user defined key bindings. |
|
rc = _getUserKeyBindingNodeIndex(node,name); |
|
if (rc != SCMO_OK) |
|
{ |
|
return rc; |
|
} |
|
} |
|
|
|
rc = _getKeyBindingDataAtNodeIndex(node,&pname,pnameLen,type,&pdata); |
|
|
|
if (rc != SCMO_OK) |
|
{ |
|
return rc; |
|
} |
|
|
|
*pvalue = _resolveSCMBUnion( |
|
type, |
|
false, // A key binding can never be an array. |
|
0, |
|
(char*)pdata-inst.base, |
|
inst.base); |
|
|
|
return SCMO_OK; |
|
} |
|
|
|
|
|
SCMO_RC SCMOInstance::_getKeyBindingDataAtNodeIndex( |
|
Uint32 node, |
|
const char** pname, |
|
Uint32 & pnameLen, |
|
CIMType & type, |
|
const SCMBUnion** pdata) const |
|
{ |
|
if (node < inst.hdr->numberKeyBindings) |
|
{ |
|
SCMBKeyBindingValue* theInstKeyBindValueArray = |
|
(SCMBKeyBindingValue*)&(inst.base[inst.hdr->keyBindingArray.start]); |
|
|
|
// create a pointer to key binding 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]); |
|
|
|
type = theClassKeyBindNodeArray[node].type; |
|
|
|
// First resolve pointer to the key binding name |
|
pnameLen = theClassKeyBindNodeArray[node].name.size; |
|
*pname = _getCharString( |
|
theClassKeyBindNodeArray[node].name, |
|
inst.hdr->theClass.ptr->cls.base); |
|
|
|
// There is no value set in the instance |
|
if (!theInstKeyBindValueArray[node].isSet) |
|
{ |
|
return SCMO_NULL_VALUE; |
|
} |
|
|
|
*pdata = &(theInstKeyBindValueArray[node].data); |
|
} |
|
else // look at the user defined key bindings |
|
{ |
|
|
|
SCMBUserKeyBindingElement* theElem = _getUserDefinedKeyBindingAt(node); |
|
|
|
type = theElem->type; |
|
|
|
pnameLen = theElem->name.size; |
|
*pname = _getCharString(theElem->name,inst.base); |
|
|
|
// There is no value set in the instance |
|
if (!theElem->value.isSet) |
|
{ |
|
return SCMO_NULL_VALUE; |
|
} |
|
|
|
*pdata = &(theElem->value.data); |
|
|
|
} |
|
|
|
return SCMO_OK; |
|
} |
|
|
|
SCMO_RC SCMOInstance::_getUserKeyBindingNodeIndex( |
|
Uint32& node, |
|
const char* name) const |
|
{ |
|
|
|
Uint32 len = strlen(name); |
|
node = 0; |
|
|
|
Uint64 elementStart = inst.hdr->userKeyBindingElement.start; |
|
|
|
while (elementStart != 0) |
|
{ |
|
SCMBUserKeyBindingElement* theUserDefKBElement = |
|
(SCMBUserKeyBindingElement*)&(inst.base[elementStart]); |
|
|
|
if (_equalNoCaseUTF8Strings( |
|
theUserDefKBElement->name,inst.base,name,len)) |
|
{ |
|
// the node index of a user defined key binding has an offset |
|
// by the number of key bindings defined in the class |
|
node = node + inst.hdr->numberKeyBindings; |
|
return SCMO_OK; |
|
} |
|
node = node + 1; |
|
elementStart = theUserDefKBElement->nextElement.start; |
|
} |
|
|
|
return SCMO_NOT_FOUND; |
|
|
|
} |
|
|
|
CIMType SCMOInstance::_CIMTypeFromKeyBindingType( |
|
const char* key, |
|
CIMKeyBinding::Type t) |
|
{ |
|
switch( t ) |
|
{ |
|
case CIMKeyBinding::NUMERIC: |
|
{ |
|
if( *(key)=='-' ) |
|
{ |
|
Sint64 x; |
|
// check if it is realy an integer |
|
if (StringConversion::stringToSignedInteger(key, x)) |
|
{ |
|
return CIMTYPE_SINT64; |
|
} |
|
else |
|
{ |
|
return CIMTYPE_REAL64; |
|
} |
|
} |
|
else |
|
{ |
|
Uint64 x; |
|
// check if it is realy an integer |
|
if (StringConversion::stringToUnsignedInteger(key, x)) |
|
{ |
|
return CIMTYPE_UINT64; |
} | } |
else | else |
{ | { |
return((void*)_getCharString(u->_stringValue,base)); |
return CIMTYPE_REAL64; |
|
} |
|
} |
} | } |
| |
| |
|
case CIMKeyBinding::STRING: |
|
{ |
|
return CIMTYPE_STRING; |
|
} |
|
|
|
case CIMKeyBinding::BOOLEAN: |
|
{ |
|
return CIMTYPE_BOOLEAN; |
|
} |
|
|
|
case CIMKeyBinding::REFERENCE: |
|
{ |
|
return CIMTYPE_REFERENCE; |
|
} |
|
|
|
default: |
|
return CIMTYPE_UINT64; |
|
} |
|
return CIMTYPE_UINT64; |
|
} |
|
|
|
Boolean SCMOInstance::_setCimKeyBindingStringToSCMOKeyBindingValue( |
|
const String& kbs, |
|
CIMType type, |
|
SCMBKeyBindingValue& scmoKBV |
|
) |
|
{ |
|
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) |
|
{ |
|
// The string is empty ! Do nothing. |
|
return false; |
|
} |
|
|
|
CString a = kbs.getCString(); |
|
const char* v = a; |
|
|
|
switch (type) |
|
{ |
|
case CIMTYPE_UINT8: |
|
{ |
|
Uint64 x; |
|
if (StringConversion::stringToUnsignedInteger(v, x) && |
|
StringConversion::checkUintBounds(x, type)) |
|
{ |
|
scmoKBV.data.simple.val.u8 = Uint8(x); |
|
scmoKBV.data.simple.hasValue=true; |
|
scmoKBV.isSet=true; |
|
} |
|
break; |
|
} |
|
case CIMTYPE_UINT16: |
|
{ |
|
Uint64 x; |
|
if (StringConversion::stringToUnsignedInteger(v, x) && |
|
StringConversion::checkUintBounds(x, type)) |
|
{ |
|
scmoKBV.data.simple.val.u16 = Uint16(x); |
|
scmoKBV.data.simple.hasValue=true; |
|
scmoKBV.isSet=true; |
|
} |
break; | break; |
} | } |
| |
case CIMTYPE_REFERENCE: |
case CIMTYPE_UINT32: |
|
{ |
|
Uint64 x; |
|
if (StringConversion::stringToUnsignedInteger(v, x) && |
|
StringConversion::checkUintBounds(x, type)) |
|
{ |
|
scmoKBV.data.simple.val.u32 = Uint32(x); |
|
scmoKBV.data.simple.hasValue=true; |
|
scmoKBV.isSet=true; |
|
} |
|
break; |
|
} |
| |
|
case CIMTYPE_UINT64: |
|
{ |
|
Uint64 x; |
|
if (StringConversion::stringToUnsignedInteger(v, x)) |
|
{ |
|
scmoKBV.data.simple.val.u64 = x; |
|
scmoKBV.data.simple.hasValue=true; |
|
scmoKBV.isSet=true; |
|
} |
break; | break; |
|
} |
| |
case CIMTYPE_OBJECT: |
case CIMTYPE_SINT8: |
|
{ |
|
Sint64 x; |
|
if (StringConversion::stringToSignedInteger(v, x) && |
|
StringConversion::checkSintBounds(x, type)) |
|
{ |
|
scmoKBV.data.simple.val.s8 = Sint8(x); |
|
scmoKBV.data.simple.hasValue=true; |
|
scmoKBV.isSet=true; |
|
} |
|
break; |
|
} |
| |
|
case CIMTYPE_SINT16: |
|
{ |
|
Sint64 x; |
|
if (StringConversion::stringToSignedInteger(v, x) && |
|
StringConversion::checkSintBounds(x, type)) |
|
{ |
|
scmoKBV.data.simple.val.s16 = Sint16(x); |
|
scmoKBV.data.simple.hasValue=true; |
|
scmoKBV.isSet=true; |
|
} |
break; | break; |
|
} |
| |
case CIMTYPE_INSTANCE: |
case CIMTYPE_SINT32: |
|
{ |
|
Sint64 x; |
|
if (StringConversion::stringToSignedInteger(v, x) && |
|
StringConversion::checkSintBounds(x, type)) |
|
{ |
|
scmoKBV.data.simple.val.s32 = Sint32(x); |
|
scmoKBV.data.simple.hasValue=true; |
|
scmoKBV.isSet=true; |
|
} |
|
break; |
|
} |
| |
|
case CIMTYPE_SINT64: |
|
{ |
|
Sint64 x; |
|
if (StringConversion::stringToSignedInteger(v, x)) |
|
{ |
|
scmoKBV.data.simple.val.s64 = x; |
|
scmoKBV.data.simple.hasValue=true; |
|
scmoKBV.isSet=true; |
|
} |
break; | break; |
|
} |
| |
default: |
case CIMTYPE_DATETIME: |
PEGASUS_ASSERT(false); |
{ |
|
CIMDateTime tmp; |
|
|
|
try |
|
{ |
|
tmp.set(v); |
|
} |
|
catch (InvalidDateTimeFormatException&) |
|
{ |
|
return false; |
|
} |
|
|
|
memcpy( |
|
&(scmoKBV.data.dateTimeValue), |
|
tmp._rep, |
|
sizeof(SCMBDateTime)); |
|
scmoKBV.isSet=true; |
|
break; |
|
} |
|
|
|
case CIMTYPE_REAL32: |
|
{ |
|
Real64 x; |
|
|
|
if (StringConversion::stringToReal64(v, x)) |
|
{ |
|
scmoKBV.data.simple.val.r32 = Real32(x); |
|
scmoKBV.data.simple.hasValue=true; |
|
scmoKBV.isSet=true; |
|
} |
|
break; |
|
} |
|
|
|
case CIMTYPE_REAL64: |
|
{ |
|
Real64 x; |
|
|
|
if (StringConversion::stringToReal64(v, x)) |
|
{ |
|
scmoKBV.data.simple.val.r64 = x; |
|
scmoKBV.data.simple.hasValue=true; |
|
scmoKBV.isSet=true; |
|
} |
|
break; |
|
} |
|
|
|
case CIMTYPE_CHAR16: |
|
{ |
|
if (kbs.size() == 1) |
|
{ |
|
scmoKBV.data.simple.val.c16 = kbs[0]; |
|
scmoKBV.data.simple.hasValue=true; |
|
scmoKBV.isSet=true; |
|
} |
|
break; |
|
} |
|
case CIMTYPE_BOOLEAN: |
|
{ |
|
if (String::equalNoCase(kbs,"TRUE")) |
|
{ |
|
scmoKBV.data.simple.val.bin = true; |
|
scmoKBV.data.simple.hasValue=true; |
|
scmoKBV.isSet=true; |
|
} |
|
else if (String::equalNoCase(kbs,"FALSE")) |
|
{ |
|
scmoKBV.data.simple.val.bin = false; |
|
scmoKBV.data.simple.hasValue=true; |
|
scmoKBV.isSet=true; |
|
} |
break; | break; |
} | } |
return NULL; |
|
|
case CIMTYPE_STRING: |
|
{ |
|
scmoKBV.isSet=true; |
|
// Can cause reallocation ! |
|
_setString(kbs,scmoKBV.data.stringValue,&inst.mem); |
|
return true; |
|
} |
|
case CIMTYPE_REFERENCE: |
|
{ |
|
if (0 != scmoKBV.data.extRefPtr) |
|
{ |
|
delete scmoKBV.data.extRefPtr; |
|
scmoKBV.data.extRefPtr = 0; |
|
scmoKBV.isSet=false; |
|
} |
|
// TBD: Optimize parsing and SCMOInstance creation. |
|
CIMObjectPath theCIMObj(kbs); |
|
|
|
scmoKBV.data.extRefPtr = new SCMOInstance(theCIMObj); |
|
scmoKBV.isSet=true; |
|
|
|
// Was the conversion successful? |
|
if (scmoKBV.data.extRefPtr->isEmpty()) |
|
{ |
|
// N0, delete the SCMOInstance. |
|
delete scmoKBV.data.extRefPtr; |
|
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); |
|
} |
|
break; |
} | } |
|
case CIMTYPE_OBJECT: |
Uint32 SCMOInstance::getKeyBindingCount() |
case CIMTYPE_INSTANCE: |
{ | { |
return(inst.hdr->numberKeyBindings); |
// From PEP 194: EmbeddedObjects cannot be keys. |
|
throw TypeMismatchException(); |
} | } |
|
default: |
|
|
SCMO_RC SCMOInstance::getKeyBindingAt( |
|
Uint32 node, |
|
const char** pname, |
|
CIMKeyBinding::Type& type, |
|
const char** pvalue) const |
|
{ |
|
*pname = NULL; |
|
*pvalue = NULL; |
|
|
|
if (node >= inst.hdr->numberKeyBindings) |
|
{ | { |
return SCMO_INDEX_OUT_OF_BOUND; |
PEGASUS_ASSERT(false); |
|
break; |
|
} |
} | } |
| |
return _getKeyBindingAtNodeIndex(node,pname,type,pvalue); |
return scmoKBV.isSet; |
} | } |
| |
SCMO_RC SCMOInstance::getKeyBinding( |
SCMO_RC SCMOInstance::_setKeyBindingFromString( |
const char* name, | const char* name, |
CIMKeyBinding::Type& type, |
CIMType type, |
const char** pvalue) const |
String cimKeyBinding) |
{ | { |
SCMO_RC rc; |
|
Uint32 node; | Uint32 node; |
const char* pname=NULL; |
|
| |
rc = inst.hdr->theClass->_getKeyBindingNodeIndex(node,name); |
if (0 == name) |
if (rc != SCMO_OK) |
|
{ | { |
return rc; |
return SCMO_INVALID_PARAMETER; |
} |
|
|
|
return _getKeyBindingAtNodeIndex(node,&pname,type,pvalue); |
|
|
|
} | } |
| |
SCMO_RC SCMOInstance::_getKeyBindingAtNodeIndex( |
if (SCMO_OK == inst.hdr->theClass.ptr->_getKeyBindingNodeIndex(node,name)) |
Uint32 node, |
|
const char** pname, |
|
CIMKeyBinding::Type& type, |
|
const char** pvalue) const |
|
{ | { |
|
|
SCMBInstanceKeyBinding* theInstKeyBindNodeArray = |
|
(SCMBInstanceKeyBinding*)&inst.base[inst.hdr->keyBindingArray.start]; |
|
|
|
// 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]); |
| |
type = theClassKeyBindNodeArray[node].type; |
// create a pointer to instance keybinding values |
|
SCMBKeyBindingValue* theInstKeyBindValueArray = |
|
(SCMBKeyBindingValue*)&(inst.base[inst.hdr->keyBindingArray.start]); |
|
|
|
// If the set was not successful, the conversion was not successful |
|
if ( !_setCimKeyBindingStringToSCMOKeyBindingValue( |
|
cimKeyBinding, |
|
theClassKeyBindNodeArray[node].type, |
|
theInstKeyBindValueArray[node])) |
|
{ |
|
return SCMO_TYPE_MISSMATCH; |
|
} |
| |
*pname = _getCharString( |
return SCMO_OK; |
theClassKeyBindNodeArray[node].name, |
} |
inst.hdr->theClass->cls.base); |
|
| |
// There is no value set in the instance |
// the key binig does not belong to the associated class |
if (!theInstKeyBindNodeArray[node].isSet) |
// add/set it as user defined key binding. |
|
SCMBUserKeyBindingElement* ptrNewElement; |
|
|
|
ptrNewElement = _getUserDefinedKeyBinding( name,strlen(name),type); |
|
|
|
// Copy the data. |
|
// If the set was not successful, the conversion was not successful |
|
if ( !_setCimKeyBindingStringToSCMOKeyBindingValue( |
|
cimKeyBinding, |
|
type, |
|
ptrNewElement->value)) |
{ | { |
*pvalue = NULL; |
return SCMO_TYPE_MISSMATCH; |
return SCMO_NULL_VALUE; |
|
} | } |
| |
// Set the absolut pointer to the key binding value |
|
*pvalue = _getCharString(theInstKeyBindNodeArray[node].value,inst.base); |
|
|
|
return SCMO_OK; | return SCMO_OK; |
|
|
} | } |
| |
SCMO_RC SCMOInstance::setKeyBinding( | SCMO_RC SCMOInstance::setKeyBinding( |
const char* name, | const char* name, |
CIMKeyBinding::Type type, |
CIMType type, |
const char* pvalue) |
const SCMBUnion* keyvalue) |
{ | { |
SCMO_RC rc; | SCMO_RC rc; |
Uint32 node; | Uint32 node; |
| |
if (NULL == name) |
if (0 == name) |
{ | { |
return SCMO_INVALID_PARAMETER; | return SCMO_INVALID_PARAMETER; |
} | } |
| |
rc = inst.hdr->theClass->_getKeyBindingNodeIndex(node,name); |
if (0 == keyvalue) |
if (rc != SCMO_OK) |
|
{ | { |
return rc; |
return SCMO_INVALID_PARAMETER; |
} | } |
| |
return setKeyBindingAt(node, type, pvalue); |
_copyOnWrite(); |
} |
|
| |
SCMO_RC SCMOInstance::setKeyBindingAt( |
// If keybindings exists and cleared using the clearKeyBindings() |
Uint32 node, |
// method, reset the value to the actual keybindings count exists |
CIMKeyBinding::Type type, |
// in the class. |
const char* pvalue) |
if (!inst.hdr->numberKeyBindings) |
{ | { |
SCMO_RC rc; |
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->cls.hdr->keyBindingSet.nodeArray.start; |
|
SCMBKeyBindingNode* theClassKeyBindNodeArray = |
|
(SCMBKeyBindingNode*)&(inst.hdr->theClass->cls.base)[idx]; |
|
| |
if (NULL == pvalue) |
rc = inst.hdr->theClass.ptr->_getKeyBindingNodeIndex(node,name); |
|
if (rc != SCMO_OK) |
{ | { |
return SCMO_INVALID_PARAMETER; |
// the key bindig does not belong to the associated class |
} |
// add/set it as user defined key binding. |
|
SCMBUserKeyBindingElement *theNode; |
|
|
|
theNode = _getUserDefinedKeyBinding( name,strlen(name),type); |
| |
if (theClassKeyBindNodeArray[node].type != type) |
// Is this a new node or an existing user key binding? |
|
if (theNode->value.isSet && (theNode->type != type)) |
{ | { |
return SCMO_TYPE_MISSMATCH; | return SCMO_TYPE_MISSMATCH; |
} |
|
|
|
SCMBInstanceKeyBinding* theInstKeyBindNodeArray = |
|
(SCMBInstanceKeyBinding*)&inst.base[inst.hdr->keyBindingArray.start]; |
|
| |
// copy the value including trailing '\0' |
} |
_setBinary( |
|
pvalue, |
|
strlen(pvalue)+1, |
|
theInstKeyBindNodeArray[node].value, |
|
&inst.mem); |
|
| |
|
theNode->value.isSet=true; |
| |
theInstKeyBindNodeArray[node].isSet=true; |
_setSCMBUnion( |
|
keyvalue, |
|
type, |
|
false, // a key binding can never be an array. |
|
0, |
|
theNode->value.data); |
| |
return SCMO_OK; | return SCMO_OK; |
} | } |
| |
|
return setKeyBindingAt(node, type, keyvalue); |
|
} |
| |
void SCMOInstance::setPropertyFilter(const char **propertyList) |
SCMO_RC SCMOInstance::setKeyBindingAt( |
|
Uint32 node, |
|
CIMType type, |
|
const SCMBUnion* keyvalue) |
{ | { |
SCMO_RC rc; |
if (0 == keyvalue) |
Uint32 node,i = 0; |
|
|
|
if (inst.hdr->propertyFilter.start == 0) |
|
{ | { |
// Allocate the SCMBPropertyFilter |
return SCMO_INVALID_PARAMETER; |
_getFreeSpace( |
} |
inst.hdr->propertyFilter, |
|
sizeof(Uint64)*(((inst.hdr->numberProperties-1)/64)+1), |
|
&inst.mem, |
|
true); |
|
| |
// Allocate the SCMBPropertyFilterIndexMap |
// count of class keys + user definded keys |
_getFreeSpace( |
if (node >= (inst.hdr->numberKeyBindings+ |
inst.hdr->propertyFilterIndexMap, |
inst.hdr->numberUserKeyBindings)) |
sizeof(Uint32)*inst.hdr->numberProperties, |
{ |
&inst.mem, |
return SCMO_INDEX_OUT_OF_BOUND; |
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 == NULL) |
|
{ |
|
// 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 |
_copyOnWrite(); |
inst.hdr->filterProperties = inst.hdr->numberProperties; |
|
| |
return; |
// 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; |
} | } |
| |
// Switch filtering on. |
|
inst.hdr->flags.isFiltered = true; |
|
| |
// intit the filter with the key properties |
// create a pointer to keybinding node array of the class. |
inst.hdr->filterProperties=_initPropFilterWithKeys(); |
Uint64 idx = inst.hdr->theClass.ptr->cls.hdr-> |
|
keyBindingSet.nodeArray.start; |
|
SCMBKeyBindingNode* theClassKeyBindNodeArray = |
|
(SCMBKeyBindingNode*)&((inst.hdr->theClass.ptr->cls.base)[idx]); |
| |
// add the properties to the filter. |
// is the node a user defined key binding ? |
while (propertyList[i] != NULL) |
if (node >= inst.hdr->numberKeyBindings) |
{ | { |
// the hash index of the property if the property name is found |
SCMBUserKeyBindingElement* theNode = _getUserDefinedKeyBindingAt(node); |
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++; |
|
} |
|
| |
|
// Does the new value for the user defined keybinding match? |
|
if (theNode->type != type) |
|
{ |
|
return SCMO_TYPE_MISSMATCH; |
} | } |
| |
|
_setSCMBUnion( |
|
keyvalue, |
|
type, |
|
false, // a key binding can never be an array. |
|
0, |
|
theNode->value.data); |
| |
Uint32 SCMOInstance::_initPropFilterWithKeys() |
return SCMO_OK; |
{ |
|
| |
// 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 |
SCMBKeyBindingValue* theInstKeyBindValueArray = |
Uint64* propertyFilterMask = |
(SCMBKeyBindingValue*)&(inst.base[inst.hdr->keyBindingArray.start]); |
(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 |
if (theClassKeyBindNodeArray[node].type == type) |
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 |
// Has to be set first, |
Uint32* propertyFilterIndexMap = |
// because reallocaton can take place in _setSCMBUnion() |
(Uint32*)&(inst.base[inst.hdr->propertyFilterIndexMap.start]); |
theInstKeyBindValueArray[node].isSet=true; |
| |
Uint32 noKeys = inst.hdr->theClass->cls.hdr->keyBindingSet.number; |
_setSCMBUnion( |
memcpy(propertyFilterIndexMap,keyIndex,sizeof(Uint32)*noKeys); |
keyvalue, |
|
type, |
|
false, // a key binding can never be an array. |
|
0, |
|
theInstKeyBindValueArray[node].data); |
| |
// return the number of properties already in the filter index map |
return SCMO_OK; |
return noKeys; |
|
| |
} | } |
| |
void SCMOInstance::_clearPropertyFilter() |
// The type does not match. |
{ |
return _setKeyBindingTypeTolerate( |
Uint64 *propertyFilter; |
theClassKeyBindNodeArray[node].type, |
|
type, |
// Calculate the real pointer to the Uint64 array |
keyvalue, |
propertyFilter = (Uint64*)&inst.base[inst.hdr->propertyFilter.start]; |
theInstKeyBindValueArray[node]); |
| |
// 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, |
* Set a SCMO user defined key binding using the class CIM type tolerating |
sizeof(Uint64)*(((inst.hdr->numberProperties-1)/64)+1)); |
* CIM key binding types converted to CIM types by fuction |
|
* _CIMTypeFromKeyBindingType(). |
|
* |
|
* @parm classType The type of the key binding in the class definition |
|
* @parm setType The type of the key binding to be set. |
|
* @param keyValue A pointer to the key binding to be set. |
|
* @param kbValue Out parameter, the SCMO keybinding to be set. |
|
* |
|
**/ |
|
SCMO_RC SCMOInstance::_setKeyBindingTypeTolerate( |
|
CIMType classType, |
|
CIMType setType, |
|
const SCMBUnion* keyValue, |
|
SCMBKeyBindingValue& kbValue) |
|
{ |
|
if (setType == CIMTYPE_UINT64 ) |
|
{ |
|
switch (classType) |
|
{ |
| |
|
case CIMTYPE_UINT8: |
|
{ |
|
kbValue.isSet=true; |
|
kbValue.data.simple.hasValue=true; |
|
kbValue.data.simple.val.u8=Uint8(keyValue->simple.val.u64); |
|
break; |
} | } |
void SCMOInstance::_setPropertyInPropertyFilter(Uint32 i) |
case CIMTYPE_UINT16: |
{ | { |
Uint64 *propertyFilter; |
kbValue.isSet=true; |
|
kbValue.data.simple.hasValue=true; |
// In which Uint64 of key mask is the bit for property i ? |
kbValue.data.simple.val.u16=Uint16(keyValue->simple.val.u64); |
// Divide with the number of bits in a Uint64. |
break; |
// 47 / 64 = 0 --> The key bit for property i is in in keyMask[0]. |
} |
Uint32 idx = i/64 ; |
case CIMTYPE_UINT32: |
|
{ |
// Create a filter to set the bit. |
kbValue.isSet=true; |
// Modulo division with 64. Shift left a bit by the remainder. |
kbValue.data.simple.hasValue=true; |
Uint64 filter = ( (Uint64)1 << (i%64)); |
kbValue.data.simple.val.u32=Uint32(keyValue->simple.val.u64); |
|
break; |
// Calculate the real pointer to the Uint64 array |
} |
propertyFilter = (Uint64*)&(inst.base[inst.hdr->propertyFilter.start]); |
case CIMTYPE_UINT64: |
|
{ |
|
kbValue.isSet=true; |
|
kbValue.data.simple.hasValue=true; |
|
kbValue.data.simple.val.u64=keyValue->simple.val.u64; |
|
break; |
|
} |
|
default: |
|
{ |
|
return SCMO_TYPE_MISSMATCH; |
|
} |
|
} |
|
return SCMO_OK; |
| |
propertyFilter[idx] = propertyFilter[idx] | filter ; |
|
} | } |
| |
Boolean SCMOInstance::_isPropertyInFilter(Uint32 i) const |
if (setType == CIMTYPE_SINT64) |
|
{ |
|
switch (classType) |
{ | { |
Uint64 *propertyFilter; |
|
| |
// In which Uint64 of key mask is the bit for property i ? |
case CIMTYPE_SINT8: |
// Divide with the number of bits in a Uint64. |
{ |
// e.g. number of Properties = 68 |
kbValue.isSet=true; |
// 47 / 64 = 0 --> The key bit for property i is in in keyMask[0]. |
kbValue.data.simple.hasValue=true; |
Uint32 idx = i/64 ; |
kbValue.data.simple.val.s8=Sint8(keyValue->simple.val.s64); |
|
break; |
|
} |
|
case CIMTYPE_SINT16: |
|
{ |
|
kbValue.isSet=true; |
|
kbValue.data.simple.hasValue=true; |
|
kbValue.data.simple.val.s16=Sint16(keyValue->simple.val.s64); |
|
break; |
|
} |
|
case CIMTYPE_SINT32: |
|
{ |
|
kbValue.isSet=true; |
|
kbValue.data.simple.hasValue=true; |
|
kbValue.data.simple.val.s32=Sint32(keyValue->simple.val.s64); |
|
break; |
|
} |
|
case CIMTYPE_SINT64: |
|
{ |
|
kbValue.isSet=true; |
|
kbValue.data.simple.hasValue=true; |
|
kbValue.data.simple.val.s64=keyValue->simple.val.s64; |
|
break; |
|
} |
|
default: |
|
{ |
|
return SCMO_TYPE_MISSMATCH; |
|
} |
|
} |
|
return SCMO_OK; |
|
} |
| |
// Create a filter to check if the bit is set: |
if (setType == CIMTYPE_REAL64) |
// Modulo division with 64. Shift left a bit by the remainder. |
{ |
Uint64 filter = ( (Uint64)1 << (i%64)); |
switch (classType) |
|
{ |
|
case CIMTYPE_REAL32: |
|
{ |
|
kbValue.isSet=true; |
|
kbValue.data.simple.hasValue=true; |
|
kbValue.data.simple.val.r32=Real32(keyValue->simple.val.r64); |
|
break; |
|
} |
|
case CIMTYPE_REAL64: |
|
{ |
|
kbValue.isSet=true; |
|
kbValue.data.simple.hasValue=true; |
|
kbValue.data.simple.val.r64=keyValue->simple.val.r64; |
|
break; |
|
} |
|
default: |
|
{ |
|
return SCMO_TYPE_MISSMATCH; |
|
} |
|
} |
|
return SCMO_OK; |
|
} |
|
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; |
|
} |
| |
// Calculate the real pointer to the Uint64 array |
switch (classType) |
propertyFilter = (Uint64*)&inst.base[inst.hdr->propertyFilter.start]; |
{ |
|
case CIMTYPE_DATETIME: |
|
case CIMTYPE_BOOLEAN: |
|
case CIMTYPE_UINT64: |
|
case CIMTYPE_SINT64: |
|
case CIMTYPE_REAL64: |
|
case CIMTYPE_STRING: |
|
case CIMTYPE_REFERENCE: |
|
{ |
|
kbValue.isSet=true; |
|
_setSCMBUnion(keyValue,classType,false, 0,kbValue.data); |
|
return SCMO_OK; |
|
} |
|
default: |
|
{ |
|
return SCMO_TYPE_MISSMATCH; |
|
} |
|
} |
|
} |
| |
// 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 |
|
|
| |
} | } |
| |
SCMODump::SCMODump(char* filename) |
SCMODump::SCMODump(const char* filename) |
{ | { |
openFile(filename); | openFile(filename); |
} | } |
| |
void SCMODump::openFile(char* filename) |
void SCMODump::openFile(const char* filename) |
{ | { |
const char* pegasusHomeDir = getenv("PEGASUS_HOME"); | const char* pegasusHomeDir = getenv("PEGASUS_HOME"); |
| |
if (pegasusHomeDir == NULL) |
if (pegasusHomeDir == 0) |
{ | { |
pegasusHomeDir = "."; | pegasusHomeDir = "."; |
} | } |
|
|
| |
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", |
fprintf(_out,"\n isClassOnly: %s", |
(insthdr->flags.isFiltered ? "True" : "False")); |
(insthdr->flags.isClassOnly ? "True" : "False")); |
|
fprintf(_out,"\n isCompromised: %s", |
|
(insthdr->flags.isCompromised ? "True" : "False")); |
|
fprintf(_out,"\n exportSetOnly: %s", |
|
(insthdr->flags.exportSetOnly ? "True" : "False")); |
|
fprintf(_out,"\n\ninstNameSpace: \'%s\'", |
|
NULLSTR(_getCharString(insthdr->instNameSpace,instbase))); |
|
fprintf(_out,"\n\ninstClassName: \'%s\'", |
|
NULLSTR(_getCharString(insthdr->instClassName,instbase))); |
fprintf(_out,"\n\nhostName: \'%s\'", | fprintf(_out,"\n\nhostName: \'%s\'", |
NULLSTR(_getCharString(insthdr->hostName,instbase))); |
NULLSTR(_getCharString(insthdr->hostName,instbase))); |
|
|
dumpSCMOInstanceKeyBindings(testInst); |
|
|
|
dumpSCMOInstancePropertyFilter(testInst); |
|
|
|
dumpInstanceProperties(testInst); |
|
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); |
dumpSCMOInstanceKeyBindings(testInst); |
| |
dumpPropertyFilterIndexMap(testInst); |
dumpInstanceProperties(testInst); |
|
fprintf(_out,"\n\n"); |
| |
} | } |
| |
void SCMODump::dumpInstanceProperties(SCMOInstance& testInst) const |
void SCMODump::dumpInstanceProperties( |
|
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; |
|
|
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 = |
if (theUserDefKBElement->value.isSet) |
(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; |
fprintf(_out,"\n\nName: '%s'\nType: '%s'", |
if (i < noMasks) |
NULLSTR(_getCharString(theUserDefKBElement->name,instbase)), |
{ |
cimTypeToString(theUserDefKBElement->type)); |
end = 64; |
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); |
SCMBInstanceKeyBinding* ptr = |
// Total size of the memory block( # bytes ) |
(SCMBInstanceKeyBinding*) |
fprintf(_out,"\n totalSize=%llu",header.totalSize); |
_resolveDataPtr(insthdr->keyBindingArray,instbase); |
// Free bytes in the block |
|
fprintf(_out,"\n freeBytes=%llu",header.freeBytes); |
fprintf(_out,"\n\nInstance Key Bindings :"); |
// Index to the start of the free space in this SCMB memory block. |
fprintf(_out,"\n======================="); |
fprintf(_out,"\n startOfFreeSpace=%llu",header.startOfFreeSpace); |
fprintf(_out,"\n\nNumber of Key Bindings : %u",insthdr->numberKeyBindings); |
// 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, k = insthdr->numberKeyBindings; i < k; i++) |
for (Uint32 i = 0; i < header.numberExtRef;) |
{ | { |
if (ptr[i].isSet) |
fprintf(_out,"%llu",extRefIndexArray[i]); |
|
i++; |
|
if (i != header.numberExtRef) |
{ | { |
fprintf(_out,"\n\nNo %u : '%s'",i, |
fprintf(_out,", "); |
NULLSTR(_getCharString(ptr[i].value,instbase))); |
} |
|
} |
|
fprintf(_out,"\n"); |
} | } |
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,"\nKey binding type: %s", |
fprintf(_out,"\nType: %s",cimTypeToString(nodeArray[i].type)); |
XmlWriter::keyBindingTypeToString(nodeArray[i].type).str); |
|
| |
} | } |
| |
|
|
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 |
{ | { |
fprintf(_out,"\n\nQualifier DMTF defined name: \'%s\'", | fprintf(_out,"\n\nQualifier DMTF defined name: \'%s\'", |
_qualifierNameStrLit[theQualifier.name].str); |
SCMOClass::qualifierNameStrLit(theQualifier.name).str); |
} | } |
| |
fprintf(_out,"\nPropagated : %s", | fprintf(_out,"\nPropagated : %s", |
|
|
| |
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 by the provider: %s", |
fprintf(_out,"\nValue was set: %s", |
(theValue.flags.isSet ? "True" : "False")); | (theValue.flags.isSet ? "True" : "False")); |
if (theValue.flags.isNull) | if (theValue.flags.isNull) |
{ | { |
|
|
} | } |
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; |
| |
|
SCMBUnion* p; |
|
p = (SCMBUnion*)&(base[u.arrayValue.start]); |
|
|
switch (type) | switch (type) |
{ | { |
case CIMTYPE_BOOLEAN: | case CIMTYPE_BOOLEAN: |
{ | { |
Boolean* p=(Boolean*)&(base[u._arrayValue.start]); |
|
for (Uint32 i = 0; i < size; i++) | for (Uint32 i = 0; i < size; i++) |
{ | { |
_toString(out,p[i]); |
out.append('\''); |
out.append(' '); |
_toString(out,p[i].simple.val.bin); |
|
out << STRLIT("\'(hasValue="); |
|
out << (p[i].simple.hasValue ? |
|
STRLIT("TRUE)"): |
|
STRLIT("FALSE)")); |
|
out.append(';'); |
} | } |
|
fprintf(_out,"\nThe values are: %s",out.getData()); |
break; | break; |
} | } |
| |
case CIMTYPE_UINT8: | case CIMTYPE_UINT8: |
{ | { |
Uint8* p=(Uint8*)&(base[u._arrayValue.start]); |
for (Uint32 i = 0; i < size; i++) |
_toString(out,p,size); |
{ |
|
out.append('\''); |
|
_toString(out,p[i].simple.val.u8); |
|
out << STRLIT("\'(hasValue="); |
|
out << (p[i].simple.hasValue ? |
|
STRLIT("TRUE)"): |
|
STRLIT("FALSE)")); |
|
out.append(';'); |
|
} |
|
fprintf(_out,"\nThe values are: %s",out.getData()); |
break; | break; |
} | } |
| |
case CIMTYPE_SINT8: | case CIMTYPE_SINT8: |
{ | { |
Sint8* p=(Sint8*)&(base[u._arrayValue.start]); |
for (Uint32 i = 0; i < size; i++) |
|
{ |
|
out.append('\''); |
|
_toString(out,p[i].simple.val.s8); |
|
out << STRLIT("\'(hasValue="); |
|
out << (p[i].simple.hasValue ? |
|
STRLIT("TRUE)"): |
|
STRLIT("FALSE)")); |
|
out.append(';'); |
|
} |
|
fprintf(_out,"\nThe values are: %s",out.getData()); |
break; | break; |
} | } |
| |
case CIMTYPE_UINT16: | case CIMTYPE_UINT16: |
{ | { |
Uint16* p=(Uint16*)&(base[u._arrayValue.start]); |
for (Uint32 i = 0; i < size; i++) |
_toString(out,p,size); |
{ |
|
out.append('\''); |
|
_toString(out,p[i].simple.val.u16); |
|
out << STRLIT("\'(hasValue="); |
|
out << (p[i].simple.hasValue ? |
|
STRLIT("TRUE)"): |
|
STRLIT("FALSE)")); |
|
out.append(';'); |
|
} |
|
fprintf(_out,"\nThe values are: %s",out.getData()); |
break; | break; |
} | } |
| |
case CIMTYPE_SINT16: | case CIMTYPE_SINT16: |
{ | { |
Sint16* p=(Sint16*)&(base[u._arrayValue.start]); |
for (Uint32 i = 0; i < size; i++) |
_toString(out,p,size); |
{ |
|
out.append('\''); |
|
_toString(out,p[i].simple.val.s16); |
|
out << STRLIT("\'(hasValue="); |
|
out << (p[i].simple.hasValue ? |
|
STRLIT("TRUE)"): |
|
STRLIT("FALSE)")); |
|
out.append(';'); |
|
} |
|
fprintf(_out,"\nThe values are: %s",out.getData()); |
break; | break; |
} | } |
| |
case CIMTYPE_UINT32: | case CIMTYPE_UINT32: |
{ | { |
Uint32* p=(Uint32*)&(base[u._arrayValue.start]); |
for (Uint32 i = 0; i < size; i++) |
_toString(out,p,size); |
{ |
|
out.append('\''); |
|
_toString(out,p[i].simple.val.u32); |
|
out << STRLIT("\'(hasValue="); |
|
out << (p[i].simple.hasValue ? |
|
STRLIT("TRUE)"): |
|
STRLIT("FALSE)")); |
|
out.append(';'); |
|
} |
|
fprintf(_out,"\nThe values are: %s",out.getData()); |
break; | break; |
} | } |
| |
case CIMTYPE_SINT32: | case CIMTYPE_SINT32: |
{ | { |
Sint32* p=(Sint32*)&(base[u._arrayValue.start]); |
for (Uint32 i = 0; i < size; i++) |
_toString(out,p,size); |
{ |
|
out.append('\''); |
|
_toString(out,p[i].simple.val.s32); |
|
out << STRLIT("\'(hasValue="); |
|
out << (p[i].simple.hasValue ? |
|
STRLIT("TRUE)"): |
|
STRLIT("FALSE)")); |
|
out.append(';'); |
|
} |
|
fprintf(_out,"\nThe values are: %s",out.getData()); |
break; | break; |
} | } |
| |
case CIMTYPE_UINT64: | case CIMTYPE_UINT64: |
{ | { |
Uint64* p=(Uint64*)&(base[u._arrayValue.start]); |
for (Uint32 i = 0; i < size; i++) |
_toString(out,p,size); |
{ |
|
out.append('\''); |
|
_toString(out,p[i].simple.val.u64); |
|
out << STRLIT("\'(hasValue="); |
|
out << (p[i].simple.hasValue ? |
|
STRLIT("TRUE)"): |
|
STRLIT("FALSE)")); |
|
out.append(';'); |
|
} |
|
fprintf(_out,"\nThe values are: %s",out.getData()); |
break; | break; |
} | } |
| |
case CIMTYPE_SINT64: | case CIMTYPE_SINT64: |
{ | { |
Sint64* p=(Sint64*)&(base[u._arrayValue.start]); |
for (Uint32 i = 0; i < size; i++) |
_toString(out,p,size); |
{ |
|
out.append('\''); |
|
_toString(out,p[i].simple.val.s64); |
|
out << STRLIT("\'(hasValue="); |
|
out << (p[i].simple.hasValue ? |
|
STRLIT("TRUE)"): |
|
STRLIT("FALSE)")); |
|
out.append(';'); |
|
} |
|
fprintf(_out,"\nThe values are: %s",out.getData()); |
break; | break; |
} | } |
| |
case CIMTYPE_REAL32: | case CIMTYPE_REAL32: |
{ | { |
Real32* p=(Real32*)&(base[u._arrayValue.start]); |
for (Uint32 i = 0; i < size; i++) |
_toString(out,p,size); |
{ |
|
out.append('\''); |
|
_toString(out,p[i].simple.val.r32); |
|
out << STRLIT("\'(hasValue="); |
|
out << (p[i].simple.hasValue ? |
|
STRLIT("TRUE)"): |
|
STRLIT("FALSE)")); |
|
out.append(';'); |
|
} |
|
fprintf(_out,"\nThe values are: %s",out.getData()); |
break; | break; |
} | } |
| |
case CIMTYPE_REAL64: | case CIMTYPE_REAL64: |
{ | { |
Real64* p=(Real64*)&(base[u._arrayValue.start]); |
for (Uint32 i = 0; i < size; i++) |
_toString(out,p,size); |
{ |
|
out.append('\''); |
|
_toString(out,p[i].simple.val.r64); |
|
out << STRLIT("\'(hasValue="); |
|
out << (p[i].simple.hasValue ? |
|
STRLIT("TRUE)"): |
|
STRLIT("FALSE)")); |
|
out.append(';'); |
|
} |
|
fprintf(_out,"\nThe values are: %s",out.getData()); |
break; | break; |
} | } |
| |
case CIMTYPE_CHAR16: | case CIMTYPE_CHAR16: |
{ | { |
Char16* p=(Char16*)&(base[u._arrayValue.start]); |
for (Uint32 i = 0; i < size; i++) |
_toString(out,p,size); |
{ |
|
out.append('\''); |
|
_toString(out,p[i].simple.val.c16); |
|
out << STRLIT("\'(hasValue="); |
|
out << (p[i].simple.hasValue ? |
|
STRLIT("TRUE)"): |
|
STRLIT("FALSE)")); |
|
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((const char*)_getCharString(p[i],base), |
out.append('\''); |
p[i].length-1); |
out.append( |
|
(const char*)_getCharString(p[i].stringValue,base), |
|
p[i].stringValue.size-1); |
|
out.append('\''); |
} | } |
else | else |
{ | { |
out.append(' '); |
out << STRLIT("NULL;"); |
} | } |
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_REFERENCE: | case CIMTYPE_REFERENCE: |
|
case CIMTYPE_OBJECT: |
|
case CIMTYPE_INSTANCE: |
{ | { |
break; |
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); |
} | } |
| |
case CIMTYPE_OBJECT: |
} else |
{ | { |
break; |
fprintf(_out,"\nThe values are: "); |
} |
|
| |
case CIMTYPE_INSTANCE: |
for (Uint32 i = 0; i < size; i++) |
{ | { |
|
fprintf( |
|
_out, |
|
"Pointer to external Reference[%d] : \'%p\';", |
|
i,p[i].extRefPtr); |
|
} |
|
} |
|
|
break; | break; |
|
|
} | } |
default: | default: |
{ | { |
PEGASUS_ASSERT(0); |
PEGASUS_ASSERT(false); |
|
break; |
} | } |
} | } |
| |
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._booleanValue); |
_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._uint8Value); |
_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._sint8Value); |
_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._uint16Value); |
_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._sint16Value); |
_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._uint32Value); |
_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._sint32Value); |
_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._uint64Value); |
_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._sint64Value); |
_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._real32Value); |
_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._real32Value); |
_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._char16Value); |
_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; |
} | } |
| |
case CIMTYPE_DATETIME: | case CIMTYPE_DATETIME: |
{ | { |
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_REFERENCE: | case CIMTYPE_REFERENCE: |
{ |
|
break; |
|
} |
|
|
|
case CIMTYPE_OBJECT: | case CIMTYPE_OBJECT: |
|
case CIMTYPE_INSTANCE: |
{ | { |
break; |
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); |
} | } |
| |
case CIMTYPE_INSTANCE: |
|
{ |
|
break; | break; |
} | } |
default: | default: |
{ | { |
PEGASUS_ASSERT(0); |
PEGASUS_ASSERT(false); |
|
break; |
} | } |
} | } |
| |
return out.getData(); |
return; |
} | } |
|
#endif // PEGASUS_DEBUG (class SCMODump only in debug builds available) |
| |
| |
/***************************************************************************** | /***************************************************************************** |
* The constant functions | * The constant functions |
*****************************************************************************/ | *****************************************************************************/ |
| |
static const void* _resolveDataPtr( |
#ifdef PEGASUS_HAS_ICU |
const SCMBDataPtr& ptr, |
Uint32 _utf8ICUncasecmp( |
char* base) |
const char* a, |
{ |
const char* b, |
return ((ptr.start==(Uint64)0 ? NULL : (void*)&(base[ptr.start]))); |
Uint32 len) |
} |
|
|
|
PEGASUS_COMMON_LINKAGE const char* _getCharString( |
|
const SCMBDataPtr& ptr, |
|
char* base) |
|
{ | { |
return ((ptr.start==(Uint64)0 ? NULL : &(base[ptr.start]))); |
UErrorCode errorCode=U_ZERO_ERROR; |
} |
|
| |
|
Uint32 rc, a16len,b16len,utf16BufLen; |
|
utf16BufLen = (len*sizeof(UChar))+2; |
| |
static Uint32 _generateSCMOStringTag( |
UChar* a_UTF16 = (UChar*)malloc(utf16BufLen); |
const SCMBDataPtr& ptr, |
UChar* b_UTF16 = (UChar*)malloc(utf16BufLen); |
char* base) |
|
{ |
|
// The lenght of a SCMBDataPtr to a UTF8 string includs the trailing '\0'. |
|
return _generateStringTag(_getCharString(ptr,base),ptr.length-1); |
|
} |
|
|
|
static Uint32 _generateStringTag(const char* str, Uint32 len) |
|
{ |
|
if (len == 0) |
|
{ |
|
return 0; |
|
} |
|
return |
|
(Uint32(CharSet::toUpperHash(str[0]) << 1) | |
|
Uint32(CharSet::toUpperHash(str[len-1]))); |
|
} |
|
| |
static CIMKeyBinding::Type _cimTypeToKeyBindType(CIMType cimType) |
UConverter *conv = ucnv_open(0, &errorCode); |
{ |
if(U_FAILURE(errorCode)) |
switch (cimType) |
{ |
{ |
free(a_UTF16); |
case CIMTYPE_BOOLEAN: |
free(b_UTF16); |
return(CIMKeyBinding::BOOLEAN); |
String message("SCMO::_utf8ICUncasecmp() ICUError: "); |
break; |
message.append(u_errorName(errorCode)); |
case CIMTYPE_CHAR16: |
message.append(" Can not open ICU default converter!"); |
case CIMTYPE_STRING: |
throw CIMException(CIM_ERR_FAILED,message ); |
case CIMTYPE_DATETIME: |
|
return(CIMKeyBinding::STRING); |
|
break; |
|
case CIMTYPE_REFERENCE: |
|
return(CIMKeyBinding::REFERENCE); |
|
break; |
|
case CIMTYPE_OBJECT: |
|
case CIMTYPE_INSTANCE: |
|
// From PEP 194: EmbeddedObjects cannot be keys. |
|
throw TypeMismatchException(); |
|
break; |
|
default: |
|
return(CIMKeyBinding::NUMERIC); |
|
break; |
|
} |
|
} | } |
| |
static Boolean _equalUTF8Strings( |
a16len = ucnv_toUChars(conv,a_UTF16,utf16BufLen,a,len,&errorCode); |
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(U_FAILURE(errorCode)) |
if (ptr_a.length-1 != len) |
|
{ | { |
return false; |
free(a_UTF16); |
} |
free(b_UTF16); |
|
ucnv_close(conv); |
const char* a = (const char*)_getCharString(ptr_a,base); |
String message("SCMO::_utf8ICUncasecmp() ICUError: "); |
|
message.append(u_errorName(errorCode)); |
// ToDo: Here an UTF8 complinet comparison should take place |
message.append(" Can not convert string a:'"); |
return ( strncmp(a,name,len )== 0 ); |
message.append(String(a,len)); |
|
message.append('\''); |
|
throw CIMException(CIM_ERR_FAILED,message ); |
} | } |
| |
static Boolean _equalNoCaseUTF8Strings( |
b16len = ucnv_toUChars(conv,b_UTF16,utf16BufLen,b,len,&errorCode); |
const SCMBDataPtr& ptr_a, |
|
char* base, |
|
const char* name, |
|
Uint32 len) |
|
|
|
{ |
|
| |
//both are empty strings, so they are equal. |
if(U_FAILURE(errorCode)) |
if (ptr_a.length == 0 && len == 0) |
|
{ | { |
return true; |
free(a_UTF16); |
|
free(b_UTF16); |
|
ucnv_close(conv); |
|
String message("SCMO::_utf8ICUncasecmp() ICUError: "); |
|
message.append(u_errorName(errorCode)); |
|
message.append(" Can not convert string b:'"); |
|
message.append(String(b,len)); |
|
message.append('\''); |
|
throw CIMException(CIM_ERR_FAILED,message ); |
} | } |
| |
// size without trailing '\0' !! |
rc = u_strCaseCompare( |
if (ptr_a.length-1 != len) |
a_UTF16,a16len, |
{ |
b_UTF16,b16len, |
return false; |
U_FOLD_CASE_DEFAULT, |
|
&errorCode); |
|
|
|
if(U_FAILURE(errorCode)) |
|
{ |
|
free(a_UTF16); |
|
free(b_UTF16); |
|
ucnv_close(conv); |
|
String message("SCMO::_utf8ICUncasecmp() ICUError: "); |
|
message.append(u_errorName(errorCode)); |
|
message.append(" Can not compare string a:'"); |
|
message.append(String(a,len)); |
|
message.append("' with b: '"); |
|
message.append(String(b,len)); |
|
message.append('\''); |
|
throw CIMException(CIM_ERR_FAILED,message ); |
} | } |
| |
const char* a = (const char*)_getCharString(ptr_a,base); |
free(a_UTF16); |
|
free(b_UTF16); |
// ToDo: Here an UTF8 complinet comparison should take place |
ucnv_close(conv); |
return ( strncasecmp(a,name,len )== 0 ); |
|
| |
|
return(rc); |
} | } |
|
#endif |
| |
/** | /** |
* This function calcutates a free memory slot in the single chunk memory block. | * This function calcutates a free memory slot in the single chunk memory block. |
|
|
* 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) == NULL) |
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= (*pmem)->freeBytes + oldSize; |
(*pmem)->freeBytes+=oldSize; |
(*pmem)->totalSize= (*pmem)->totalSize + oldSize; |
(*pmem)->totalSize+=oldSize; |
} | } |
| |
(*pmem)->freeBytes = (*pmem)->freeBytes - size; |
(*pmem)->freeBytes -= reqAlignSize; |
(*pmem)->startOfFreeSpace = (*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) |
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; |
} | } |
| |
|
} |
|
} |
| |
PEGASUS_NAMESPACE_END | PEGASUS_NAMESPACE_END |