version 1.3.2.1, 2010/10/25 13:28:45
|
version 1.4.2.2, 2011/10/11 18:18:09
|
|
|
#include <cstdlib> | #include <cstdlib> |
#include <cstdio> | #include <cstdio> |
#include <Pegasus/Common/SCMOXmlWriter.h> | #include <Pegasus/Common/SCMOXmlWriter.h> |
|
#include "Tracer.h" |
| |
PEGASUS_NAMESPACE_BEGIN | PEGASUS_NAMESPACE_BEGIN |
|
void SCMOXmlWriter::buildPropertyFilterNodesArray( |
|
Array<Uint32> & nodes, |
|
const SCMOClass * classPtr, |
|
const CIMPropertyList & propertyList) |
|
{ |
|
for (Uint32 i=0,k=propertyList.size(); i<k; i++) |
|
{ |
|
Uint32 node = 0; |
|
const CIMName & name = propertyList[i]; |
|
SCMO_RC rc = |
|
classPtr->_getProperyNodeIndex( |
|
node, |
|
(const char *)name.getString().getCString()); |
|
if(rc == SCMO_OK) |
|
{ |
|
nodes.append(node); |
|
} |
|
} |
|
} |
|
|
|
const Array<Uint32> & SCMOXmlWriter::getFilteredNodesArray( |
|
Array<propertyFilterNodesArray_t> & propFilterNodesArrays, |
|
const SCMOInstance& scmoInstance, |
|
const CIMPropertyList & propertyList) |
|
{ |
|
//First see if the class ptr is already stored in the propFilterNodesArrays |
|
const SCMOClass * classPtr = scmoInstance.inst.hdr->theClass.ptr; |
|
SCMBClass_Main * classPtrMemBlock = classPtr->cls.hdr; |
|
for (int i=0, k=propFilterNodesArrays.size(); i < k; i++) |
|
{ |
|
if (classPtrMemBlock == propFilterNodesArrays[i].classPtrMemBlock) |
|
{ |
|
return propFilterNodesArrays[i].nodes; |
|
} |
|
} |
|
|
|
// Could not find the class pointer of this SCMOInstance in the |
|
// property filter nodes array |
|
// --> need to create the new entry and return that |
|
propertyFilterNodesArray_t newEntry; |
|
newEntry.classPtrMemBlock = classPtrMemBlock; |
|
SCMOXmlWriter::buildPropertyFilterNodesArray( |
|
newEntry.nodes, |
|
classPtr, |
|
propertyList); |
|
propFilterNodesArrays.append(newEntry); |
|
|
|
// return the new nodes entry, but as a reference into the array |
|
return propFilterNodesArrays[propFilterNodesArrays.size()-1].nodes; |
|
} |
|
|
|
void SCMOXmlWriter::appendValueSCMOInstanceElements( |
|
Buffer& out, |
|
const Array<SCMOInstance> & _scmoInstances, |
|
const CIMPropertyList & propertyList) |
|
{ |
|
if (propertyList.isNull()) |
|
{ |
|
Array<Uint32> emptyNodes; |
|
for (Uint32 i = 0, n = _scmoInstances.size(); i < n; i++) |
|
{ |
|
SCMOXmlWriter::appendValueSCMOInstanceElement( |
|
out, |
|
_scmoInstances[i], |
|
false, |
|
emptyNodes); |
|
} |
|
} |
|
else |
|
{ |
|
Array<propertyFilterNodesArray_t> propFilterNodesArrays; |
| |
|
for (Uint32 i = 0, n = _scmoInstances.size(); i < n; i++) |
|
{ |
|
// This searches for an already created array of nodes, |
|
// if not found, creates it inside propFilterNodesArrays |
|
const Array<Uint32> & nodes= |
|
SCMOXmlWriter::getFilteredNodesArray( |
|
propFilterNodesArrays, |
|
_scmoInstances[i], |
|
propertyList); |
|
|
|
SCMOXmlWriter::appendValueSCMOInstanceElement( |
|
out, |
|
_scmoInstances[i], |
|
true, |
|
nodes); |
|
} |
|
} |
|
} |
|
|
|
void SCMOXmlWriter::appendValueSCMOInstanceWithPathElements( |
|
Buffer& out, |
|
const Array<SCMOInstance> & _scmoInstances, |
|
const CIMPropertyList & propertyList) |
|
{ |
|
if (propertyList.isNull()) |
|
{ |
|
Array<Uint32> emptyNodes; |
|
for (Uint32 i = 0, n = _scmoInstances.size(); i < n; i++) |
|
{ |
|
SCMOXmlWriter::appendValueSCMOInstanceWithPathElement( |
|
out, |
|
_scmoInstances[i], |
|
false, |
|
emptyNodes); |
|
} |
|
} |
|
else |
|
{ |
|
Array<propertyFilterNodesArray_t> propFilterNodesArrays; |
|
|
|
for (Uint32 i = 0, n = _scmoInstances.size(); i < n; i++) |
|
{ |
|
// This searches for an already created array of nodes, |
|
// if not found, creates it inside propFilterNodesArrays |
|
const Array<Uint32> & nodes= |
|
SCMOXmlWriter::getFilteredNodesArray( |
|
propFilterNodesArrays, |
|
_scmoInstances[i], |
|
propertyList); |
|
|
|
SCMOXmlWriter::appendValueSCMOInstanceWithPathElement( |
|
out, |
|
_scmoInstances[i], |
|
true, |
|
nodes); |
|
} |
|
} |
|
} |
|
|
|
// KS_TODO - Show the XML statement for this function |
void SCMOXmlWriter::appendValueSCMOInstanceElement( | void SCMOXmlWriter::appendValueSCMOInstanceElement( |
Buffer& out, | Buffer& out, |
const SCMOInstance& scmoInstance) |
const SCMOInstance& scmoInstance, |
|
bool filtered, |
|
const Array<Uint32> & nodes) |
{ | { |
out << STRLIT("<VALUE.NAMEDINSTANCE>\n"); | out << STRLIT("<VALUE.NAMEDINSTANCE>\n"); |
| |
appendInstanceNameElement(out, scmoInstance); | appendInstanceNameElement(out, scmoInstance); |
appendInstanceElement(out, scmoInstance); |
appendInstanceElement(out, scmoInstance,filtered,nodes); |
| |
out << STRLIT("</VALUE.NAMEDINSTANCE>\n"); | out << STRLIT("</VALUE.NAMEDINSTANCE>\n"); |
} | } |
| |
|
//------------------------------------------------------------------------------ |
|
// |
|
// appendValueInstanceWithPathElement() -- Pull Operation support |
|
// |
|
// <!ELEMENT VALUE.INSTANCEWITHPATH (INSTANCEPATH,INSTANCE)> |
|
// |
|
//------------------------------------------------------------------------------ |
|
|
|
// KS_TODO - Double check to be sure this not duplication |
|
void SCMOXmlWriter::appendValueSCMOInstanceWithPathElement( |
|
Buffer& out, |
|
const SCMOInstance& scmoInstance, |
|
bool filtered, |
|
const Array<Uint32> & nodes) |
|
{ |
|
out << STRLIT("<VALUE.INSTANCEWITHPATH>\n"); |
|
|
|
appendInstancePathElement(out,scmoInstance); |
|
appendInstanceElement(out, scmoInstance, filtered, nodes); |
|
|
|
out << STRLIT("</VALUE.INSTANCEWITHPATH>\n"); |
|
} |
|
|
void SCMOXmlWriter::appendInstanceNameElement( | void SCMOXmlWriter::appendInstanceNameElement( |
Buffer& out, | Buffer& out, |
const SCMOInstance& scmoInstance) | const SCMOInstance& scmoInstance) |
|
|
//------------------------------------------------------------------------------ | //------------------------------------------------------------------------------ |
void SCMOXmlWriter::appendInstanceElement( | void SCMOXmlWriter::appendInstanceElement( |
Buffer& out, | Buffer& out, |
const SCMOInstance& scmoInstance) |
const SCMOInstance& scmoInstance, |
|
bool filtered, |
|
const Array<Uint32> & nodes) |
{ | { |
// Class opening element: | // Class opening element: |
| |
|
|
} | } |
| |
// Append Properties: | // Append Properties: |
// getPropertyCount() returns number of properties, only non-filtered ones |
if(!filtered) |
for (Uint32 i=0,k=scmoInstance.getPropertyCount();i<k;i++) |
{ |
|
for (Uint32 i=0,k=scmoInstance.inst.hdr->numberProperties;i<k;i++) |
{ | { |
// function _getPropertyAt() used by appendPropertyElement |
|
// translates the filter position of a property into the real one |
|
// for us |
|
SCMOXmlWriter::appendPropertyElement(out,scmoInstance,i); | SCMOXmlWriter::appendPropertyElement(out,scmoInstance,i); |
} | } |
|
} |
|
else |
|
{ |
|
for (Uint32 i=0,k=nodes.size();i<k;i++) |
|
{ |
|
SCMOXmlWriter::appendPropertyElement(out,scmoInstance,nodes[i]); |
|
} |
|
} |
// Instance closing element: | // Instance closing element: |
out << STRLIT("</INSTANCE>\n"); | out << STRLIT("</INSTANCE>\n"); |
} | } |
|
|
appendInstanceNameElement(out, instancePath); | appendInstanceNameElement(out, instancePath); |
out << STRLIT("</INSTANCEPATH>\n"); | out << STRLIT("</INSTANCEPATH>\n"); |
} | } |
|
void SCMOXmlWriter::appendValueObjectWithPathElement( |
|
Buffer& out, |
|
const Array<SCMOInstance> & objectWithPath, |
|
const CIMPropertyList& propertyList) |
|
{ |
|
if (propertyList.isNull()) |
|
{ |
|
Array<Uint32> emptyNodes; |
|
for (Uint32 i = 0, n = objectWithPath.size(); i < n; i++) |
|
{ |
|
SCMOXmlWriter::appendValueObjectWithPathElement( |
|
out, |
|
objectWithPath[i], |
|
false, |
|
emptyNodes); |
|
} |
|
} |
|
else |
|
{ |
|
Array<propertyFilterNodesArray_t> propFilterNodesArrays; |
|
for (Uint32 i = 0, n = objectWithPath.size(); i < n; i++) |
|
{ |
|
// This searches for an already created array of nodes, |
|
// if not found, creates it inside propFilterNodesArrays |
|
const Array<Uint32> & nodes= |
|
SCMOXmlWriter::getFilteredNodesArray( |
|
propFilterNodesArrays, |
|
objectWithPath[i], |
|
propertyList); |
|
SCMOXmlWriter::appendValueObjectWithPathElement( |
|
out, |
|
objectWithPath[i], |
|
true, |
|
nodes); |
|
|
|
} |
|
} |
|
} |
|
|
|
//------------------------------------------------------------------------------ |
|
// |
|
// appendValueInstanceWithPathElement() |
|
// |
|
// <!ELEMENT VALUE.INSTANCEWITHPATH (INSTANCEPATH,INSTANCE)> |
|
// |
|
//------------------------------------------------------------------------------ |
|
// EXP_PULL_TBD checkout the INSTANCEPATH vs NAMEDINSTANCE differences |
|
// Can we create something more common |
|
void SCMOXmlWriter::appendValueInstanceWithPathElement( |
|
Buffer& out, |
|
const SCMOInstance& namedInstance, |
|
bool filtered, |
|
const Array<Uint32> & nodes) |
|
{ |
|
out << STRLIT("<VALUE.INSTANCEWITHPATH>\n"); |
|
|
|
appendInstancePathElement(out, namedInstance); |
|
appendInstanceElement(out, namedInstance, filtered, nodes); |
|
|
|
out << STRLIT("</VALUE.INSTANCEWITHPATH>\n"); |
|
} |
| |
// appendValueObjectWithPathElement() | // appendValueObjectWithPathElement() |
// <!ELEMENT VALUE.OBJECTWITHPATH | // <!ELEMENT VALUE.OBJECTWITHPATH |
// ((CLASSPATH,CLASS)|(INSTANCEPATH,INSTANCE))> | // ((CLASSPATH,CLASS)|(INSTANCEPATH,INSTANCE))> |
void SCMOXmlWriter::appendValueObjectWithPathElement( | void SCMOXmlWriter::appendValueObjectWithPathElement( |
Buffer& out, | Buffer& out, |
const SCMOInstance& objectWithPath) |
const SCMOInstance& objectWithPath, |
|
bool filtered, |
|
const Array<Uint32> & nodes) |
{ | { |
out << STRLIT("<VALUE.OBJECTWITHPATH>\n"); | out << STRLIT("<VALUE.OBJECTWITHPATH>\n"); |
| |
appendValueReferenceElement(out, objectWithPath, false); | appendValueReferenceElement(out, objectWithPath, false); |
appendObjectElement(out, objectWithPath); |
appendObjectElement(out, objectWithPath,filtered,nodes); |
| |
out << STRLIT("</VALUE.OBJECTWITHPATH>\n"); | out << STRLIT("</VALUE.OBJECTWITHPATH>\n"); |
} | } |
|
|
// May refer to a CLASS or an INSTANCE | // May refer to a CLASS or an INSTANCE |
void SCMOXmlWriter::appendObjectElement( | void SCMOXmlWriter::appendObjectElement( |
Buffer& out, | Buffer& out, |
const SCMOInstance& object) |
const SCMOInstance& object, |
|
bool filtered, |
|
const Array<Uint32> & nodes) |
{ | { |
if (object.inst.hdr->flags.isClassOnly) | if (object.inst.hdr->flags.isClassOnly) |
{ | { |
|
|
} | } |
else | else |
{ | { |
appendInstanceElement(out, object); |
appendInstanceElement(out, object,filtered,nodes); |
} | } |
} | } |
| |
|
|
arr++; | arr++; |
} | } |
out << STRLIT("</VALUE.REFARRAY>\n"); | out << STRLIT("</VALUE.REFARRAY>\n"); |
|
break; |
} | } |
case CIMTYPE_OBJECT: | case CIMTYPE_OBJECT: |
case CIMTYPE_INSTANCE: | case CIMTYPE_INSTANCE: |