version 1.5.2.2, 2011/01/21 02:25:43
|
version 1.5.2.3, 2011/10/11 18:18:08
|
|
|
#define LOCAL_MIN(a, b) ((a < b) ? a : b) | #define LOCAL_MIN(a, b) ((a < b) ? a : b) |
// C++ objects interface handling | // C++ objects interface handling |
| |
|
void CIMResponseData::SVALID() |
|
{ |
|
PEGASUS_ASSERT(valid()); |
|
if (_size > 100000) |
|
{ |
|
PEG_TRACE((TRC_XML, Tracer::LEVEL4, |
|
"CIMResponseData::SVALID() _size too big ",_size )); |
|
PEGASUS_ASSERT(false); |
|
} |
|
PEG_TRACE((TRC_XML, Tracer::LEVEL4, |
|
"CIMResponseData Size _size=%u", _size)); |
|
Uint32 size = _size; |
|
} |
// Instance Names handling | // Instance Names handling |
Array<CIMObjectPath>& CIMResponseData::getInstanceNames() | Array<CIMObjectPath>& CIMResponseData::getInstanceNames() |
{ | { |
|
SVALID(); |
PEGASUS_DEBUG_ASSERT( | PEGASUS_DEBUG_ASSERT( |
(_dataType==RESP_INSTNAMES || _dataType==RESP_OBJECTPATHS)); | (_dataType==RESP_INSTNAMES || _dataType==RESP_OBJECTPATHS)); |
_resolveToCIM(); | _resolveToCIM(); |
|
|
// set an array of SCMOInstances into the response data object | // set an array of SCMOInstances into the response data object |
void CIMResponseData::setSCMO(const Array<SCMOInstance>& x) | void CIMResponseData::setSCMO(const Array<SCMOInstance>& x) |
{ | { |
|
SVALID(); |
_scmoInstances=x; | _scmoInstances=x; |
_encoding |= RESP_ENC_SCMO; | _encoding |= RESP_ENC_SCMO; |
_size += x.size(); | _size += x.size(); |
|
|
| |
bool CIMResponseData::setXml(CIMBuffer& in) | bool CIMResponseData::setXml(CIMBuffer& in) |
{ | { |
|
SVALID(); |
switch (_dataType) | switch (_dataType) |
{ | { |
case RESP_INSTANCE: | case RESP_INSTANCE: |
|
|
| |
// Return the number of CIM objects in the CIM Response data object | // Return the number of CIM objects in the CIM Response data object |
// | // |
|
#define TEMPLOG PEG_TRACE((TRC_XML, Tracer::LEVEL4, \ |
|
"rtnSize %u size %u", rtnSize, _size)) |
|
|
Uint32 CIMResponseData::size() | Uint32 CIMResponseData::size() |
{ | { |
PEG_METHOD_ENTER(TRC_XML,"CIMResponseData::size()"); | PEG_METHOD_ENTER(TRC_XML,"CIMResponseData::size()"); |
|
SVALID(); |
// If debug mode, add up all the individual size components to | // If debug mode, add up all the individual size components to |
// determine overall size of this object. Then compare this with | // determine overall size of this object. Then compare this with |
// the _size variable. this is a good check on the completeness of the | // the _size variable. this is a good check on the completeness of the |
|
|
PEGASUS_ASSERT(valid()); //KS_TEMP | PEGASUS_ASSERT(valid()); //KS_TEMP |
| |
Uint32 rtnSize = 0; | Uint32 rtnSize = 0; |
|
TEMPLOG; |
if (RESP_ENC_XML == (_encoding & RESP_ENC_XML)) | if (RESP_ENC_XML == (_encoding & RESP_ENC_XML)) |
{ | { |
|
TEMPLOG; |
switch (_dataType) | switch (_dataType) |
{ | { |
case RESP_OBJECTPATHS: | case RESP_OBJECTPATHS: |
|
|
rtnSize += _instanceData.size(); | rtnSize += _instanceData.size(); |
break; | break; |
} | } |
|
SVALID(); |
|
TEMPLOG; |
} | } |
if (RESP_ENC_BINARY == (_encoding & RESP_ENC_BINARY)) | if (RESP_ENC_BINARY == (_encoding & RESP_ENC_BINARY)) |
{ | { |
|
TEMPLOG; |
// KS_PULL_TODO | // KS_PULL_TODO |
// Cannot resolve this one without actually processing | // Cannot resolve this one without actually processing |
// the data since it is a stream. | // the data since it is a stream. |
rtnSize += 0; | rtnSize += 0; |
//PEGASUS_ASSERT(false); | //PEGASUS_ASSERT(false); |
|
TEMPLOG; |
} | } |
| |
if (RESP_ENC_SCMO == (_encoding & RESP_ENC_SCMO)) | if (RESP_ENC_SCMO == (_encoding & RESP_ENC_SCMO)) |
{ | { |
|
SVALID(); |
|
TEMPLOG; |
rtnSize += _scmoInstances.size(); | rtnSize += _scmoInstances.size(); |
|
TEMPLOG; |
} | } |
| |
if (RESP_ENC_CIM == (_encoding & RESP_ENC_CIM)) | if (RESP_ENC_CIM == (_encoding & RESP_ENC_CIM)) |
{ | { |
|
SVALID(); |
|
TEMPLOG; |
switch (_dataType) | switch (_dataType) |
{ | { |
case RESP_OBJECTPATHS: | case RESP_OBJECTPATHS: |
|
|
rtnSize += _objects.size(); | rtnSize += _objects.size(); |
break; | break; |
} | } |
|
SVALID(); |
|
TEMPLOG; |
} | } |
// Test of actual count against _size variable. | // Test of actual count against _size variable. |
if (rtnSize != _size) | if (rtnSize != _size) |
{ | { |
|
SVALID(); |
|
TEMPLOG; |
PEG_TRACE((TRC_XML, Tracer::LEVEL1, | PEG_TRACE((TRC_XML, Tracer::LEVEL1, |
"CIMResponseData::size ERROR. debug size mismatch." | "CIMResponseData::size ERROR. debug size mismatch." |
"Computed = %u. variable = %u",rtnSize, _size )); | "Computed = %u. variable = %u",rtnSize, _size )); |
// KS_TEMP | // KS_TEMP |
cout << "Size err " << rtnSize << " " << _size << endl; | cout << "Size err " << rtnSize << " " << _size << endl; |
|
TEMPLOG; |
} | } |
//PEGASUS_TEST_ASSERT(rtnSize == _size); | //PEGASUS_TEST_ASSERT(rtnSize == _size); |
#endif | #endif |
|
|
PEG_METHOD_ENTER(TRC_DISPATCHER, | PEG_METHOD_ENTER(TRC_DISPATCHER, |
"CIMResponseData::encodeBinaryResponse"); | "CIMResponseData::encodeBinaryResponse"); |
| |
|
SVALID(); |
|
|
// Need to do a complete job here by transferring all contained data | // Need to do a complete job here by transferring all contained data |
// into binary format and handing it out in the CIMBuffer | // into binary format and handing it out in the CIMBuffer |
// KS_TODO | // KS_TODO |
if (RESP_ENC_BINARY == (_encoding & RESP_ENC_BINARY)) | if (RESP_ENC_BINARY == (_encoding & RESP_ENC_BINARY)) |
{ | { |
|
PEGASUS_ASSERT(false); // KS_TEMP |
// Binary does NOT need a marker as it consists of C++ and SCMO | // Binary does NOT need a marker as it consists of C++ and SCMO |
const Array<Uint8>& data = _binaryData; | const Array<Uint8>& data = _binaryData; |
out.putBytes(data.getData(), data.size()); | out.putBytes(data.getData(), data.size()); |
|
|
p.setNameSpace(nsName); | p.setNameSpace(nsName); |
} | } |
} | } |
|
break; |
} | } |
case RESP_INSTANCES: | case RESP_INSTANCES: |
{ | { |
|
|
{ | { |
if (_instances.size() > 0) | if (_instances.size() > 0) |
{ | { |
XmlWriter::appendInstanceElement(out, _instances[0]); |
XmlWriter::appendInstanceElement( |
|
out, |
|
_instances[0], |
|
_includeQualifiers, |
|
_includeClassOrigin, |
|
_propertyList); |
} | } |
break; | break; |
} | } |
|
|
if (isPullResponse) | if (isPullResponse) |
{ | { |
XmlWriter::appendValueInstanceWithPathElement( | XmlWriter::appendValueInstanceWithPathElement( |
out, _instances[i]); |
out, |
|
_instances[i], |
|
_includeQualifiers, |
|
_includeClassOrigin, |
|
_propertyList); |
} | } |
else | else |
{ | { |
XmlWriter::appendValueNamedInstanceElement( | XmlWriter::appendValueNamedInstanceElement( |
out, _instances[i]); |
out, |
|
_instances[i], |
|
_includeQualifiers, |
|
_includeClassOrigin, |
|
_propertyList); |
} | } |
|
|
} | } |
break; | break; |
} | } |
|
|
{ | { |
CIMInstance x = (CIMInstance)_objects[i]; | CIMInstance x = (CIMInstance)_objects[i]; |
XmlWriter::appendValueInstanceWithPathElement( | XmlWriter::appendValueInstanceWithPathElement( |
out, x); |
out, x, |
|
_includeQualifiers, |
|
_includeClassOrigin, |
|
_propertyList); |
} | } |
else | else |
{ | { |
XmlWriter::appendValueObjectWithPathElement( | XmlWriter::appendValueObjectWithPathElement( |
out,_objects[i]); |
out, |
|
_objects[i], |
|
_includeQualifiers, |
|
_includeClassOrigin, |
|
_propertyList); |
} | } |
|
|
} | } |
break; | break; |
} | } |
|
|
SCMOXmlWriter::appendInstanceNameElement( | SCMOXmlWriter::appendInstanceNameElement( |
out, | out, |
_scmoInstances[i]); | _scmoInstances[i]); |
|
|
} | } |
break; | break; |
} | } |
|
|
{ | { |
if (_scmoInstances.size() > 0) | if (_scmoInstances.size() > 0) |
{ | { |
SCMOXmlWriter::appendInstanceElement(out,_scmoInstances[0]); |
if(_propertyList.isNull()) |
|
{ |
|
Array<Uint32> emptyNodes; |
|
SCMOXmlWriter::appendInstanceElement( |
|
out, |
|
_scmoInstances[0], |
|
false, |
|
emptyNodes); |
|
} |
|
else |
|
{ |
|
Array<propertyFilterNodesArray_t> propFilterNodesArrays; |
|
// This searches for an already created array of nodes, |
|
//if not found, creates it inside propFilterNodesArrays |
|
const Array<Uint32> & nodes= |
|
SCMOXmlWriter::getFilteredNodesArray( |
|
propFilterNodesArrays, |
|
_scmoInstances[0], |
|
_propertyList); |
|
SCMOXmlWriter::appendInstanceElement( |
|
out, |
|
_scmoInstances[0], |
|
true, |
|
nodes); |
|
} |
} | } |
break; | break; |
} | } |
case RESP_INSTANCES: | case RESP_INSTANCES: |
{ | { |
for (Uint32 i = 0, n = _scmoInstances.size(); i < n; i++) |
|
{ |
|
if (isPullResponse) | if (isPullResponse) |
{ | { |
SCMOXmlWriter::appendValueSCMOInstanceWithPathElement( |
SCMOXmlWriter::appendValueSCMOInstanceWithPathElements( |
out, _scmoInstances[i]); |
out, _scmoInstances, _propertyList); |
} | } |
else | else |
{ | { |
SCMOXmlWriter::appendValueSCMOInstanceElement( |
SCMOXmlWriter::appendValueSCMOInstanceElements( |
out, _scmoInstances[i]); |
out, _scmoInstances, _propertyList); |
} |
|
} | } |
|
|
break; | break; |
} | } |
case RESP_OBJECTS: | case RESP_OBJECTS: |
{ | { |
for (Uint32 i = 0; i < _scmoInstances.size(); i++) |
|
{ |
|
if (isPullResponse) | if (isPullResponse) |
{ | { |
SCMOXmlWriter::appendValueSCMOInstanceWithPathElement( |
SCMOXmlWriter::appendValueSCMOInstanceWithPathElements( |
out,_scmoInstances[i]); |
out,_scmoInstances, _propertyList); |
} | } |
else | else |
{ | { |
|
// KS_TODO why is this one named element rather than |
|
// elements |
SCMOXmlWriter::appendValueObjectWithPathElement( | SCMOXmlWriter::appendValueObjectWithPathElement( |
out, _scmoInstances[i]); |
out, _scmoInstances, _propertyList); |
} |
|
} | } |
|
|
break; | break; |
} | } |
case RESP_OBJECTPATHS: | case RESP_OBJECTPATHS: |
|
|
if (0 == _instances.size()) | if (0 == _instances.size()) |
{ | { |
_instances.append(CIMInstance()); | _instances.append(CIMInstance()); |
|
CIMInternalXmlEncoder::_putXMLInstance( |
|
out, |
|
_instances[0]); |
|
break; |
} | } |
CIMInternalXmlEncoder::_putXMLInstance(out, _instances[0]); |
CIMInternalXmlEncoder::_putXMLInstance( |
|
out, |
|
_instances[0], |
|
_includeQualifiers, |
|
_includeClassOrigin, |
|
_propertyList); |
break; | break; |
} | } |
case RESP_INSTANCES: | case RESP_INSTANCES: |
|
|
{ | { |
CIMInternalXmlEncoder::_putXMLNamedInstance( | CIMInternalXmlEncoder::_putXMLNamedInstance( |
out, | out, |
_instances[i]); |
_instances[i], |
|
_includeQualifiers, |
|
_includeClassOrigin, |
|
_propertyList); |
} | } |
break; | break; |
} | } |
|
|
out.putUint32(totalSize); | out.putUint32(totalSize); |
for (Uint32 i = 0; i < n; i++) | for (Uint32 i = 0; i < n; i++) |
{ | { |
CIMInternalXmlEncoder::_putXMLObject(out, _objects[i]); |
CIMInternalXmlEncoder::_putXMLObject( |
|
out, |
|
_objects[i], |
|
_includeQualifiers, |
|
_includeClassOrigin, |
|
_propertyList); |
} | } |
break; | break; |
} | } |
|
|
{ | { |
_scmoInstances.append(SCMOInstance()); | _scmoInstances.append(SCMOInstance()); |
} | } |
SCMOInternalXmlEncoder::_putXMLInstance(out, _scmoInstances[0]); |
SCMOInternalXmlEncoder::_putXMLInstance( |
|
out, |
|
_scmoInstances[0], |
|
_propertyList); |
break; | break; |
} | } |
case RESP_INSTANCES: | case RESP_INSTANCES: |
|
|
{ | { |
out.putUint32(n); | out.putUint32(n); |
} | } |
for (Uint32 i = 0; i < n; i++) |
|
{ |
|
SCMOInternalXmlEncoder::_putXMLNamedInstance( | SCMOInternalXmlEncoder::_putXMLNamedInstance( |
out, | out, |
_scmoInstances[i]); |
_scmoInstances, |
} |
_propertyList); |
break; | break; |
} | } |
case RESP_OBJECTS: | case RESP_OBJECTS: |
|
|
{ | { |
out.putUint32(n); | out.putUint32(n); |
} | } |
for (Uint32 i = 0; i < n; i++) |
|
{ |
|
SCMOInternalXmlEncoder::_putXMLObject( | SCMOInternalXmlEncoder::_putXMLObject( |
out, | out, |
_scmoInstances[i]); |
_scmoInstances, |
} |
_propertyList); |
break; | break; |
} | } |
// internal xml encoding of instance names and object paths not | // internal xml encoding of instance names and object paths not |
|
|
} | } |
} | } |
} | } |
|
|
} | } |
| |
void CIMResponseData::_resolveToCIM() | void CIMResponseData::_resolveToCIM() |
|
|
return _magic; | return _magic; |
} | } |
| |
|
void CIMResponseData::setRequestProperties( |
|
const Boolean includeQualifiers, |
|
const Boolean includeClassOrigin, |
|
const CIMPropertyList& propertyList) |
|
{ |
|
_includeQualifiers = includeQualifiers; |
|
_includeClassOrigin = includeClassOrigin; |
|
_propertyList = propertyList; |
|
} |
|
|
PEGASUS_NAMESPACE_END | PEGASUS_NAMESPACE_END |