version 1.2.2.24, 2009/09/09 13:16:14
|
version 1.2.2.38, 2009/10/13 09:36:35
|
|
|
#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/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 <strings.h> | #include <strings.h> |
| |
#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) \ | #define NEWCIMSTR(ptr,base) \ |
((ptr).length == 0 ? \ | ((ptr).length == 0 ? \ |
|
|
| |
PEGASUS_NAMESPACE_BEGIN | PEGASUS_NAMESPACE_BEGIN |
| |
|
#define PEGASUS_ARRAY_T SCMOInstance |
|
# include "ArrayImpl.h" |
|
#undef PEGASUS_ARRAY_T |
|
|
|
|
const StrLit SCMOClass::_qualifierNameStrLit[72] = | const StrLit SCMOClass::_qualifierNameStrLit[72] = |
{ | { |
STRLIT(""), | STRLIT(""), |
|
|
(sizeof(_qualifierNameStrLit)/sizeof(_qualifierNameStrLit[0])) | (sizeof(_qualifierNameStrLit)/sizeof(_qualifierNameStrLit[0])) |
| |
/***************************************************************************** | /***************************************************************************** |
|
* Internal inline functions. |
|
*****************************************************************************/ |
|
|
|
inline SCMOClass* _getSCMOClass( |
|
const CIMObjectPath& theCIMObj, |
|
const char* altNS, |
|
Uint64 altNSlength) |
|
{ |
|
SCMOClass* theClass=0; |
|
|
|
if (theCIMObj.getClassName().isNull()) |
|
{ |
|
return 0; |
|
} |
|
|
|
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 |
|
{ |
|
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; |
|
} |
|
|
|
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.length != 0) |
|
{ |
|
Uint32 oldArraySize=(theArray.length/sizeof(SCMBUnion)); |
|
|
|
ptr = (SCMBUnion*)&(((char*)*pmem)[theArray.start]); |
|
for (Uint32 i = 0 ; i < oldArraySize ; i++) |
|
{ |
|
delete ptr[i].extRefPtr; |
|
} |
|
} |
|
} |
|
|
|
inline void _copyArrayExtReference( |
|
SCMBDataPtr& theArray, |
|
SCMBMgmt_Header** pmem ) |
|
{ |
|
SCMBUnion* ptr; |
|
// if the array was already set, |
|
// the previous references has to be deleted |
|
if(theArray.length != 0) |
|
{ |
|
Uint32 oldArraySize=(theArray.length/sizeof(SCMBUnion)); |
|
|
|
ptr = (SCMBUnion*)&(((char*)*pmem)[theArray.start]); |
|
for (Uint32 i = 0 ; i < oldArraySize ; i++) |
|
{ |
|
if (ptr[i].extRefPtr != 0) |
|
{ |
|
ptr[i].extRefPtr = new SCMOInstance(*ptr[i].extRefPtr); |
|
} |
|
} |
|
} |
|
} |
|
|
|
/***************************************************************************** |
* The SCMOClass methods | * The SCMOClass methods |
*****************************************************************************/ | *****************************************************************************/ |
SCMOClass::SCMOClass() | SCMOClass::SCMOClass() |
{ | { |
cls.mem = NULL; |
cls.mem = 0; |
|
} |
|
|
|
void SCMOClass::_destroyExternalReferences() |
|
{ |
|
// TODO: Has to be optimized not to loop through all props. |
|
// Address the property array |
|
SCMBClassPropertyNode* nodeArray = |
|
(SCMBClassPropertyNode*) |
|
&(cls.base[cls.hdr->propertySet.nodeArray.start]); |
|
|
|
SCMBValue* theValue; |
|
|
|
for (Uint32 i = 0; i < cls.hdr->propertySet.number; i++) |
|
{ |
|
theValue = &(nodeArray[i].theProperty.defaultValue); |
|
|
|
// if not an NULL value ! |
|
if(!theValue->flags.isNull) |
|
{ |
|
if (theValue->valueType == CIMTYPE_REFERENCE || |
|
theValue->valueType == CIMTYPE_OBJECT || |
|
theValue->valueType == CIMTYPE_INSTANCE ) |
|
{ |
|
if (theValue->flags.isArray) |
|
{ |
|
_deleteArrayExtReference( |
|
theValue->value.arrayValue, |
|
&cls.mem); |
|
} |
|
else |
|
{ |
|
delete theValue->value.extRefPtr; |
|
} // end is Array |
|
} // end is ext. reference. |
|
}// end is not null |
|
}// loop throug all properties |
} | } |
| |
SCMOClass::SCMOClass(CIMClass& theCIMClass, const char* nameSpaceName) |
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 ) |
|
{ |
|
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, |
|
strlen(className)+1, |
|
cls.hdr->className, |
|
&cls.mem ); |
|
|
|
_setBinary(nameSpaceName, |
|
strlen(nameSpaceName)+1, |
|
cls.hdr->nameSpace, |
|
&cls.mem ); |
|
|
|
} |
|
|
|
SCMOClass::SCMOClass( |
|
const CIMClass& theCIMClass, |
|
const char* nameSpaceName) |
|
{ |
|
|
|
_initSCMOClass(); |
|
|
try | try |
{ | { |
_setString(theCIMClass.getSuperClassName().getString(), | _setString(theCIMClass.getSuperClassName().getString(), |
|
|
&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::getCIMClass(CIMClass& cimClass) const |
|
{ |
|
CIMClass newCimClass( |
|
CIMNameCast(NEWCIMSTR(cls.hdr->className,cls.base)), |
|
CIMNameCast(NEWCIMSTR(cls.hdr->superClassName,cls.base))); |
|
|
|
// set the name space |
|
newCimClass._rep->_reference._rep->_nameSpace= |
|
CIMNamespaceNameCast(NEWCIMSTR(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(NEWCIMSTR(clsProp.theProperty.name,cls.base)), |
|
theCimValue, |
|
theCimValue.getArraySize(), |
|
CIMNameCast(NEWCIMSTR(clsProp.theProperty.refClassName,cls.base)), |
|
CIMNameCast(NEWCIMSTR( |
|
clsProp.theProperty.originClassName,cls.base)), |
|
clsProp.theProperty.flags.propagated); |
|
} |
|
else |
|
{ |
|
retCimProperty = CIMProperty( |
|
CIMNameCast(NEWCIMSTR(clsProp.theProperty.name,cls.base)), |
|
theCimValue, |
|
theCimValue.getArraySize(), |
|
CIMNameCast(NEWCIMSTR(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 = NEWCIMSTR(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 |
|
|
| |
} | } |
| |
|
|
SCMO_RC SCMOClass::_getProperyNodeIndex(Uint32& node, const char* name) const | SCMO_RC SCMOClass::_getProperyNodeIndex(Uint32& node, const char* name) const |
{ | { |
| |
|
|
| |
} | } |
| |
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; |
|
|
// (68 - 1) / 64 = 1 --> The mask consists of two Uint64 values. | // (68 - 1) / 64 = 1 --> The mask consists of two Uint64 values. |
_getFreeSpace(cls.hdr->keyPropertyMask, | _getFreeSpace(cls.hdr->keyPropertyMask, |
sizeof(Uint64)*(((noProps-1)/64)+1), | sizeof(Uint64)*(((noProps-1)/64)+1), |
&cls.mem); |
&cls.mem,true); |
| |
// allocate property array and save the start index of the array. | // allocate property array and save the start index of the array. |
start = _getFreeSpace(cls.hdr->propertySet.nodeArray, | start = _getFreeSpace(cls.hdr->propertySet.nodeArray, |
sizeof(SCMBClassPropertyNode)*noProps, | sizeof(SCMBClassPropertyNode)*noProps, |
&cls.mem); |
&cls.mem,true); |
| |
// clear the hash table | // clear the hash table |
memset(cls.hdr->propertySet.hashTable, | memset(cls.hdr->propertySet.hashTable, |
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 |
|
|
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); |
| |
|
|
| |
} | } |
| |
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; |
|
|
Uint64 filter = ( (Uint64)1 << (i%64)); | Uint64 filter = ( (Uint64)1 << (i%64)); |
| |
// 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 ; |
} | } |
|
|
Uint64 filter = ( (Uint64)1 << (i%64)); | Uint64 filter = ( (Uint64)1 << (i%64)); |
| |
// 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 ; |
| |
|
|
| |
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); |
| |
} | } |
|
|
cls.hdr->qualifierArray.start=0; | cls.hdr->qualifierArray.start=0; |
cls.hdr->qualifierArray.length=0; | cls.hdr->qualifierArray.length=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) |
|
|
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.length, |
rep->u); | rep->u); |
} | } |
else | else |
|
|
valueStart, | valueStart, |
&cls.mem, | &cls.mem, |
rep->type, | rep->type, |
|
cls.hdr->nameSpace.start, |
|
cls.hdr->nameSpace.length, |
rep->u); | rep->u); |
} | } |
} | } |
|
|
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( |
|
|
const char** propertyList) | const char** propertyList) |
{ | { |
| |
_initSCMOInstance( |
_initSCMOInstance(new SCMOClass(baseClass)); |
new SCMOClass(baseClass), |
|
includeQualifiers, |
inst.hdr->flags.includeQualifiers=includeQualifiers; |
includeClassOrigin); |
inst.hdr->flags.includeClassOrigin=includeClassOrigin; |
| |
setPropertyFilter(propertyList); | setPropertyFilter(propertyList); |
| |
|
|
| |
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; |
_setCIMInstance(cimInstance); |
Boolean hasQualifiers = (instRep->_qualifiers.getCount()>0); |
|
Boolean hasClassOrigin = false; |
|
| |
_initSCMOInstance(new SCMOClass(baseClass),hasQualifiers,hasClassOrigin); |
} |
| |
_setCIMObjectPath(instRep->_reference); |
|
| |
// Copy all properties |
void SCMOInstance::_copyExternalReferences() |
for (Uint32 i = 0, k = instRep->_properties.size(); i < k; i++) |
|
{ | { |
propRep = instRep->_properties[i]._rep; |
// TODO: Has to be optimized not to loop through all props. |
// if not already detected that qualifiers are specified and |
// create a pointer to keybinding node array of the class. |
// there are qualifers at that property. |
Uint64 idx = inst.hdr->theClass->cls.hdr->keyBindingSet.nodeArray.start; |
if (!hasQualifiers && propRep->getQualifierCount() > 0) |
SCMBKeyBindingNode* theClassKeyBindNodeArray = |
|
(SCMBKeyBindingNode*)&((inst.hdr->theClass->cls.base)[idx]); |
|
|
|
// create a pointer to instanc key binding array. |
|
SCMBKeyBindingValue* theInstanceKeyBindingNodeArray = |
|
(SCMBKeyBindingValue*)&(inst.base[inst.hdr->keyBindingArray.start]); |
|
|
|
for (Uint32 i = 0; i < inst.hdr->numberKeyBindings; i++) |
{ | { |
includeQualifiers(); |
if (theInstanceKeyBindingNodeArray[i].isSet) |
} |
|
// if not already detected that class origins are specified and |
|
// there is a class origin specified at that property. |
|
if (!hasClassOrigin && !propRep->_classOrigin.isNull()) |
|
{ | { |
includeClassOrigins(); |
// only references can be a key binding. |
|
if (theClassKeyBindNodeArray[i].type == CIMTYPE_REFERENCE) |
|
{ |
|
// Use the copy constructro to ref. count the reference. |
|
// These objects are handeld by the SCMOInstance it sef. |
|
// No one can modify these instances. |
|
theInstanceKeyBindingNodeArray[i].data.extRefPtr = |
|
new SCMOInstance( |
|
*theInstanceKeyBindingNodeArray[i].data.extRefPtr); |
} | } |
|
} |
|
}// for all key bindings defined in the class |
| |
// get the property node index for the property |
// Are there user defined key bindings ? |
rc = inst.hdr->theClass->_getProperyNodeIndex( |
if (0 != inst.hdr->numberUserKeyBindindigs) |
propNode, |
{ |
(const char*)propRep->_name.getString().getCString()); |
SCMBUserKeyBindingElement* theUserDefKBElement = |
|
(SCMBUserKeyBindingElement*) |
|
&(inst.base[inst.hdr->userKeyBindingElement.start]); |
| |
if (rc != SCMO_OK) |
for(Uint32 i = 0; i < inst.hdr->numberUserKeyBindindigs; i++) |
{ | { |
throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NO_SUCH_PROPERTY, |
if (theUserDefKBElement->value.isSet) |
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); |
// only references can be a key binding. |
} |
if (theUserDefKBElement->type == CIMTYPE_REFERENCE) |
else |
|
{ | { |
throw PEGASUS_CIM_EXCEPTION(CIM_ERR_TYPE_MISMATCH, |
// Use the copy constructro to ref. count the reference. |
propRep->_name.getString()); |
// These objects are handeld by the SCMOInstance it sef. |
|
// No one can modify these instances. |
|
theUserDefKBElement->value.data.extRefPtr = |
|
new SCMOInstance( |
|
*theUserDefKBElement->value.data.extRefPtr); |
} | } |
} | } |
| |
|
theUserDefKBElement = |
|
(SCMBUserKeyBindingElement*) |
|
&(inst.base[theUserDefKBElement->nextElement.start]); |
|
} // for all user def. key bindings. |
} | } |
| |
SCMO_RC SCMOInstance::getCIMInstance(CIMInstance& cimInstance) const |
SCMBValue* theInstPropArray = |
{ |
(SCMBValue*)&(inst.base[inst.hdr->propertyArray.start]); |
|
|
SCMO_RC rc = SCMO_OK; |
|
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); |
for (Uint32 i = 0; i < inst.hdr->numberProperties; i++) |
|
|
if (inst.hdr->flags.includeQualifiers) |
|
{ | { |
SCMBQualifier* qualiArray = |
// was the property set by the provider ? |
(SCMBQualifier*)&(clsbase[clshdr->qualifierArray.start]); |
if(theInstPropArray[i].flags.isSet) |
|
|
CIMName qualiName; |
|
CIMValue theValue; |
|
|
|
Uint32 i, k = clshdr->numberOfQualifiers; |
|
|
|
for ( i = 0 ; i < k ; i++) |
|
{ | { |
_getCIMValueFromSCMBValue(theValue,qualiArray[i].value,clsbase); |
// is the property type reference,instance or object? |
|
if (theInstPropArray[i].valueType == CIMTYPE_REFERENCE || |
if (qualiArray[i].name == QUALNAME_USERDEFINED) |
theInstPropArray[i].valueType == CIMTYPE_OBJECT || |
|
theInstPropArray[i].valueType == CIMTYPE_INSTANCE ) |
|
{ |
|
if (theInstPropArray[i].flags.isArray) |
{ | { |
qualiName = NEWCIMSTR(qualiArray[i].userDefName,clsbase); |
_copyArrayExtReference( |
|
theInstPropArray[i].value.arrayValue, |
|
&inst.mem); |
} | } |
else | else |
{ | { |
qualiName = String( |
theInstPropArray[i].value.extRefPtr = |
SCMOClass::qualifierNameStrLit(qualiArray[i].name).str, |
new SCMOInstance(*theInstPropArray[i].value.extRefPtr); |
SCMOClass::qualifierNameStrLit(qualiArray[i].name).size); |
} // end is arry |
} |
} // end is reference |
|
}// end is set |
cimInstance._rep->_qualifiers.addUnchecked( |
} // for all properties. |
CIMQualifier( |
|
qualiName, |
|
theValue, |
|
qualiArray[i].flavor, |
|
qualiArray[i].propagated)); |
|
} |
|
} | } |
| |
if (inst.hdr->flags.isFiltered) |
void SCMOInstance::_destroyExternalReferences() |
{ | { |
// Get absolut pointer to property filter index map of the instance |
// TODO: Has to be optimized not to loop through all props. |
Uint32* propertyFilterIndexMap = |
// create a pointer to keybinding node array of the class. |
|
Uint64 idx = inst.hdr->theClass->cls.hdr->keyBindingSet.nodeArray.start; |
|
SCMBKeyBindingNode* theClassKeyBindNodeArray = |
|
(SCMBKeyBindingNode*)&((inst.hdr->theClass->cls.base)[idx]); |
|
|
|
// create a pointer to instanc key binding array. |
|
SCMBKeyBindingValue* theInstanceKeyBindingNodeArray = |
|
(SCMBKeyBindingValue*)&(inst.base[inst.hdr->keyBindingArray.start]); |
|
|
|
for (Uint32 i = 0; i < inst.hdr->numberKeyBindings; i++) |
|
{ |
|
if (theInstanceKeyBindingNodeArray[i].isSet) |
|
{ |
|
// only references can be a key binding |
|
if (theClassKeyBindNodeArray[i].type == CIMTYPE_REFERENCE) |
|
{ |
|
delete theInstanceKeyBindingNodeArray[i].data.extRefPtr; |
|
} |
|
} |
|
}// for all key bindings |
|
|
|
// Are there user defined key bindings ? |
|
if (0 != inst.hdr->numberUserKeyBindindigs) |
|
{ |
|
SCMBUserKeyBindingElement* theUserDefKBElement = |
|
(SCMBUserKeyBindingElement*) |
|
&(inst.base[inst.hdr->userKeyBindingElement.start]); |
|
|
|
for(Uint32 i = 0; i < inst.hdr->numberUserKeyBindindigs; i++) |
|
{ |
|
if (theUserDefKBElement->value.isSet) |
|
{ |
|
// only references can be a key binding. |
|
if (theUserDefKBElement->type == CIMTYPE_REFERENCE) |
|
{ |
|
delete theUserDefKBElement->value.data.extRefPtr; |
|
} |
|
} |
|
|
|
theUserDefKBElement = |
|
(SCMBUserKeyBindingElement*) |
|
&(inst.base[theUserDefKBElement->nextElement.start]); |
|
} // for all user def. key bindings. |
|
} |
|
|
|
SCMBValue* theInstPropArray = |
|
(SCMBValue*)&(inst.base[inst.hdr->propertyArray.start]); |
|
|
|
for (Uint32 i = 0; i < inst.hdr->numberProperties; i++) |
|
{ |
|
// was the property set by the provider ? |
|
if(theInstPropArray[i].flags.isSet) |
|
{ |
|
// is the property type reference,instance or object? |
|
if (theInstPropArray[i].valueType == CIMTYPE_REFERENCE || |
|
theInstPropArray[i].valueType == CIMTYPE_OBJECT || |
|
theInstPropArray[i].valueType == CIMTYPE_INSTANCE ) |
|
{ |
|
if (theInstPropArray[i].flags.isArray) |
|
{ |
|
_deleteArrayExtReference( |
|
theInstPropArray[i].value.arrayValue, |
|
&inst.mem); |
|
} |
|
else |
|
{ |
|
delete theInstPropArray[i].value.extRefPtr; |
|
} // end is arry |
|
} // end is reference |
|
}// end is set |
|
} // for all properties. |
|
} |
|
|
|
SCMO_RC SCMOInstance::getCIMInstance(CIMInstance& cimInstance) const |
|
{ |
|
|
|
SCMO_RC rc = SCMO_OK; |
|
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 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.isFiltered) |
|
{ |
|
// Get absolut pointer to property filter index map of the instance |
|
Uint32* propertyFilterIndexMap = |
(Uint32*)&(inst.base[inst.hdr->propertyFilterIndexMap.start]); | (Uint32*)&(inst.base[inst.hdr->propertyFilterIndexMap.start]); |
| |
for(Uint32 i = 0, k = inst.hdr->filterProperties; i<k; i++) | for(Uint32 i = 0, k = inst.hdr->filterProperties; i<k; i++) |
|
|
CIMProperty theProperty=_getCIMPropertyAtNodeIndex( | CIMProperty theProperty=_getCIMPropertyAtNodeIndex( |
propertyFilterIndexMap[i]); | propertyFilterIndexMap[i]); |
| |
cimInstance._rep->_properties.append(theProperty); |
newInstance._rep->_properties.append(theProperty); |
} | } |
| |
} | } |
|
|
{ | { |
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); |
|
} |
} | } |
| |
} | } |
| |
|
cimInstance = newInstance; |
|
|
return rc; | return rc; |
} | } |
| |
void SCMOInstance::getCIMObjectPath(CIMObjectPath& cimObj) const | void SCMOInstance::getCIMObjectPath(CIMObjectPath& cimObj) const |
{ | { |
|
|
|
CIMObjectPath newObjectPath; |
|
|
// For better usability define pointers to SCMO Class data structures. | // For better usability define pointers to SCMO Class data structures. |
SCMBClass_Main* clshdr = inst.hdr->theClass->cls.hdr; | SCMBClass_Main* clshdr = inst.hdr->theClass->cls.hdr; |
char* clsbase = inst.hdr->theClass->cls.base; | char* clsbase = inst.hdr->theClass->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 |
SCMBKeyBindingValue* scmoInstArray = | SCMBKeyBindingValue* scmoInstArray = |
(SCMBKeyBindingValue*)&inst.base[inst.hdr->keyBindingArray.start]; |
(SCMBKeyBindingValue*)&(inst.base[inst.hdr->keyBindingArray.start]); |
| |
Uint32 numberKeyBindings = inst.hdr->numberKeyBindings; | Uint32 numberKeyBindings = inst.hdr->numberKeyBindings; |
| |
|
|
0, | 0, |
scmoInstArray[i].data, | scmoInstArray[i].data, |
inst.base); | inst.base); |
cimObj._rep->_keyBindings.append( |
newObjectPath._rep->_keyBindings.append( |
CIMKeyBinding( | CIMKeyBinding( |
CIMNameCast(NEWCIMSTR(scmoClassArray[i].name,clsbase)), | CIMNameCast(NEWCIMSTR(scmoClassArray[i].name,clsbase)), |
theKeyBindingValue | theKeyBindingValue |
|
|
} | } |
} | } |
| |
cimObj._rep->_host = NEWCIMSTR(inst.hdr->hostName,inst.base); |
// Are there user defined key bindings ? |
cimObj._rep->_nameSpace = |
if (0 != inst.hdr->numberUserKeyBindindigs) |
CIMNamespaceNameCast(NEWCIMSTR(clshdr->nameSpace,clsbase)); |
{ |
cimObj._rep->_className=CIMNameCast(NEWCIMSTR(clshdr->className,clsbase)); |
SCMBUserKeyBindingElement* theUserDefKBElement = |
|
(SCMBUserKeyBindingElement*) |
|
&(inst.base[inst.hdr->userKeyBindingElement.start]); |
|
|
|
for(Uint32 i = 0; i < inst.hdr->numberUserKeyBindindigs; 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); |
|
|
|
newObjectPath._rep->_keyBindings.append( |
|
CIMKeyBinding( |
|
CIMNameCast( |
|
NEWCIMSTR(theUserDefKBElement->name,inst.base)), |
|
theKeyBindingValue)); |
|
} |
|
theUserDefKBElement = |
|
(SCMBUserKeyBindingElement*) |
|
&(inst.base[theUserDefKBElement->nextElement.start]); |
|
} // for all user def. key bindings. |
|
} |
|
|
|
newObjectPath._rep->_host = NEWCIMSTR(inst.hdr->hostName,inst.base); |
|
// Use name space and class name of the instance |
|
newObjectPath._rep->_nameSpace = |
|
CIMNamespaceNameCast(NEWCIMSTR(inst.hdr->instNameSpace,inst.base)); |
|
newObjectPath._rep->_className= |
|
CIMNameCast(NEWCIMSTR(inst.hdr->instClassName,inst.base)); |
|
|
|
cimObj = newObjectPath; |
} | } |
| |
CIMProperty SCMOInstance::_getCIMPropertyAtNodeIndex(Uint32 nodeIdx) const | CIMProperty SCMOInstance::_getCIMPropertyAtNodeIndex(Uint32 nodeIdx) const |
|
|
(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( |
|
SCMOClass::qualifierNameStrLit(qualiArray[i].name).str, |
|
SCMOClass::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::_getCIMValueFromSCMBUnion( | void SCMOInstance::_getCIMValueFromSCMBUnion( |
|
|
const Boolean isArray, | const Boolean isArray, |
const Uint32 arraySize, | const Uint32 arraySize, |
const SCMBUnion& scmbUn, | const SCMBUnion& scmbUn, |
const char * base) const |
const char * base) |
{ | { |
|
|
|
const SCMBUnion* pscmbArrayUn = 0; |
|
|
if (isNull) | if (isNull) |
{ | { |
cimV.setNullValue(type,isArray,arraySize); | cimV.setNullValue(type,isArray,arraySize); |
return; | return; |
} | } |
| |
|
if (isArray) |
|
{ |
|
pscmbArrayUn =(SCMBUnion*)&(base[scmbUn.arrayValue.start]); |
|
} |
|
|
switch (type) | switch (type) |
{ | { |
| |
|
|
{ | { |
if (isArray) | if (isArray) |
{ | { |
const Uint8* u=(Uint8*)&(base[scmbUn._arrayValue.start]); |
|
Array<Uint8> x; | Array<Uint8> x; |
x.append(u,arraySize); |
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(scmbUn._uint8Value); |
cimV.set(scmbUn.simple.val.u8); |
} | } |
break; | break; |
} | } |
|
|
{ | { |
if (isArray) | if (isArray) |
{ | { |
const Uint16* u=(Uint16*)&(base[scmbUn._arrayValue.start]); |
|
Array<Uint16> x; | Array<Uint16> x; |
x.append(u,arraySize); |
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(scmbUn._uint16Value); |
cimV.set(scmbUn.simple.val.u16); |
} | } |
break; | break; |
} | } |
|
|
{ | { |
if (isArray) | if (isArray) |
{ | { |
const Uint32* u=(Uint32*)&(base[scmbUn._arrayValue.start]); |
|
Array<Uint32> x; | Array<Uint32> x; |
x.append(u,arraySize); |
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(scmbUn._uint32Value); |
cimV.set(scmbUn.simple.val.u32); |
} | } |
break; | break; |
} | } |
|
|
{ | { |
if (isArray) | if (isArray) |
{ | { |
const Uint64* u=(Uint64*)&(base[scmbUn._arrayValue.start]); |
|
Array<Uint64> x; | Array<Uint64> x; |
x.append(u,arraySize); |
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(scmbUn._uint64Value); |
cimV.set(scmbUn.simple.val.u64); |
} | } |
break; | break; |
} | } |
|
|
{ | { |
if (isArray) | if (isArray) |
{ | { |
const Sint8* u=(Sint8*)&(base[scmbUn._arrayValue.start]); |
|
Array<Sint8> x; | Array<Sint8> x; |
x.append(u,arraySize); |
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(scmbUn._sint8Value); |
cimV.set(scmbUn.simple.val.s8); |
} | } |
break; | break; |
} | } |
|
|
{ | { |
if (isArray) | if (isArray) |
{ | { |
const Sint16* u=(Sint16*)&(base[scmbUn._arrayValue.start]); |
|
Array<Sint16> x; | Array<Sint16> x; |
x.append(u,arraySize); |
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(scmbUn._sint16Value); |
cimV.set(scmbUn.simple.val.s16); |
} | } |
break; | break; |
} | } |
|
|
{ | { |
if (isArray) | if (isArray) |
{ | { |
const Sint32* u=(Sint32*)&(base[scmbUn._arrayValue.start]); |
|
Array<Sint32> x; | Array<Sint32> x; |
x.append(u,arraySize); |
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(scmbUn._sint32Value); |
cimV.set(scmbUn.simple.val.s32); |
} | } |
break; | break; |
} | } |
|
|
{ | { |
if (isArray) | if (isArray) |
{ | { |
const Sint64* u=(Sint64*)&(base[scmbUn._arrayValue.start]); |
|
Array<Sint64> x; | Array<Sint64> x; |
x.append(u,arraySize); |
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(scmbUn._sint64Value); |
cimV.set(scmbUn.simple.val.s64); |
} | } |
break; | break; |
} | } |
|
|
{ | { |
if (isArray) | if (isArray) |
{ | { |
const Real32* u=(Real32*)&(base[scmbUn._arrayValue.start]); |
|
Array<Real32> x; | Array<Real32> x; |
x.append(u,arraySize); |
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(scmbUn._real32Value); |
cimV.set(scmbUn.simple.val.r32); |
} | } |
break; | break; |
} | } |
|
|
{ | { |
if (isArray) | if (isArray) |
{ | { |
const Real64* u=(Real64*)&(base[scmbUn._arrayValue.start]); |
|
Array<Real64> x; | Array<Real64> x; |
x.append(u,arraySize); |
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(scmbUn._real64Value); |
cimV.set(scmbUn.simple.val.r64); |
} | } |
break; | break; |
} | } |
|
|
{ | { |
if (isArray) | if (isArray) |
{ | { |
const Char16* u=(Char16*)&(base[scmbUn._arrayValue.start]); |
|
Array<Char16> x; | Array<Char16> x; |
x.append(u,arraySize); |
for (Uint32 i = 0, k = arraySize; i < k ; i++) |
|
{ |
|
x.append(pscmbArrayUn[i].simple.val.c16); |
|
} |
cimV.set(x); | cimV.set(x); |
} | } |
else | else |
{ | { |
cimV.set(scmbUn._char16Value); |
cimV.set(scmbUn.simple.val.c16); |
} | } |
break; | break; |
} | } |
|
|
{ | { |
if (isArray) | if (isArray) |
{ | { |
const Boolean* u=(Boolean*)&(base[scmbUn._arrayValue.start]); |
|
Array<Boolean> x; | Array<Boolean> x; |
x.append(u,arraySize); |
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(scmbUn._booleanValue); |
cimV.set(scmbUn.simple.val.bin); |
} | } |
break; | break; |
} | } |
|
|
{ | { |
if (isArray) | if (isArray) |
{ | { |
// get the pointer to the array of relative SCMB pointers |
|
const SCMBDataPtr *ptr = |
|
(SCMBDataPtr*)&(base[scmbUn._arrayValue.start]); |
|
| |
Array<String> x; | Array<String> x; |
| |
for (Uint32 i = 0, k = arraySize; i < k ; i++) | for (Uint32 i = 0, k = arraySize; i < k ; i++) |
{ | { |
x.append(NEWCIMSTR(ptr[i],base)); |
x.append(NEWCIMSTR(pscmbArrayUn[i].stringValue,base)); |
} | } |
cimV.set(x); | cimV.set(x); |
} | } |
else | else |
{ | { |
cimV.set(NEWCIMSTR(scmbUn._stringValue,base)); |
cimV.set(NEWCIMSTR(scmbUn.stringValue,base)); |
} | } |
break; | break; |
} | } |
|
|
{ | { |
if (isArray) | if (isArray) |
{ | { |
// get the pointer to the array of SCMBDateTime |
|
const SCMBDateTime *ptr = |
|
(SCMBDateTime*)&(base[scmbUn._arrayValue.start]); |
|
|
|
Array<CIMDateTime> x; | Array<CIMDateTime> x; |
| |
for (Uint32 i = 0, k = arraySize; 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(&scmbUn._dateTimeValue)); |
cimV.set(CIMDateTime(&scmbUn.dateTimeValue)); |
} | } |
break; | break; |
| |
} | } |
| |
case CIMTYPE_REFERENCE: | case CIMTYPE_REFERENCE: |
|
{ |
|
CIMObjectPath theObjPath; |
| |
break; |
if(isArray) |
|
{ |
|
Array<CIMObjectPath> x; |
|
for (Uint32 i = 0, k = arraySize; i < k ; i++) |
|
{ |
|
if (0 != pscmbArrayUn[i].extRefPtr) |
|
{ |
|
pscmbArrayUn[i].extRefPtr->getCIMObjectPath(theObjPath); |
|
x.append(theObjPath); |
|
} |
|
else |
|
{ |
|
// set an empty object |
|
x.append(CIMObjectPath()); |
|
} |
|
} |
|
cimV.set(x); |
|
} |
|
else |
|
{ |
| |
|
if (0 != scmbUn.extRefPtr) |
|
{ |
|
scmbUn.extRefPtr->getCIMObjectPath(theObjPath); |
|
cimV.set(theObjPath); |
|
} |
|
else |
|
{ |
|
cimV.set(CIMObjectPath()); |
|
} |
|
} |
|
break; |
|
} |
case CIMTYPE_OBJECT: | case CIMTYPE_OBJECT: |
|
{ |
|
CIMInstance theInstance; |
|
CIMClass theClass; |
|
|
|
if(isArray) |
|
{ |
|
Array<CIMObject> x; |
|
for (Uint32 i = 0, k = arraySize; i < k ; i++) |
|
{ |
|
if (0 != pscmbArrayUn[i].extRefPtr) |
|
{ |
|
// check if the Object is an emedded instance or class |
|
if(pscmbArrayUn[i].extRefPtr-> |
|
inst.hdr->flags.isClassOnly) |
|
{ |
|
pscmbArrayUn[i].extRefPtr-> |
|
inst.hdr->theClass->getCIMClass(theClass); |
|
x.append(CIMObject(theClass)); |
|
} |
|
else |
|
{ |
|
pscmbArrayUn[i].extRefPtr-> |
|
getCIMInstance(theInstance); |
|
x.append(CIMObject(theInstance)); |
|
} |
|
} |
|
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->getCIMClass(theClass); |
|
cimV.set(CIMObject(theClass)); |
|
} |
|
else |
|
{ |
|
scmbUn.extRefPtr->getCIMInstance(theInstance); |
|
cimV.set(CIMObject(theInstance)); |
|
} |
|
} |
|
else |
|
{ |
|
cimV.set(CIMObject()); |
|
} |
|
} |
break; | break; |
|
} |
| |
case CIMTYPE_INSTANCE: | 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; | break; |
} | } |
} | } |
|
} |
| |
void SCMOInstance::_getCIMValueFromSCMBValue( | void SCMOInstance::_getCIMValueFromSCMBValue( |
CIMValue& cimV, | CIMValue& cimV, |
const SCMBValue& scmbV, | const SCMBValue& scmbV, |
const char * base) const |
const char * base) |
{ | { |
_getCIMValueFromSCMBUnion( |
SCMOInstance::_getCIMValueFromSCMBUnion( |
cimV, | cimV, |
scmbV.valueType, | scmbV.valueType, |
scmbV.flags.isNull, | scmbV.flags.isNull, |
|
|
CIMObjectPathRep* objRep = cimObj._rep; | CIMObjectPathRep* objRep = cimObj._rep; |
SCMO_RC rc; | 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(); | CString className = objRep->_className.getString().getCString(); |
CString nameSpace = objRep->_nameSpace.getString().getCString(); |
|
| |
// Is the instance from the same class and name space ? |
// Is the instance from the same class ? |
if (!(_equalNoCaseUTF8Strings( | if (!(_equalNoCaseUTF8Strings( |
clshdr->className, |
inst.hdr->instClassName, |
clsbase, |
inst.base, |
(const char*)className, | (const char*)className, |
strlen(className)) && |
strlen(className)))) |
_equalNoCaseUTF8Strings( |
|
clshdr->nameSpace, |
|
clsbase, |
|
(const char*)nameSpace, |
|
strlen(nameSpace))) |
|
) |
|
{ | { |
throw PEGASUS_CIM_EXCEPTION(CIM_ERR_INVALID_CLASS, | throw PEGASUS_CIM_EXCEPTION(CIM_ERR_INVALID_CLASS, |
objRep->_className.getString()); | objRep->_className.getString()); |
|
|
//set host name | //set host name |
_setString(objRep->_host,inst.hdr->hostName,&inst.mem ); | _setString(objRep->_host,inst.hdr->hostName,&inst.mem ); |
| |
if (inst.hdr->numberKeyBindings < objRep->_keyBindings.size()) |
|
{ |
|
String message("CIMObjectPath has more keybindings " |
|
"than the associated class key properties."); |
|
throw CIMException(CIM_ERR_FAILED, message); |
|
} |
|
|
|
for (Uint32 i = 0, k = objRep->_keyBindings.size(); i < k; i++) | for (Uint32 i = 0, k = objRep->_keyBindings.size(); i < k; i++) |
{ | { |
|
String key = objRep->_keyBindings[i].getValue(); |
rc = _setKeyBindingFromString( | rc = _setKeyBindingFromString( |
(const char*) | (const char*) |
objRep->_keyBindings[i].getName().getString().getCString(), | objRep->_keyBindings[i].getName().getString().getCString(), |
objRep->_keyBindings[i].getValue()); |
_CIMTypeFromKeyBindingType( |
|
(const char*)key.getCString(), |
|
objRep->_keyBindings[i].getType()), |
|
key); |
| |
if (rc != SCMO_OK) | if (rc != SCMO_OK) |
{ | { |
switch (rc) |
String message("Can not set CIMObjectPath key binding:'"); |
{ |
|
case SCMO_NOT_FOUND: |
|
{ |
|
String message("CIMObjectPath key binding "); |
|
message.append( |
|
objRep->_keyBindings[i].getName().getString()); |
|
message.append(" not found."); |
|
throw CIMException(CIM_ERR_FAILED, message); |
|
} |
|
default: |
|
{ |
|
String message("CIMObjectPath key binding "); |
|
message.append( | message.append( |
objRep->_keyBindings[i].getName().getString()); | objRep->_keyBindings[i].getName().getString()); |
message.append(" does not match class definition!"); |
message.append("'"); |
throw CIMException(CIM_ERR_FAILED, message); | throw CIMException(CIM_ERR_FAILED, message); |
} | } |
} | } |
} |
|
} |
|
| |
} | } |
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; |
|
|
_setUnionArrayValue( | _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.length, |
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.length, |
|
valRep->u); |
} | } |
} | } |
| |
|
|
return inst.base == theInstance.inst.base; | return inst.base == theInstance.inst.base; |
} | } |
| |
const char* SCMOInstance::getHostName() const |
void SCMOInstance::setHostName(const char* hostName) |
{ | { |
return _getCharString(inst.hdr->hostName,inst.base); |
Uint32 len; |
} |
|
|
if (hostName!=0) |
|
{ |
|
|
|
len = strlen((const char*)hostName); |
|
if(len != 0) |
|
{ |
|
|
|
// copy including trailing '\0' |
|
_setBinary(hostName,len+1,inst.hdr->hostName,&inst.mem); |
|
return; |
|
} |
|
|
|
} |
|
inst.hdr->hostName.start=0; |
|
inst.hdr->hostName.length=0; |
|
} |
|
|
|
const char* SCMOInstance::getHostName() const |
|
{ |
|
return _getCharString(inst.hdr->hostName,inst.base); |
|
} |
|
|
|
const char* SCMOInstance::getHostName_l(Uint64& length) const |
|
{ |
|
length = inst.hdr->hostName.length; |
|
return _getCharString(inst.hdr->hostName,inst.base); |
|
} |
|
|
|
void SCMOInstance::setClassName(const char* className) |
|
{ |
|
Uint32 len; |
|
|
|
if (className!=0) |
|
{ |
|
|
|
len = strlen((const char*)className); |
|
if(len != 0) |
|
{ |
|
|
|
// copy including trailing '\0' |
|
_setBinary(className,len+1,inst.hdr->instClassName,&inst.mem); |
|
return; |
|
} |
|
|
|
} |
|
|
|
inst.hdr->instClassName.start=0; |
|
inst.hdr->instClassName.length=0; |
|
|
|
// flag the instance as compromized |
|
inst.hdr->flags.isCompromised=true; |
|
|
|
} |
|
|
|
const char* SCMOInstance::getClassName() const |
|
{ |
|
return _getCharString(inst.hdr->instClassName,inst.base); |
|
} |
|
|
|
const char* SCMOInstance::getClassName_l(Uint64 & length) const |
|
{ |
|
length = inst.hdr->instClassName.length; |
|
return _getCharString(inst.hdr->instClassName,inst.base); |
|
} |
|
|
|
void SCMOInstance::setNameSpace(const char* nameSpace) |
|
{ |
|
Uint32 len; |
|
|
|
if (nameSpace!=0) |
|
{ |
|
|
|
len = strlen((const char*)nameSpace); |
|
if(len != 0) |
|
{ |
|
|
|
// copy including trailing '\0' |
|
_setBinary(nameSpace,len+1,inst.hdr->instNameSpace,&inst.mem); |
|
return; |
|
} |
|
|
|
} |
|
|
|
inst.hdr->instNameSpace.start=0; |
|
inst.hdr->instNameSpace.length=0; |
|
|
|
// flag the instance as compromized |
|
inst.hdr->flags.isCompromised=true; |
|
|
|
} |
|
|
|
const char* SCMOInstance::getNameSpace() const |
|
{ |
|
return _getCharString(inst.hdr->instNameSpace,inst.base); |
|
} |
|
|
|
const char* SCMOInstance::getNameSpace_l(Uint64 & length) const |
|
{ |
|
length = inst.hdr->instNameSpace.length; |
|
return _getCharString(inst.hdr->instNameSpace,inst.base); |
|
} |
| |
void SCMOInstance::buildKeyBindingsFromProperties() | void SCMOInstance::buildKeyBindingsFromProperties() |
{ | { |
|
|
{ | { |
keyData.isSet=true; | keyData.isSet=true; |
_setBinary( | _setBinary( |
&uBase[u._stringValue.start], |
&uBase[u.stringValue.start], |
u._stringValue.length, |
u.stringValue.length, |
keyData.data._stringValue, |
keyData.data.stringValue, |
&inst.mem); | &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); |
|
} |
|
else |
|
{ |
|
keyData.data.extRefPtr=0; |
|
} |
|
keyData.isSet=true; |
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) |
|
{ |
|
|
|
// copy including trailing '\0' |
|
_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( |
PEGASUS_ASSERT(false); |
inst.hdr->theClass->cls.hdr->className, |
break; |
inst.hdr->theClass->cls.base); |
|
} | } |
|
|
const char* SCMOInstance::getClassName_l(Uint64 & length) const |
|
{ |
|
SCMOClass * scmoCls = inst.hdr->theClass; |
|
length = scmoCls->cls.hdr->className.length; |
|
return _getCharString( |
|
scmoCls->cls.hdr->className, |
|
scmoCls->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; |
|
|
//Assign the SCMBClass structure this instance based on. | //Assign the SCMBClass structure this instance based on. |
inst.hdr->theClass = pClass; | inst.hdr->theClass = 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->cls.hdr->className, |
inst.hdr->flags.isFiltered=false; |
inst.hdr->theClass->cls.base), |
|
inst.hdr->theClass->cls.hdr->className.length, |
|
inst.hdr->instClassName, |
|
&inst.mem); |
| |
inst.hdr->hostName.start=0; |
_setBinary( |
inst.hdr->hostName.length=0; |
_getCharString(inst.hdr->theClass->cls.hdr->nameSpace, |
|
inst.hdr->theClass->cls.base), |
|
inst.hdr->theClass->cls.hdr->nameSpace.length, |
|
inst.hdr->instNameSpace, |
|
&inst.mem); |
| |
// Number of key bindings | // Number of key bindings |
inst.hdr->numberKeyBindings = | inst.hdr->numberKeyBindings = |
|
|
&inst.mem, | &inst.mem, |
true); | true); |
| |
inst.hdr->propertyFilter.start=0; |
} |
inst.hdr->propertyFilter.length=0; |
|
inst.hdr->propertyFilterIndexMap.start=0; |
void SCMOInstance::_setCIMInstance(const CIMInstance& cimInstance) |
inst.hdr->propertyFilterIndexMap.length=0; |
{ |
|
CIMPropertyRep* propRep; |
|
Uint32 propNode; |
|
Uint64 valueStart; |
|
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); |
|
|
|
_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->_getProperyNodeIndex( |
|
propNode, |
|
(const char*)propRep->_name.getString().getCString()); |
| |
|
if (rc != SCMO_OK) |
|
{ |
|
throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NO_SUCH_PROPERTY, |
|
propRep->_name.getString()); |
|
} |
|
// The type stored in the class information is set on realType. |
|
// It must be used in further calls to guaranty consistence. |
|
rc = inst.hdr->theClass->_isNodeSameType( |
|
propNode, |
|
propRep->_value._rep->type, |
|
propRep->_value._rep->isArray, |
|
realType); |
|
if (rc == SCMO_OK) |
|
{ |
|
_setCIMValueAtNodeIndex(propNode, propRep->_value._rep,realType); |
|
} |
|
else |
|
{ |
|
throw PEGASUS_CIM_EXCEPTION(CIM_ERR_TYPE_MISMATCH, |
|
propRep->_name.getString()); |
|
} |
|
} |
} | } |
| |
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; |
| |
|
|
} | } |
} | } |
| |
return _getPropertyAtNodeIndex(node,&pname,type,pvalue,isArray,size); |
return _getPropertyAtNodeIndex(node,&pname,type,pOutVal,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; | Uint32 node; |
|
|
} | } |
} | } |
| |
return _getPropertyAtNodeIndex(node,pname,type,pvalue,isArray,size); |
return _getPropertyAtNodeIndex(node,pname,type,pOutVal,isArray,size); |
} | } |
| |
SCMO_RC SCMOInstance::getPropertyAt( | SCMO_RC SCMOInstance::getPropertyAt( |
|
|
} | } |
| |
SCMBValue* theInstPropNodeArray = | SCMBValue* theInstPropNodeArray = |
(SCMBValue*)&inst.base[inst.hdr->propertyArray.start]; |
(SCMBValue*)&(inst.base[inst.hdr->propertyArray.start]); |
| |
// create a pointer to property node array of the class. | // create a pointer to property node array of the class. |
Uint64 idx = inst.hdr->theClass->cls.hdr->propertySet.nodeArray.start; | Uint64 idx = inst.hdr->theClass->cls.hdr->propertySet.nodeArray.start; |
|
|
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; |
} | } |
|
|
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) |
{ | { |
Uint32 node; | Uint32 node; |
SCMO_RC rc; | SCMO_RC rc; |
|
CIMType realType; |
| |
rc = inst.hdr->theClass->_getProperyNodeIndex(node,name); | rc = inst.hdr->theClass->_getProperyNodeIndex(node,name); |
if (rc != SCMO_OK) | if (rc != 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->_isNodeSameType(node,type,isArray,realType); |
if (rc != SCMO_OK) | if (rc != SCMO_OK) |
{ | { |
return rc; | return rc; |
|
|
} | } |
| |
// 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->_isSamePropOrigin(node,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) |
{ | { |
SCMO_RC rc; | SCMO_RC rc; |
|
CIMType realType; |
| |
if (node >= inst.hdr->numberProperties) | if (node >= inst.hdr->numberProperties) |
{ | { |
|
|
} | } |
| |
// 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->_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) |
{ | { |
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 |
{ | { |
_setSCMBUnion(value,type,isArray,size,theInstPropNodeArray[node].value); |
_setSCMBUnion( |
|
pInVal, |
|
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, |
|
|
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: |
|
case CIMTYPE_DATETIME: |
{ | { |
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)); |
} | } |
break; | break; |
} | } |
|
case CIMTYPE_STRING: |
case CIMTYPE_UINT8: |
|
{ | { |
if (isArray) | if (isArray) |
{ | { |
_setBinary(value,size*sizeof(Uint8), |
SCMBUnion* ptr; |
u._arrayValue, |
Uint64 startPtr; |
&inst.mem ); |
|
} |
|
else |
|
{ |
|
u._uint8Value = *((Uint8*)value); |
|
} |
|
break; |
|
} |
|
| |
case CIMTYPE_SINT8: |
startPtr = _getFreeSpace( |
{ |
u.arrayValue, |
if (isArray) |
size*sizeof(SCMBUnion), |
|
&inst.mem,true); |
|
|
|
for (Uint32 i = 0; i < size; i++) |
{ | { |
_setBinary(value,size*sizeof(Sint8), |
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._sint8Value = *((Sint8*)value); |
// Copy the sting including the trailing '\0' |
|
_setBinary( |
|
pInVal->extString.pchar, |
|
pInVal->extString.length+1, |
|
u.stringValue, |
|
&inst.mem ); |
} | } |
break; | break; |
} | } |
| |
case CIMTYPE_UINT16: |
case CIMTYPE_REFERENCE: |
|
case CIMTYPE_OBJECT: |
|
case CIMTYPE_INSTANCE: |
{ | { |
if (isArray) | if (isArray) |
{ | { |
_setBinary(value,size*sizeof(Uint16), |
SCMBUnion* ptr; |
u._arrayValue, |
Uint64 startPtr; |
&inst.mem ); |
|
} |
|
else |
|
{ |
|
u._uint16Value = *((Uint16*)value); |
|
} |
|
break; |
|
} |
|
| |
case CIMTYPE_SINT16: |
// 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,false); |
|
|
|
ptr = (SCMBUnion*)&(inst.base[startPtr]); |
|
|
|
for (Uint32 i = 0 ; i < size ; i++) |
{ | { |
if (isArray) |
if(pInVal[i].extRefPtr) |
{ | { |
_setBinary(value,size*sizeof(Sint16), |
ptr[i].extRefPtr= |
u._arrayValue, |
new SCMOInstance(*(pInVal[i].extRefPtr)); |
&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)); |
{ |
|
_setBinary(value,size*sizeof(Sint32), |
|
u._arrayValue, |
|
&inst.mem ); |
|
} | } |
else | else |
{ | { |
u._sint32Value = *((Sint32*)value); |
u.extRefPtr = 0; |
|
} |
} | } |
break; | break; |
} | } |
|
default: |
case CIMTYPE_UINT64: |
|
{ |
|
if (isArray) |
|
{ |
|
_setBinary(value,size*sizeof(Uint64), |
|
u._arrayValue, |
|
&inst.mem ); |
|
} |
|
else |
|
{ |
|
u._uint64Value = *((Uint64*)value); |
|
} |
|
break; |
|
} |
|
|
|
case CIMTYPE_SINT64: |
|
{ |
|
if (isArray) |
|
{ |
|
_setBinary(value,size*sizeof(Sint64), |
|
u._arrayValue, |
|
&inst.mem ); |
|
} |
|
else |
|
{ |
|
u._sint64Value = *((Sint64*)value); |
|
} |
|
break; |
|
} |
|
|
|
case CIMTYPE_REAL32: |
|
{ |
|
if (isArray) |
|
{ |
|
_setBinary(value,size*sizeof(Real32), |
|
u._arrayValue, |
|
&inst.mem ); |
|
} |
|
else |
|
{ |
|
u._real32Value = *((Real32*)value); |
|
} |
|
break; |
|
} |
|
|
|
case CIMTYPE_REAL64: |
|
{ |
|
if (isArray) |
|
{ |
|
_setBinary(value,size*sizeof(Real64), |
|
u._arrayValue, |
|
&inst.mem ); |
|
} |
|
else |
|
{ |
|
u._real64Value = *((Real64*)value); |
|
} |
|
break; |
|
} |
|
|
|
case CIMTYPE_CHAR16: |
|
{ |
|
if (isArray) |
|
{ |
|
_setBinary(value,size*sizeof(Char16), |
|
u._arrayValue, |
|
&inst.mem ); |
|
} |
|
else |
|
{ |
|
u._char16Value = *((Char16*)value); |
|
} |
|
break; |
|
} |
|
|
|
case CIMTYPE_DATETIME: |
|
{ |
|
if (isArray) |
|
{ |
|
_setBinary(value,size*sizeof(SCMBDateTime), |
|
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' |
PEGASUS_ASSERT(false); |
_setBinary( |
|
value, |
|
strlen((char*)value)+1, |
|
u._stringValue, |
|
&inst.mem ); |
|
} |
|
break; | break; |
} | } |
|
|
case CIMTYPE_REFERENCE: |
|
|
|
break; |
|
|
|
case CIMTYPE_OBJECT: |
|
|
|
break; |
|
case CIMTYPE_INSTANCE: |
|
|
|
break; |
|
} | } |
} | } |
| |
|
|
SCMBMgmt_Header** pmem, | SCMBMgmt_Header** pmem, |
CIMType type, | CIMType type, |
Uint32& n, | Uint32& n, |
|
Uint64 startNS, |
|
Uint64 lenNS, |
Union& u) | Union& u) |
{ | { |
SCMBUnion* scmoUnion = (SCMBUnion*)&(((char*)*pmem)[start]); | SCMBUnion* scmoUnion = (SCMBUnion*)&(((char*)*pmem)[start]); |
|
SCMBUnion* ptargetUnion; |
Uint64 arrayStart; | Uint64 arrayStart; |
|
Uint32 loop; |
| |
switch (type) | switch (type) |
{ | { |
case CIMTYPE_BOOLEAN: | case CIMTYPE_BOOLEAN: |
{ | { |
Array<Boolean> *x = reinterpret_cast<Array<Boolean>*>(&u); | Array<Boolean> *x = reinterpret_cast<Array<Boolean>*>(&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(Boolean), |
loop*sizeof(SCMBUnion), |
pmem); |
pmem, |
memcpy( |
true); |
&((char*)*pmem)[arrayStart],x->getData(),n * sizeof(Boolean)); |
|
|
ConstArrayIterator<Boolean> iterator(*x); |
|
|
|
ptargetUnion = (SCMBUnion*)&(((char*)*pmem)[arrayStart]); |
|
for (Uint32 i = 0; i < loop; i++) |
|
{ |
|
ptargetUnion[i].simple.val.bin = iterator[i]; |
|
ptargetUnion[i].simple.hasValue = true; |
|
} |
break; | break; |
} | } |
| |
case CIMTYPE_UINT8: | case CIMTYPE_UINT8: |
{ | { |
Array<Uint8> *x = reinterpret_cast<Array<Uint8>*>(&u); | Array<Uint8> *x = reinterpret_cast<Array<Uint8>*>(&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(Uint8), |
loop*sizeof(SCMBUnion), |
pmem); |
pmem, |
memcpy(&((char*)*pmem)[arrayStart],x->getData(),n * sizeof(Uint8)); |
true); |
|
|
|
ConstArrayIterator<Uint8> iterator(*x); |
|
|
|
ptargetUnion = (SCMBUnion*)&(((char*)*pmem)[arrayStart]); |
|
for (Uint32 i = 0; i < loop; i++) |
|
{ |
|
ptargetUnion[i].simple.val.u8 = iterator[i]; |
|
ptargetUnion[i].simple.hasValue = true; |
|
} |
break; | break; |
} | } |
| |
case CIMTYPE_SINT8: | case CIMTYPE_SINT8: |
{ | { |
Array<Sint8> *x = reinterpret_cast<Array<Sint8>*>(&u); | Array<Sint8> *x = reinterpret_cast<Array<Sint8>*>(&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(Sint8), |
loop*sizeof(SCMBUnion), |
pmem); |
pmem, |
memcpy(&((char*)*pmem)[arrayStart],x->getData(),n * sizeof(Sint8)); |
true); |
|
|
|
ConstArrayIterator<Sint8> iterator(*x); |
|
|
|
ptargetUnion = (SCMBUnion*)&(((char*)*pmem)[arrayStart]); |
|
for (Uint32 i = 0; i < loop; i++) |
|
{ |
|
ptargetUnion[i].simple.val.s8 = iterator[i]; |
|
ptargetUnion[i].simple.hasValue = true; |
|
} |
break; | break; |
} | } |
| |
case CIMTYPE_UINT16: | case CIMTYPE_UINT16: |
{ | { |
Array<Uint16> *x = reinterpret_cast<Array<Uint16>*>(&u); | Array<Uint16> *x = reinterpret_cast<Array<Uint16>*>(&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)); |
true); |
| |
|
ConstArrayIterator<Uint16> iterator(*x); |
|
|
|
ptargetUnion = (SCMBUnion*)&(((char*)*pmem)[arrayStart]); |
|
for (Uint32 i = 0; i < loop; i++) |
|
{ |
|
ptargetUnion[i].simple.val.u16 = iterator[i]; |
|
ptargetUnion[i].simple.hasValue = true; |
|
} |
break; | break; |
} | } |
| |
case CIMTYPE_SINT16: | case CIMTYPE_SINT16: |
{ | { |
Array<Sint16> *x = reinterpret_cast<Array<Sint16>*>(&u); | Array<Sint16> *x = reinterpret_cast<Array<Sint16>*>(&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(Sint16), |
loop*sizeof(SCMBUnion), |
pmem); |
pmem, |
memcpy(&((char*)*pmem)[arrayStart],x->getData(),n * sizeof(Sint16)); |
true); |
|
|
|
ConstArrayIterator<Sint16> iterator(*x); |
|
|
|
ptargetUnion = (SCMBUnion*)&(((char*)*pmem)[arrayStart]); |
|
for (Uint32 i = 0; i < loop; i++) |
|
{ |
|
ptargetUnion[i].simple.val.s16 = iterator[i]; |
|
ptargetUnion[i].simple.hasValue = true; |
|
} |
break; | break; |
} | } |
| |
case CIMTYPE_UINT32: | case CIMTYPE_UINT32: |
{ | { |
Array<Uint32> *x = reinterpret_cast<Array<Uint32>*>(&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(Uint32), |
loop*sizeof(SCMBUnion), |
pmem); |
pmem, |
memcpy(&((char*)*pmem)[arrayStart],x->getData(),n * sizeof(Uint32)); |
true); |
|
|
|
ConstArrayIterator<Uint32> iterator(*x); |
|
|
|
ptargetUnion = (SCMBUnion*)&(((char*)*pmem)[arrayStart]); |
|
for (Uint32 i = 0; i < loop; i++) |
|
{ |
|
ptargetUnion[i].simple.val.u32 = iterator[i]; |
|
ptargetUnion[i].simple.hasValue = true; |
|
} |
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)); |
true); |
|
|
|
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)); |
true); |
|
|
|
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)); |
true); |
|
|
|
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)); |
true); |
|
|
|
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)); |
true); |
|
|
|
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)); |
true); |
|
|
|
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; |
|
Uint32 size; |
|
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 ! | // n can be invalid after re-allocation in _getFreeSpace ! |
size = n = x->size(); |
loop = n = x->size(); |
| |
arrayStart = _getFreeSpace( | arrayStart = _getFreeSpace( |
scmoUnion->_arrayValue, |
scmoUnion->arrayValue, |
size*sizeof(SCMBDataPtr), |
loop*sizeof(SCMBUnion), |
pmem); | pmem); |
| |
for (Uint32 i = 0; i < size ; 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; |
|
Uint32 size; |
|
Array<CIMDateTime> *x = reinterpret_cast<Array<CIMDateTime>*>(&u); | Array<CIMDateTime> *x = reinterpret_cast<Array<CIMDateTime>*>(&u); |
// n can be invalid after reallocation in _getFreeSpace ! | // n can be invalid after reallocation in _getFreeSpace ! |
size = n = x->size(); |
loop = n = x->size(); |
|
|
arrayStart = _getFreeSpace( | arrayStart = _getFreeSpace( |
scmoUnion->_arrayValue, |
scmoUnion->arrayValue, |
size*sizeof(SCMBDateTime), |
loop*sizeof(SCMBUnion), |
pmem); | pmem); |
| |
ptr=(SCMBDateTime*)(&((char*)*pmem)[arrayStart]); |
ConstArrayIterator<CIMDateTime> iterator(*x); |
| |
for (Uint32 i = 0; i < size ; 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(); |
| |
break; |
arrayStart = _getFreeSpace( |
|
scmoUnion->arrayValue, |
|
loop*sizeof(SCMBUnion), |
|
pmem); |
| |
case CIMTYPE_INSTANCE: |
ConstArrayIterator<CIMObjectPath> iterator(*x); |
| |
break; |
ptargetUnion = (SCMBUnion*)(&((char*)*pmem)[arrayStart]); |
} |
|
} |
|
| |
|
SCMOClass* theRefClass; |
| |
void SCMOInstance::_setUnionValue( |
for (Uint32 i = 0; i < loop ; i++) |
Uint64 start, |
|
SCMBMgmt_Header** pmem, |
|
CIMType type, |
|
Union& u) |
|
{ | { |
SCMBUnion* scmoUnion = (SCMBUnion*)&(((char*)*pmem)[start]); |
|
| |
switch (type) |
theRefClass = _getSCMOClass( |
|
iterator[i], |
|
&(((const char*)*pmem)[startNS]), |
|
lenNS); |
|
|
|
if (theRefClass != 0) |
{ | { |
case CIMTYPE_BOOLEAN: |
ptargetUnion[i].extRefPtr = |
|
new SCMOInstance(*theRefClass,iterator[i]); |
|
} else |
{ | { |
scmoUnion->_booleanValue = u._booleanValue; |
//There is no reference class for the object path |
break; |
ptargetUnion[i].extRefPtr = 0; |
} | } |
|
|
case CIMTYPE_UINT8: |
|
{ |
|
scmoUnion->_uint8Value = u._uint8Value; |
|
break; |
|
} | } |
| |
case CIMTYPE_SINT8: |
|
{ |
|
scmoUnion->_sint8Value = u._sint8Value; |
|
break; | break; |
} | } |
|
case CIMTYPE_OBJECT: |
|
{ |
|
Array<CIMObject> *x = |
|
reinterpret_cast<Array<CIMObject>*>(&u); |
| |
case CIMTYPE_UINT16: |
// 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]); |
|
|
|
SCMOClass* theRefClass; |
|
|
|
for (Uint32 i = 0; i < loop ; i++) |
{ | { |
scmoUnion->_uint16Value = u._uint16Value; |
if (iterator[i].isUninitialized()) |
break; |
{ |
|
// the Object was empty. |
|
ptargetUnion[i].extRefPtr = 0; |
} | } |
|
else |
case CIMTYPE_SINT16: |
|
{ | { |
scmoUnion->_sint16Value = u._sint16Value; |
if (iterator[i].isClass()) |
break; |
{ |
|
CIMClass theClass(iterator[i]); |
|
ptargetUnion[i].extRefPtr = new SCMOInstance(theClass); |
|
// marke as class only ! |
|
ptargetUnion[i].extRefPtr-> |
|
inst.hdr->flags.isClassOnly=true; |
} | } |
|
else |
|
{ |
|
CIMInstance theInst(iterator[i]); |
|
theRefClass = _getSCMOClass( |
|
theInst.getPath(), |
|
&(((const char*)*pmem)[startNS]), |
|
lenNS); |
| |
case CIMTYPE_UINT32: |
if (theRefClass != 0) |
{ | { |
scmoUnion->_uint32Value = u._uint32Value; |
ptargetUnion[i].extRefPtr = |
break; |
new SCMOInstance(*theRefClass,theInst); |
|
} else |
|
{ |
|
//There is no reference class for the object path |
|
ptargetUnion[i].extRefPtr = 0; |
} | } |
| |
case CIMTYPE_SINT32: |
} |
{ |
} |
scmoUnion->_sint32Value = u._sint32Value; |
|
break; |
|
} | } |
| |
case CIMTYPE_UINT64: |
break; |
{ |
} |
scmoUnion->_uint64Value = u._uint64Value; |
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]); |
|
|
|
SCMOClass* theRefClass; |
|
|
|
for (Uint32 i = 0; i < loop ; i++) |
|
{ |
|
if (iterator[i].isUninitialized()) |
|
{ |
|
// the Instance was empty. |
|
ptargetUnion[i].extRefPtr = 0; |
|
} |
|
else |
|
{ |
|
theRefClass = _getSCMOClass( |
|
iterator[i].getPath(), |
|
&(((const char*)*pmem)[startNS]), |
|
lenNS); |
|
|
|
|
|
if (theRefClass != 0) |
|
{ |
|
ptargetUnion[i].extRefPtr = |
|
new SCMOInstance(*theRefClass,iterator[i]); |
|
} else |
|
{ |
|
//There is no reference class for the object path |
|
ptargetUnion[i].extRefPtr = 0; |
|
} |
|
} |
|
} |
|
|
|
break; |
|
} |
|
default: |
|
{ |
|
PEGASUS_ASSERT(false); |
|
break; |
|
} |
|
} |
|
} |
|
|
|
|
|
void SCMOInstance::_setUnionValue( |
|
Uint64 start, |
|
SCMBMgmt_Header** pmem, |
|
CIMType type, |
|
Uint64 startNS, |
|
Uint64 lenNS, |
|
Union& u) |
|
{ |
|
SCMBUnion* scmoUnion = (SCMBUnion*)&(((char*)*pmem)[start]); |
|
|
|
switch (type) |
|
{ |
|
case CIMTYPE_BOOLEAN: |
|
{ |
|
scmoUnion->simple.val.bin = u._booleanValue; |
|
scmoUnion->simple.hasValue=true; |
|
break; |
|
} |
|
|
|
case CIMTYPE_UINT8: |
|
{ |
|
scmoUnion->simple.val.u8 = u._uint8Value; |
|
scmoUnion->simple.hasValue=true; |
|
break; |
|
} |
|
|
|
case CIMTYPE_SINT8: |
|
{ |
|
scmoUnion->simple.val.s8 = u._sint8Value; |
|
scmoUnion->simple.hasValue=true; |
|
break; |
|
} |
|
|
|
case CIMTYPE_UINT16: |
|
{ |
|
scmoUnion->simple.val.u16 = u._uint16Value; |
|
scmoUnion->simple.hasValue=true; |
|
break; |
|
} |
|
|
|
case CIMTYPE_SINT16: |
|
{ |
|
scmoUnion->simple.val.s16 = u._sint16Value; |
|
scmoUnion->simple.hasValue=true; |
|
break; |
|
} |
|
|
|
case CIMTYPE_UINT32: |
|
{ |
|
scmoUnion->simple.val.u32 = u._uint32Value; |
|
scmoUnion->simple.hasValue=true; |
|
break; |
|
} |
|
|
|
case CIMTYPE_SINT32: |
|
{ |
|
scmoUnion->simple.val.s32 = u._sint32Value; |
|
scmoUnion->simple.hasValue=true; |
|
break; |
|
} |
|
|
|
case CIMTYPE_UINT64: |
|
{ |
|
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)), | _setString(*((String*)((void*)&u)), |
scmoUnion->_stringValue, |
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; |
|
} |
|
|
|
CIMObjectPath* theCIMObj = |
|
(CIMObjectPath*)((void*)&u._referenceValue); |
|
|
|
SCMOClass* theRefClass = _getSCMOClass( |
|
*theCIMObj, |
|
&(((const char*)*pmem)[startNS]), |
|
lenNS); |
| |
|
if (theRefClass != 0) |
|
{ |
|
scmoUnion->extRefPtr = |
|
new SCMOInstance(*theRefClass,*theCIMObj); |
|
} else |
|
{ |
|
//There is no reference class for the object path |
|
scmoUnion->extRefPtr = 0; |
|
} |
|
break; |
|
} |
case CIMTYPE_OBJECT: | case CIMTYPE_OBJECT: |
|
{ |
|
if (0 != scmoUnion->extRefPtr) |
|
{ |
|
delete scmoUnion->extRefPtr; |
|
scmoUnion->extRefPtr = 0; |
|
} |
|
|
|
if (0 == u._referenceValue) |
|
{ |
|
scmoUnion->extRefPtr=0; |
|
return; |
|
} |
|
|
|
CIMObject* theCIMObject =(CIMObject*)((void*)&u._objectValue); |
|
SCMOClass* theRefClass; |
|
|
|
if (theCIMObject->isUninitialized()) |
|
{ |
|
// the Object was empty. |
|
scmoUnion->extRefPtr = 0; |
|
} |
|
else |
|
{ |
|
if (theCIMObject->isClass()) |
|
{ |
|
CIMClass theClass(*theCIMObject); |
|
scmoUnion->extRefPtr = new SCMOInstance(theClass); |
|
// marke as class only ! |
|
scmoUnion->extRefPtr->inst.hdr->flags.isClassOnly=true; |
|
} |
|
else |
|
{ |
|
CIMInstance theInst(*theCIMObject); |
|
theRefClass = _getSCMOClass( |
|
theInst.getPath(), |
|
&(((const char*)*pmem)[startNS]), |
|
lenNS); |
|
|
|
if (theRefClass != 0) |
|
{ |
|
scmoUnion->extRefPtr = |
|
new SCMOInstance(*theRefClass,theInst); |
|
} else |
|
{ |
|
//There is no reference class for the object path |
|
scmoUnion->extRefPtr = 0; |
|
} |
| |
|
} |
|
} |
break; | break; |
|
} |
case CIMTYPE_INSTANCE: | case CIMTYPE_INSTANCE: |
|
{ |
|
if (0 != scmoUnion->extRefPtr) |
|
{ |
|
delete scmoUnion->extRefPtr; |
|
scmoUnion->extRefPtr = 0; |
|
} |
| |
break; |
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 |
|
{ |
|
SCMOClass* theRefClass = _getSCMOClass( |
|
theCIMInst->getPath(), |
|
&(((const char*)*pmem)[startNS]), |
|
lenNS); |
|
if (theRefClass != 0) |
|
{ |
|
scmoUnion->extRefPtr = |
|
new SCMOInstance(*theRefClass,*theCIMInst); |
|
} else |
|
{ |
|
//There is no reference class for the object path |
|
scmoUnion->extRefPtr = 0; |
|
} |
|
} |
|
break; |
|
} |
|
default: |
|
{ |
|
PEGASUS_ASSERT(false); |
|
break; |
|
} |
|
} |
} | } |
| |
SCMO_RC SCMOInstance::_getPropertyAtNodeIndex( | SCMO_RC SCMOInstance::_getPropertyAtNodeIndex( |
Uint32 node, | Uint32 node, |
const char** pname, | const char** pname, |
CIMType& type, | CIMType& type, |
const void** pvalue, |
const SCMBUnion** pvalue, |
Boolean& isArray, | Boolean& isArray, |
Uint32& size ) const | Uint32& size ) const |
{ | { |
|
|
| |
SCMOInstance newInst; | SCMOInstance newInst; |
newInst.inst.base = (char*)malloc(this->inst.mem->totalSize); | newInst.inst.base = (char*)malloc(this->inst.mem->totalSize); |
if (newInst.inst.base == NULL ) |
if (newInst.inst.base == 0 ) |
{ | { |
throw PEGASUS_STD(bad_alloc)(); | throw PEGASUS_STD(bad_alloc)(); |
} | } |
|
|
memcpy( newInst.inst.base,this->inst.base,this->inst.mem->totalSize); | memcpy( newInst.inst.base,this->inst.base,this->inst.mem->totalSize); |
// reset the refcounter of this new instance | // reset the refcounter of this new instance |
newInst.inst.hdr->refCount = 1; | newInst.inst.hdr->refCount = 1; |
// kepp the ref counter of the class correct ! |
// keep the ref counter of the class correct ! |
newInst.inst.hdr->theClass = new SCMOClass(*(this->inst.hdr->theClass)); | newInst.inst.hdr->theClass = new SCMOClass(*(this->inst.hdr->theClass)); |
|
// keep the ref count for external references |
|
newInst._copyExternalReferences(); |
| |
return newInst; | return newInst; |
} | } |
|
|
Uint32 noBindings = inst.hdr->numberKeyBindings; | Uint32 noBindings = inst.hdr->numberKeyBindings; |
| |
SCMBKeyBindingValue* sourceArray = | SCMBKeyBindingValue* sourceArray = |
(SCMBKeyBindingValue*)&inst.base[inst.hdr->keyBindingArray.start]; |
(SCMBKeyBindingValue*)&(inst.base[inst.hdr->keyBindingArray.start]); |
| |
// Address the class keybinding information | // Address the class keybinding information |
const SCMBClass_Main* clshdr = inst.hdr->theClass->cls.hdr; | const SCMBClass_Main* clshdr = inst.hdr->theClass->cls.hdr; |
const char * clsbase = inst.hdr->theClass->cls.base; | const char * clsbase = inst.hdr->theClass->cls.base; |
SCMBKeyBindingNode* scmoClassArray = | SCMBKeyBindingNode* scmoClassArray = |
(SCMBKeyBindingNode*)&clsbase[clshdr->keyBindingSet.nodeArray.start]; |
(SCMBKeyBindingNode*)&(clsbase[clshdr->keyBindingSet.nodeArray.start]); |
| |
SCMBKeyBindingValue* targetArray; | SCMBKeyBindingValue* targetArray; |
| |
|
|
} | } |
} | } |
| |
|
// Are there user defined key bindings ? |
|
if (0 != inst.hdr->numberUserKeyBindindigs) |
|
{ |
|
SCMBUserKeyBindingElement* theUserDefKBElement = |
|
(SCMBUserKeyBindingElement*) |
|
&(inst.base[inst.hdr->userKeyBindingElement.start]); |
|
|
|
for(Uint32 i = 0; i < inst.hdr->numberUserKeyBindindigs; i++) |
|
{ |
|
if (theUserDefKBElement->value.isSet) |
|
{ |
|
targetInst._setUserDefinedKeyBinding(*theUserDefKBElement, |
|
inst.base); |
|
} |
|
|
|
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.length-1, |
|
theInsertElement.type); |
|
|
|
// Copy the data |
|
_setKeyBindingFromSCMBUnion( |
|
theInsertElement.type, |
|
theInsertElement.value.data, |
|
elementBase, |
|
ptrNewElement->value); |
|
|
|
} |
|
|
|
|
|
SCMBUserKeyBindingElement* SCMOInstance::_getUserDefinedKeyBindingAt( |
|
Uint32 index ) const |
|
{ |
|
|
|
// 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 ++) |
|
{ |
|
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.length = |
|
inst.hdr->userKeyBindingElement.length; |
|
// - Assing the the new element |
|
// to the start point of user key binding element chain |
|
inst.hdr->userKeyBindingElement.start = newElement.start; |
|
inst.hdr->userKeyBindingElement.length = newElement.length; |
|
// Adjust the couter of user defined key bindings. |
|
inst.hdr->numberUserKeyBindindigs++; |
|
|
|
|
|
// 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 | Uint32 SCMOInstance::getPropertyCount() const |
{ | { |
if (inst.hdr->flags.isFiltered) | if (inst.hdr->flags.isFiltered) |
|
|
return(inst.hdr->numberProperties); | return(inst.hdr->numberProperties); |
} | } |
| |
void* SCMOInstance::_resolveSCMBUnion( |
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; | 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.length-1; |
} | } |
|
|
return((void*)tmp); |
|
} | } |
else | else |
{ | { |
return((void*)_getCharString(u->_stringValue,base)); |
ptr = (SCMBUnion*)malloc(sizeof(SCMBUnion)); |
|
ptr->extString.pchar = |
|
(char*)_getCharString(u->stringValue,base); |
|
// lenght with out the trailing /0 ! |
|
ptr->extString.length = u->stringValue.length-1; |
} | } |
| |
|
return(ptr); |
break; | break; |
} | } |
|
|
case CIMTYPE_REFERENCE: |
|
|
|
break; |
|
|
|
case CIMTYPE_OBJECT: |
|
|
|
break; |
|
|
|
case CIMTYPE_INSTANCE: |
|
|
|
break; |
|
|
|
default: | default: |
|
{ |
PEGASUS_ASSERT(false); | PEGASUS_ASSERT(false); |
break; | break; |
} | } |
return NULL; |
} |
|
return 0; |
} | } |
| |
Uint32 SCMOInstance::getKeyBindingCount() const | Uint32 SCMOInstance::getKeyBindingCount() const |
{ | { |
return(inst.hdr->numberKeyBindings); |
// count of class keys + user definded keys |
|
return(inst.hdr->numberKeyBindings+ |
|
inst.hdr->numberUserKeyBindindigs); |
} | } |
| |
| |
|
|
Uint32 node, | Uint32 node, |
const char** pname, | const char** pname, |
CIMType& type, | CIMType& type, |
const void** pvalue) const |
const SCMBUnion** pvalue) const |
{ | { |
SCMO_RC rc; | SCMO_RC rc; |
const SCMBUnion* pdata=NULL; |
const SCMBUnion* pdata=0; |
Uint32 pnameLen=0; | Uint32 pnameLen=0; |
| |
*pname = NULL; |
*pname = 0; |
*pvalue = NULL; |
*pvalue = 0; |
| |
if (node >= inst.hdr->numberKeyBindings) |
// count of class keys + user definded keys |
|
if (node >= (inst.hdr->numberKeyBindings+ |
|
inst.hdr->numberUserKeyBindindigs)) |
{ | { |
return SCMO_INDEX_OUT_OF_BOUND; | return SCMO_INDEX_OUT_OF_BOUND; |
} | } |
|
|
SCMO_RC SCMOInstance::getKeyBinding( | SCMO_RC SCMOInstance::getKeyBinding( |
const char* name, | const char* name, |
CIMType& type, | CIMType& type, |
const void** pvalue) const |
const SCMBUnion** pvalue) const |
{ | { |
SCMO_RC rc; | SCMO_RC rc; |
Uint32 node; | Uint32 node; |
const char* pname=NULL; |
const char* pname=0; |
const SCMBUnion* pdata=NULL; |
const SCMBUnion* pdata=0; |
Uint32 pnameLen=0; | Uint32 pnameLen=0; |
| |
*pvalue = NULL; |
*pvalue = 0; |
| |
rc = inst.hdr->theClass->_getKeyBindingNodeIndex(node,name); | rc = inst.hdr->theClass->_getKeyBindingNodeIndex(node,name); |
if (rc != SCMO_OK) | if (rc != SCMO_OK) |
{ | { |
|
// look at the user defined key bindings. |
|
rc = _getUserKeyBindingNodeIndex(node,name); |
|
if (rc != SCMO_OK) |
|
{ |
return rc; | return rc; |
} | } |
|
} |
| |
rc = _getKeyBindingDataAtNodeIndex(node,&pname,pnameLen,type,&pdata); | rc = _getKeyBindingDataAtNodeIndex(node,&pname,pnameLen,type,&pdata); |
|
|
if (rc != SCMO_OK) | if (rc != SCMO_OK) |
{ | { |
return rc; | return rc; |
|
|
CIMType & type, | CIMType & type, |
const SCMBUnion** pdata) const | const SCMBUnion** pdata) const |
{ | { |
|
if (node < inst.hdr->numberKeyBindings) |
|
{ |
SCMBKeyBindingValue* theInstKeyBindValueArray = | SCMBKeyBindingValue* theInstKeyBindValueArray = |
(SCMBKeyBindingValue*)&inst.base[inst.hdr->keyBindingArray.start]; |
(SCMBKeyBindingValue*)&(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->cls.hdr->keyBindingSet.nodeArray.start; |
SCMBKeyBindingNode* theClassKeyBindNodeArray = | SCMBKeyBindingNode* theClassKeyBindNodeArray = |
(SCMBKeyBindingNode*)&(inst.hdr->theClass->cls.base)[idx]; |
(SCMBKeyBindingNode*)&((inst.hdr->theClass->cls.base)[idx]); |
| |
type = theClassKeyBindNodeArray[node].type; | type = theClassKeyBindNodeArray[node].type; |
| |
/* First resolve pointer to the property name */ |
// First resolve pointer to the key binding name |
pnameLen = theClassKeyBindNodeArray[node].name.length; | pnameLen = theClassKeyBindNodeArray[node].name.length; |
*pname = _getCharString( | *pname = _getCharString( |
theClassKeyBindNodeArray[node].name, | theClassKeyBindNodeArray[node].name, |
|
|
} | } |
| |
*pdata = &(theInstKeyBindValueArray[node].data); | *pdata = &(theInstKeyBindValueArray[node].data); |
|
} |
|
else // look at the user defined key bindings |
|
{ |
|
|
|
SCMBUserKeyBindingElement* theElem = _getUserDefinedKeyBindingAt(node); |
|
|
|
type = theElem->type; |
|
|
|
pnameLen = theElem->name.length; |
|
*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; | return SCMO_OK; |
} | } |
| |
Boolean SCMOInstance::_setCimKeyBindingStringToSCMOKeyBindigValue( |
SCMO_RC SCMOInstance::_getUserKeyBindingNodeIndex( |
const char* v, |
Uint32& node, |
Uint32 len, |
const char* name) const |
CIMType type, |
|
SCMBKeyBindingValue& scmoKBV |
|
) |
|
{ | { |
scmoKBV.isSet=false; |
|
| |
if (v == NULL || len == 0 && type != CIMTYPE_STRING) |
Uint32 len = strlen(name); |
|
node = 0; |
|
SCMBUserKeyBindingElement* theUserDefKBElement; |
|
|
|
Uint64 elementStart = inst.hdr->userKeyBindingElement.start; |
|
|
|
while (elementStart != 0) |
{ | { |
// The string is empty ! Do nothing. |
SCMBUserKeyBindingElement* theUserDefKBElement = |
return true; |
(SCMBUserKeyBindingElement*)&(inst.base[elementStart]); |
|
|
|
if (_equalUTF8Strings(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 |
|
{ |
|
return CIMTYPE_REAL64; |
|
} |
|
} |
|
break; |
|
} |
|
|
|
|
|
case CIMKeyBinding::STRING: |
|
{ |
|
return CIMTYPE_STRING; |
|
break; |
} | } |
|
|
|
case CIMKeyBinding::BOOLEAN: |
|
{ |
|
return CIMTYPE_BOOLEAN; |
|
break; |
|
} |
|
|
|
case CIMKeyBinding::REFERENCE: |
|
{ |
|
return CIMTYPE_REFERENCE; |
|
break; |
|
} |
|
|
|
default: |
|
return CIMTYPE_UINT64; |
|
} |
|
return CIMTYPE_UINT64; |
|
} |
|
|
|
Boolean SCMOInstance::_setCimKeyBindingStringToSCMOKeyBindingValue( |
|
const String& kbs, |
|
CIMType type, |
|
SCMBKeyBindingValue& scmoKBV |
|
) |
|
{ |
|
scmoKBV.isSet=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) | switch (type) |
{ | { |
case CIMTYPE_UINT8: | case CIMTYPE_UINT8: |
|
|
if (StringConversion::stringToUnsignedInteger(v, x) && | if (StringConversion::stringToUnsignedInteger(v, x) && |
StringConversion::checkUintBounds(x, type)) | StringConversion::checkUintBounds(x, type)) |
{ | { |
scmoKBV.data._uint8Value = Uint8(x); |
scmoKBV.data.simple.val.u8 = Uint8(x); |
scmoKBV.isSet=true; | scmoKBV.isSet=true; |
} | } |
break; | break; |
|
|
if (StringConversion::stringToUnsignedInteger(v, x) && | if (StringConversion::stringToUnsignedInteger(v, x) && |
StringConversion::checkUintBounds(x, type)) | StringConversion::checkUintBounds(x, type)) |
{ | { |
scmoKBV.data._uint16Value = Uint16(x); |
scmoKBV.data.simple.val.u16 = Uint16(x); |
scmoKBV.isSet=true; | scmoKBV.isSet=true; |
} | } |
break; | break; |
|
|
if (StringConversion::stringToUnsignedInteger(v, x) && | if (StringConversion::stringToUnsignedInteger(v, x) && |
StringConversion::checkUintBounds(x, type)) | StringConversion::checkUintBounds(x, type)) |
{ | { |
scmoKBV.data._uint32Value = Uint32(x); |
scmoKBV.data.simple.val.u32 = Uint32(x); |
scmoKBV.isSet=true; | scmoKBV.isSet=true; |
} | } |
break; | break; |
|
|
Uint64 x; | Uint64 x; |
if (StringConversion::stringToUnsignedInteger(v, x)) | if (StringConversion::stringToUnsignedInteger(v, x)) |
{ | { |
scmoKBV.data._uint64Value = x; |
scmoKBV.data.simple.val.u64 = x; |
scmoKBV.isSet=true; | scmoKBV.isSet=true; |
} | } |
break; | break; |
|
|
if (StringConversion::stringToSignedInteger(v, x) && | if (StringConversion::stringToSignedInteger(v, x) && |
StringConversion::checkSintBounds(x, type)) | StringConversion::checkSintBounds(x, type)) |
{ | { |
scmoKBV.data._sint8Value = Sint8(x); |
scmoKBV.data.simple.val.s8 = Sint8(x); |
scmoKBV.isSet=true; | scmoKBV.isSet=true; |
} | } |
break; | break; |
|
|
if (StringConversion::stringToSignedInteger(v, x) && | if (StringConversion::stringToSignedInteger(v, x) && |
StringConversion::checkSintBounds(x, type)) | StringConversion::checkSintBounds(x, type)) |
{ | { |
scmoKBV.data._sint16Value = Sint16(x); |
scmoKBV.data.simple.val.s16 = Sint16(x); |
scmoKBV.isSet=true; | scmoKBV.isSet=true; |
} | } |
break; | break; |
|
|
if (StringConversion::stringToSignedInteger(v, x) && | if (StringConversion::stringToSignedInteger(v, x) && |
StringConversion::checkSintBounds(x, type)) | StringConversion::checkSintBounds(x, type)) |
{ | { |
scmoKBV.data._sint32Value = Sint32(x); |
scmoKBV.data.simple.val.s32 = Sint32(x); |
scmoKBV.isSet=true; | scmoKBV.isSet=true; |
} | } |
break; | break; |
|
|
Sint64 x; | Sint64 x; |
if (StringConversion::stringToSignedInteger(v, x)) | if (StringConversion::stringToSignedInteger(v, x)) |
{ | { |
scmoKBV.data._sint64Value = x; |
scmoKBV.data.simple.val.s64 = x; |
scmoKBV.isSet=true; | scmoKBV.isSet=true; |
} | } |
break; | break; |
|
|
} | } |
| |
memcpy( | memcpy( |
&(scmoKBV.data._dateTimeValue), |
&(scmoKBV.data.dateTimeValue), |
tmp._rep, | tmp._rep, |
sizeof(SCMBDateTime)); | sizeof(SCMBDateTime)); |
scmoKBV.isSet=true; | scmoKBV.isSet=true; |
|
|
{ | { |
Real64 x; | Real64 x; |
| |
if (!StringConversion::stringToReal64(v, x)) |
if (StringConversion::stringToReal64(v, x)) |
{ | { |
scmoKBV.data._real32Value = Real32(x); |
scmoKBV.data.simple.val.r32 = Real32(x); |
scmoKBV.isSet=true; | scmoKBV.isSet=true; |
} | } |
break; | break; |
|
|
{ | { |
Real64 x; | Real64 x; |
| |
if (!StringConversion::stringToReal64(v, x)) |
if (StringConversion::stringToReal64(v, x)) |
{ | { |
scmoKBV.data._real32Value = x; |
scmoKBV.data.simple.val.r64 = x; |
scmoKBV.isSet=true; | scmoKBV.isSet=true; |
} | } |
break; | break; |
|
|
| |
case CIMTYPE_CHAR16: | case CIMTYPE_CHAR16: |
{ | { |
// Converts UTF-8 to UTF-16 |
if (kbs.size() == 1) |
String tmp(v, len); |
{ |
if (tmp.size() == 1) |
scmoKBV.data.simple.val.c16 = kbs[0]; |
|
scmoKBV.isSet=true; |
|
} |
|
break; |
|
} |
|
case CIMTYPE_BOOLEAN: |
|
{ |
|
if (String::equalNoCase(kbs,"TRUE")) |
|
{ |
|
scmoKBV.data.simple.val.bin = true; |
|
scmoKBV.isSet=true; |
|
} |
|
else if (String::equalNoCase(kbs,"FALSE")) |
|
{ |
|
scmoKBV.data.simple.val.bin = false; |
|
scmoKBV.isSet=true; |
|
} |
|
break; |
|
} |
|
|
|
case CIMTYPE_STRING: |
|
{ |
|
scmoKBV.isSet=true; |
|
// Can cause reallocation ! |
|
_setString(kbs,scmoKBV.data.stringValue,&inst.mem); |
|
return true; |
|
break; |
|
} |
|
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); |
|
SCMOClass* theRefClass = _getSCMOClass( |
|
theCIMObj, |
|
_getCharString(inst.hdr->instNameSpace,inst.base), |
|
inst.hdr->instNameSpace.length); |
|
|
|
if (theRefClass != 0) |
|
{ |
|
scmoKBV.data.extRefPtr = |
|
new SCMOInstance(*theRefClass,theCIMObj); |
|
} else |
|
{ |
|
scmoKBV.data.extRefPtr = 0; |
|
} |
|
scmoKBV.isSet=true; |
|
break; |
|
} |
|
case CIMTYPE_OBJECT: |
|
case CIMTYPE_INSTANCE: |
|
{ |
|
// From PEP 194: EmbeddedObjects cannot be keys. |
|
throw TypeMismatchException(); |
|
break; |
|
} |
|
default: |
|
{ |
|
PEGASUS_ASSERT(false); |
|
break; |
|
} |
|
} |
|
|
|
return scmoKBV.isSet; |
|
} |
|
|
|
SCMO_RC SCMOInstance::_setKeyBindingFromString( |
|
const char* name, |
|
CIMType type, |
|
String cimKeyBinding) |
|
{ |
|
SCMO_RC rc; |
|
Uint32 node; |
|
|
|
if (0 == name) |
|
{ |
|
return SCMO_INVALID_PARAMETER; |
|
} |
|
|
|
if (SCMO_OK == inst.hdr->theClass->_getKeyBindingNodeIndex(node,name)) |
|
{ |
|
// create a pointer to keybinding node array of the class. |
|
Uint64 idx = inst.hdr->theClass->cls.hdr->keyBindingSet.nodeArray.start; |
|
SCMBKeyBindingNode* theClassKeyBindNodeArray = |
|
(SCMBKeyBindingNode*)&((inst.hdr->theClass->cls.base)[idx]); |
|
|
|
// create a pointer to 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; |
|
} |
|
|
|
return SCMO_OK; |
|
} |
|
|
|
// the key binig does not belong to the associated class |
|
// 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)) |
|
{ |
|
return SCMO_TYPE_MISSMATCH; |
|
} |
|
|
|
return SCMO_OK; |
|
} |
|
|
|
SCMO_RC SCMOInstance::setKeyBinding( |
|
const char* name, |
|
CIMType type, |
|
const SCMBUnion* keyvalue) |
|
{ |
|
SCMO_RC rc; |
|
Uint32 node; |
|
|
|
if (0 == name) |
|
{ |
|
return SCMO_INVALID_PARAMETER; |
|
} |
|
|
|
if (0 == keyvalue) |
|
{ |
|
return SCMO_INVALID_PARAMETER; |
|
} |
|
|
|
rc = inst.hdr->theClass->_getKeyBindingNodeIndex(node,name); |
|
if (rc != SCMO_OK) |
|
{ |
|
// 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); |
|
|
|
// Is this a new node or an existing user key binding? |
|
if (theNode->value.isSet && (theNode->type != type)) |
|
{ |
|
return SCMO_TYPE_MISSMATCH; |
|
|
|
} |
|
|
|
theNode->value.isSet=true; |
|
|
|
_setSCMBUnion( |
|
keyvalue, |
|
type, |
|
false, // a key binding can never be an array. |
|
0, |
|
theNode->value.data); |
|
|
|
return SCMO_OK; |
|
} |
|
|
|
return setKeyBindingAt(node, type, keyvalue); |
|
} |
|
|
|
SCMO_RC SCMOInstance::setKeyBindingAt( |
|
Uint32 node, |
|
CIMType type, |
|
const SCMBUnion* keyvalue) |
|
{ |
|
SCMO_RC rc; |
|
|
|
// create a pointer to keybinding node array of the class. |
|
Uint64 idx = inst.hdr->theClass->cls.hdr->keyBindingSet.nodeArray.start; |
|
SCMBKeyBindingNode* theClassKeyBindNodeArray = |
|
(SCMBKeyBindingNode*)&((inst.hdr->theClass->cls.base)[idx]); |
|
|
|
if (0 == keyvalue) |
|
{ |
|
return SCMO_INVALID_PARAMETER; |
|
} |
|
|
|
// count of class keys + user definded keys |
|
if (node >= (inst.hdr->numberKeyBindings+ |
|
inst.hdr->numberUserKeyBindindigs)) |
|
{ |
|
return SCMO_INDEX_OUT_OF_BOUND; |
|
} |
|
|
|
// is the node a user defined key binding ? |
|
if (node >= inst.hdr->numberKeyBindings) |
|
{ |
|
SCMBUserKeyBindingElement* theNode = _getUserDefinedKeyBindingAt(node); |
|
|
|
// 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); |
|
|
|
return SCMO_OK; |
|
|
|
} |
|
|
|
SCMBKeyBindingValue* theInstKeyBindValueArray = |
|
(SCMBKeyBindingValue*)&(inst.base[inst.hdr->keyBindingArray.start]); |
|
|
|
|
|
if (theClassKeyBindNodeArray[node].type == type) |
|
{ |
|
|
|
// Has to be set first, |
|
// because reallocaton can take place in _setSCMBUnion() |
|
theInstKeyBindValueArray[node].isSet=true; |
|
|
|
_setSCMBUnion( |
|
keyvalue, |
|
type, |
|
false, // a key binding can never be an array. |
|
0, |
|
theInstKeyBindValueArray[node].data); |
|
|
|
return SCMO_OK; |
|
|
|
} |
|
|
|
// The type does not match. |
|
return _setKeyBindingTypeTolerate( |
|
theClassKeyBindNodeArray[node].type, |
|
type, |
|
keyvalue, |
|
theInstKeyBindValueArray[node]); |
|
|
|
} |
|
|
|
/** |
|
* Set a SCMO user defined key binding using the class CIM type tolerating |
|
* 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); |
|
return SCMO_OK; |
|
break; |
|
} |
|
case CIMTYPE_UINT16: |
|
{ |
|
kbValue.isSet=true; |
|
kbValue.data.simple.hasValue=true; |
|
kbValue.data.simple.val.u16=Uint16(keyValue->simple.val.u64); |
|
return SCMO_OK; |
|
break; |
|
} |
|
case CIMTYPE_UINT32: |
|
{ |
|
kbValue.isSet=true; |
|
kbValue.data.simple.hasValue=true; |
|
kbValue.data.simple.val.u32=Uint32(keyValue->simple.val.u64); |
|
return SCMO_OK; |
|
break; |
|
} |
|
case CIMTYPE_UINT64: |
|
{ |
|
kbValue.isSet=true; |
|
kbValue.data.simple.hasValue=true; |
|
kbValue.data.simple.val.u64=keyValue->simple.val.u64; |
|
return SCMO_OK; |
|
break; |
|
} |
|
default: |
|
{ |
|
return SCMO_TYPE_MISSMATCH; |
|
break; |
|
} |
|
} |
|
} |
|
|
|
if (setType == CIMTYPE_SINT64) |
|
{ |
|
switch (classType) |
|
{ |
|
|
|
case CIMTYPE_SINT8: |
{ | { |
scmoKBV.data._char16Value = tmp[0]; |
kbValue.isSet=true; |
scmoKBV.isSet=true; |
kbValue.data.simple.hasValue=true; |
} |
kbValue.data.simple.val.s8=Sint8(keyValue->simple.val.s64); |
|
return SCMO_OK; |
break; | break; |
} | } |
case CIMTYPE_BOOLEAN: |
case CIMTYPE_SINT16: |
{ |
|
if (strncasecmp(v, "TRUE",len) == 0) |
|
{ | { |
scmoKBV.data._booleanValue = true; |
kbValue.isSet=true; |
scmoKBV.isSet=true; |
kbValue.data.simple.hasValue=true; |
|
kbValue.data.simple.val.s16=Sint16(keyValue->simple.val.s64); |
|
return SCMO_OK; |
|
break; |
} | } |
else if (strncasecmp(v, "FALSE",len) == 0) |
case CIMTYPE_SINT32: |
{ | { |
scmoKBV.data._booleanValue = false; |
kbValue.isSet=true; |
scmoKBV.isSet=true; |
kbValue.data.simple.hasValue=true; |
} |
kbValue.data.simple.val.s32=Sint32(keyValue->simple.val.s64); |
|
return SCMO_OK; |
break; | break; |
} | } |
|
case CIMTYPE_SINT64: |
case CIMTYPE_STRING: |
|
{ | { |
scmoKBV.isSet=true; |
kbValue.isSet=true; |
// Can cause reallocation ! |
kbValue.data.simple.hasValue=true; |
_setBinary(v,len,scmoKBV.data._stringValue,&inst.mem); |
kbValue.data.simple.val.s64=keyValue->simple.val.s64; |
return true; |
return SCMO_OK; |
break; | break; |
} | } |
case CIMTYPE_REFERENCE: |
default: |
{ | { |
|
return SCMO_TYPE_MISSMATCH; |
break; | break; |
} | } |
case CIMTYPE_OBJECT: |
|
case CIMTYPE_INSTANCE: |
|
// From PEP 194: EmbeddedObjects cannot be keys. |
|
throw TypeMismatchException(); |
|
break; |
|
} | } |
|
|
return scmoKBV.isSet; |
|
} | } |
| |
SCMO_RC SCMOInstance::_setKeyBindingFromString( |
if (setType == CIMTYPE_REAL64) |
const char* name, |
|
String cimKeyBinding) |
|
{ | { |
SCMO_RC rc; |
switch (classType) |
Uint32 node; |
|
|
|
if (NULL == name) |
|
{ | { |
return SCMO_INVALID_PARAMETER; |
case CIMTYPE_REAL32: |
} |
|
|
|
rc = inst.hdr->theClass->_getKeyBindingNodeIndex(node,name); |
|
if (rc != SCMO_OK) |
|
{ | { |
return rc; |
kbValue.isSet=true; |
|
kbValue.data.simple.hasValue=true; |
|
kbValue.data.simple.val.r32=Real32(keyValue->simple.val.r64); |
|
return SCMO_OK; |
|
break; |
} | } |
|
case CIMTYPE_REAL64: |
// create a pointer to keybinding node array of the class. |
|
Uint64 idx = inst.hdr->theClass->cls.hdr->keyBindingSet.nodeArray.start; |
|
SCMBKeyBindingNode* theClassKeyBindNodeArray = |
|
(SCMBKeyBindingNode*)&(inst.hdr->theClass->cls.base)[idx]; |
|
|
|
// create a pointer to instance keybinding values |
|
SCMBKeyBindingValue* theInstKeyBindValueArray = |
|
(SCMBKeyBindingValue*)&(inst.base[inst.hdr->keyBindingArray.start]); |
|
|
|
CString tmp = cimKeyBinding.getCString(); |
|
if ( _setCimKeyBindingStringToSCMOKeyBindigValue( |
|
(const char*)tmp, |
|
strlen((const char*)tmp), |
|
theClassKeyBindNodeArray[node].type, |
|
theInstKeyBindValueArray[node])) |
|
{ | { |
return SCMO_TYPE_MISSMATCH; |
kbValue.isSet=true; |
} |
kbValue.data.simple.hasValue=true; |
|
kbValue.data.simple.val.r64=keyValue->simple.val.r64; |
return SCMO_OK; | return SCMO_OK; |
|
break; |
} | } |
|
default: |
SCMO_RC SCMOInstance::setKeyBinding( |
|
const char* name, |
|
CIMType type, |
|
void* keyvalue) |
|
{ |
|
SCMO_RC rc; |
|
Uint32 node; |
|
|
|
if (NULL == name) |
|
{ | { |
return SCMO_INVALID_PARAMETER; |
return SCMO_TYPE_MISSMATCH; |
|
break; |
} | } |
|
|
rc = inst.hdr->theClass->_getKeyBindingNodeIndex(node,name); |
|
if (rc != SCMO_OK) |
|
{ |
|
return rc; |
|
} | } |
|
|
return setKeyBindingAt(node, type, keyvalue); |
|
} | } |
|
else |
SCMO_RC SCMOInstance::setKeyBindingAt( |
|
Uint32 node, |
|
CIMType type, |
|
void* keyvalue) |
|
{ | { |
SCMO_RC rc; |
switch (classType) |
|
|
// 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 == keyvalue) |
|
{ | { |
return SCMO_INVALID_PARAMETER; |
case CIMTYPE_BOOLEAN: |
} |
case CIMTYPE_UINT64: |
|
case CIMTYPE_SINT64: |
if (node >= inst.hdr->numberKeyBindings) |
case CIMTYPE_REAL64: |
|
case CIMTYPE_STRING: |
|
case CIMTYPE_REFERENCE: |
{ | { |
return SCMO_INDEX_OUT_OF_BOUND; |
kbValue.isSet=true; |
|
_setSCMBUnion(keyValue,classType,false, 0,kbValue.data); |
|
return SCMO_OK; |
|
break; |
} | } |
|
default: |
if (theClassKeyBindNodeArray[node].type != type) |
|
{ | { |
return SCMO_TYPE_MISSMATCH; | return SCMO_TYPE_MISSMATCH; |
|
break; |
|
} |
|
} |
} | } |
| |
SCMBKeyBindingValue* theInstKeyBindValueArray = |
return SCMO_TYPE_MISSMATCH; |
(SCMBKeyBindingValue*)&inst.base[inst.hdr->keyBindingArray.start]; |
|
|
|
|
|
// Has to be set first, |
|
// because reallocaton can take place in _setSCMBUnion() |
|
theInstKeyBindValueArray[node].isSet=true; |
|
|
|
_setSCMBUnion( |
|
keyvalue, |
|
type, |
|
false, // a key binding can never be an array. |
|
0, |
|
theInstKeyBindValueArray[node].data); |
|
| |
return SCMO_OK; |
|
} | } |
| |
| |
|
|
(Uint32*)&(inst.base[inst.hdr->propertyFilterIndexMap.start]); | (Uint32*)&(inst.base[inst.hdr->propertyFilterIndexMap.start]); |
| |
// All properties are accepted | // All properties are accepted |
if (propertyList == NULL) |
if (propertyList == 0) |
{ | { |
// Clear filtering: | // Clear filtering: |
// Switch filtering off. | // Switch filtering off. |
|
|
inst.hdr->filterProperties=_initPropFilterWithKeys(); | inst.hdr->filterProperties=_initPropFilterWithKeys(); |
| |
// add the properties to the filter. | // add the properties to the filter. |
while (propertyList[i] != NULL) |
while (propertyList[i] != 0) |
{ | { |
// the hash index of the property if the property name is found | // the hash index of the property if the property name is found |
rc = inst.hdr->theClass->_getProperyNodeIndex(node,propertyList[i]); | rc = inst.hdr->theClass->_getProperyNodeIndex(node,propertyList[i]); |
|
|
Uint64 *propertyFilter; | Uint64 *propertyFilter; |
| |
// Calculate the real pointer to the Uint64 array | // Calculate the real pointer to the Uint64 array |
propertyFilter = (Uint64*)&inst.base[inst.hdr->propertyFilter.start]; |
propertyFilter = (Uint64*)&(inst.base[inst.hdr->propertyFilter.start]); |
| |
// the number of Uint64 in the key mask is : | // the number of Uint64 in the key mask is : |
// Decrease the number of properties by 1 | // Decrease the number of properties by 1 |
|
|
Uint64 filter = ( (Uint64)1 << (i%64)); | Uint64 filter = ( (Uint64)1 << (i%64)); |
| |
// Calculate the real pointer to the Uint64 array | // Calculate the real pointer to the Uint64 array |
propertyFilter = (Uint64*)&inst.base[inst.hdr->propertyFilter.start]; |
propertyFilter = (Uint64*)&(inst.base[inst.hdr->propertyFilter.start]); |
| |
// If the bit is set the property is NOT filtered. | // If the bit is set the property is NOT filtered. |
// So the result has to be negated! | // So the result has to be negated! |
|
|
| |
} | } |
| |
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 = "."; |
} | } |
|
|
(insthdr->flags.includeClassOrigin ? "True" : "False")); | (insthdr->flags.includeClassOrigin ? "True" : "False")); |
fprintf(_out,"\n isFiltered: %s", | fprintf(_out,"\n isFiltered: %s", |
(insthdr->flags.isFiltered ? "True" : "False")); | (insthdr->flags.isFiltered ? "True" : "False")); |
|
fprintf(_out,"\n isClassOnly: %s", |
|
(insthdr->flags.isClassOnly ? "True" : "False")); |
|
fprintf(_out,"\n isCompromised: %s", |
|
(insthdr->flags.isCompromised ? "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))); |
| |
|
|
// create a pointer to keybinding node array of the class. | // create a pointer to keybinding node array of the class. |
Uint64 idx = insthdr->theClass->cls.hdr->keyBindingSet.nodeArray.start; | Uint64 idx = insthdr->theClass->cls.hdr->keyBindingSet.nodeArray.start; |
SCMBKeyBindingNode* theClassKeyBindNodeArray = | SCMBKeyBindingNode* theClassKeyBindNodeArray = |
(SCMBKeyBindingNode*)&(insthdr->theClass->cls.base)[idx]; |
(SCMBKeyBindingNode*)&((insthdr->theClass->cls.base)[idx]); |
| |
SCMBKeyBindingValue* ptr = | SCMBKeyBindingValue* ptr = |
(SCMBKeyBindingValue*) | (SCMBKeyBindingValue*) |
|
|
char* base) const | char* base) 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) |
{ | { |
|
|
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'", |
fprintf(_out,"\nThe values are: %s", |
(const char*)printArrayValue( | (const char*)printArrayValue( |
theValue.valueType, | theValue.valueType, |
theValue.valueArraySize, | theValue.valueArraySize, |
|
|
{ | { |
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(';'); |
} | } |
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(';'); |
|
} |
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(';'); |
|
} |
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(';'); |
|
} |
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(';'); |
|
} |
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(';'); |
|
} |
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(';'); |
|
} |
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(';'); |
|
} |
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(';'); |
|
} |
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(';'); |
|
} |
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(';'); |
|
} |
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(';'); |
|
} |
break; | break; |
} | } |
| |
case CIMTYPE_STRING: | case CIMTYPE_STRING: |
{ | { |
SCMBDataPtr* p = (SCMBDataPtr*)&(base[u._arrayValue.start]); |
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].length) |
{ | { |
|
out.append('\''); |
out.append((const char*)_getCharString(p[i],base), | out.append((const char*)_getCharString(p[i],base), |
p[i].length-1); | p[i].length-1); |
|
out.append('\''); |
} | } |
else | else |
{ | { |
out.append(' '); |
out << STRLIT("NULL;"); |
} | } |
out.append(' '); |
out.append(';'); |
} | } |
break; | break; |
} | } |
| |
case CIMTYPE_DATETIME: | case CIMTYPE_DATETIME: |
{ | { |
SCMBDateTime* p = (SCMBDateTime*)&(base[u._arrayValue.start]); |
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++) |
{ | { |
|
|
} | } |
| |
case CIMTYPE_REFERENCE: | case CIMTYPE_REFERENCE: |
{ |
|
break; |
|
} |
|
|
|
case CIMTYPE_OBJECT: | case CIMTYPE_OBJECT: |
{ |
|
break; |
|
} |
|
|
|
case CIMTYPE_INSTANCE: | case CIMTYPE_INSTANCE: |
{ | { |
|
// TODO: has to dump SCMOInstance ... |
break; | break; |
} | } |
default: | default: |
{ | { |
PEGASUS_ASSERT(0); |
PEGASUS_ASSERT(false); |
|
break; |
} | } |
} | } |
| |
|
|
{ | { |
case CIMTYPE_BOOLEAN: | case CIMTYPE_BOOLEAN: |
{ | { |
_toString(out,u._booleanValue); |
_toString(out,u.simple.val.bin); |
break; | break; |
} | } |
| |
case CIMTYPE_UINT8: | case CIMTYPE_UINT8: |
{ | { |
_toString(out,u._uint8Value); |
_toString(out,u.simple.val.u8); |
break; | break; |
} | } |
| |
case CIMTYPE_SINT8: | case CIMTYPE_SINT8: |
{ | { |
_toString(out,u._sint8Value); |
_toString(out,u.simple.val.s8); |
break; | break; |
} | } |
| |
case CIMTYPE_UINT16: | case CIMTYPE_UINT16: |
{ | { |
_toString(out,(Uint32)u._uint16Value); |
_toString(out,(Uint32)u.simple.val.u16); |
break; | break; |
} | } |
| |
case CIMTYPE_SINT16: | case CIMTYPE_SINT16: |
{ | { |
_toString(out,u._sint16Value); |
_toString(out,u.simple.val.s16); |
break; | break; |
} | } |
| |
case CIMTYPE_UINT32: | case CIMTYPE_UINT32: |
{ | { |
_toString(out,u._uint32Value); |
_toString(out,u.simple.val.u32); |
break; | break; |
} | } |
| |
case CIMTYPE_SINT32: | case CIMTYPE_SINT32: |
{ | { |
_toString(out,u._sint32Value); |
_toString(out,u.simple.val.s32); |
break; | break; |
} | } |
| |
case CIMTYPE_UINT64: | case CIMTYPE_UINT64: |
{ | { |
_toString(out,u._uint64Value); |
_toString(out,u.simple.val.u64); |
break; | break; |
} | } |
| |
case CIMTYPE_SINT64: | case CIMTYPE_SINT64: |
{ | { |
_toString(out,u._sint64Value); |
_toString(out,u.simple.val.s64); |
break; | break; |
} | } |
| |
case CIMTYPE_REAL32: | case CIMTYPE_REAL32: |
{ | { |
_toString(out,u._real32Value); |
_toString(out,u.simple.val.r32); |
break; | break; |
} | } |
| |
case CIMTYPE_REAL64: | case CIMTYPE_REAL64: |
{ | { |
_toString(out,u._real32Value); |
_toString(out,u.simple.val.r32); |
break; | break; |
} | } |
| |
case CIMTYPE_CHAR16: | case CIMTYPE_CHAR16: |
{ | { |
_toString(out,u._char16Value); |
_toString(out,u.simple.val.c16); |
break; | break; |
} | } |
| |
case CIMTYPE_STRING: | case CIMTYPE_STRING: |
{ | { |
if ( 0 != u._stringValue.length) |
if ( 0 != u.stringValue.length) |
{ | { |
out.append((const char*)_getCharString(u._stringValue,base), |
out.append((const char*)_getCharString(u.stringValue,base), |
u._stringValue.length-1); |
u.stringValue.length-1); |
} | } |
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); |
break; | break; |
} | } |
| |
case CIMTYPE_REFERENCE: | case CIMTYPE_REFERENCE: |
{ |
|
break; |
|
} |
|
|
|
case CIMTYPE_OBJECT: | case CIMTYPE_OBJECT: |
{ |
|
break; |
|
} |
|
|
|
case CIMTYPE_INSTANCE: | case CIMTYPE_INSTANCE: |
{ | { |
|
// TODO: Has to dump SCMOInstance. |
break; | break; |
} | } |
default: | default: |
{ | { |
PEGASUS_ASSERT(0); |
PEGASUS_ASSERT(false); |
|
break; |
} | } |
} | } |
| |
|
|
* The constant functions | * The constant functions |
*****************************************************************************/ | *****************************************************************************/ |
| |
/* |
|
static CIMKeyBinding::Type _cimTypeToKeyBindType(CIMType cimType) |
|
{ |
|
switch (cimType) |
|
{ |
|
case CIMTYPE_BOOLEAN: |
|
return(CIMKeyBinding::BOOLEAN); |
|
break; |
|
case CIMTYPE_CHAR16: |
|
case CIMTYPE_STRING: |
|
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; |
|
} |
|
} |
|
*/ |
|
/* OLD THILO VERSION |
|
static Boolean _equalUTF8Strings( |
|
const SCMBDataPtr& ptr_a, |
|
char* base, |
|
const char* name, |
|
Uint32 len) |
|
|
|
{ |
|
//both are empty strings, so they are equal. |
|
if (ptr_a.length == 0 && len == 0) |
|
{ |
|
return true; |
|
} |
|
|
|
// size without trailing '\0' !! |
|
if (ptr_a.length-1 != len) |
|
{ |
|
return false; |
|
} |
|
|
|
const char* a = (const char*)_getCharString(ptr_a,base); |
|
|
|
// ToDo: Here an UTF8 complinet comparison should take place |
|
return ( strncmp(a,name,len )== 0 ); |
|
|
|
} |
|
*/ |
|
|
|
static Boolean _equalUTF8Strings( | static Boolean _equalUTF8Strings( |
const SCMBDataPtr& ptr_a, | const SCMBDataPtr& ptr_a, |
char* base, | char* base, |
|
|
| |
const char* a = (const char*)_getCharString(ptr_a,base); | const char* a = (const char*)_getCharString(ptr_a,base); |
| |
// ToDo: Here an UTF8 complinet comparison should take place |
#ifdef PEGASUS_HAS_ICU |
|
return ( _utf8ICUncasecmp(a,name,len)== 0); |
|
#else |
return ( strncasecmp(a,name,len )== 0 ); | return ( strncasecmp(a,name,len )== 0 ); |
|
#endif |
|
} |
|
|
|
#ifdef PEGASUS_HAS_ICU |
|
static Uint32 _utf8ICUncasecmp( |
|
const char* a, |
|
const char* b, |
|
Uint32 len) |
|
{ |
|
UErrorCode errorCode=U_ZERO_ERROR; |
|
|
|
Uint32 rc, a16len,b16len,utf16BufLen; |
|
utf16BufLen = (len*sizeof(UChar))+2; |
|
|
|
UChar* a_UTF16 = (UChar*)malloc(utf16BufLen); |
|
UChar* b_UTF16 = (UChar*)malloc(utf16BufLen); |
|
|
|
UConverter *conv = ucnv_open(0, &errorCode); |
|
if(U_FAILURE(errorCode)) |
|
{ |
|
free(a_UTF16); |
|
free(b_UTF16); |
|
String message("SCMO::_utf8ICUncasecmp() ICUError: "); |
|
message.append(u_errorName(errorCode)); |
|
message.append(" Can not open ICU default converter!"); |
|
throw CIMException(CIM_ERR_FAILED,message ); |
|
} |
|
|
|
a16len = ucnv_toUChars(conv,a_UTF16,utf16BufLen,a,len,&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 convert string a:'"); |
|
message.append(String(a,len)); |
|
message.append('\''); |
|
throw CIMException(CIM_ERR_FAILED,message ); |
|
} |
|
|
|
b16len = ucnv_toUChars(conv,b_UTF16,utf16BufLen,b,len,&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 convert string b:'"); |
|
message.append(String(b,len)); |
|
message.append('\''); |
|
throw CIMException(CIM_ERR_FAILED,message ); |
|
} |
| |
|
rc = u_strCaseCompare( |
|
a_UTF16,a16len, |
|
b_UTF16,b16len, |
|
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 ); |
} | } |
| |
|
free(a_UTF16); |
|
free(b_UTF16); |
|
ucnv_close(conv); |
|
|
|
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. |
|
|
// 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); | (*pmem) = (SCMBMgmt_Header*)realloc((*pmem),oldSize*2); |
if ((*pmem) == NULL) |
if ((*pmem) == 0) |
{ | { |
// Not enough memory! | // Not enough memory! |
throw PEGASUS_STD(bad_alloc)(); | throw PEGASUS_STD(bad_alloc)(); |
|
|
{ | { |
| |
// If buffer is not empty. | // If buffer is not empty. |
if (bufferSize != 1) |
if (bufferSize != 1 && theBuffer != 0) |
{ | { |
| |
Uint64 start; | Uint64 start; |
|
|
} | } |
} | } |
| |
|
|
PEGASUS_NAMESPACE_END | PEGASUS_NAMESPACE_END |