(file) Return to SCMOXmlWriter.cpp CVS log (file) (dir) Up to [Pegasus] / pegasus / src / Pegasus / Common

Diff for /pegasus/src/Pegasus/Common/SCMOXmlWriter.cpp between version 1.1.2.6 and 1.4.2.9

version 1.1.2.6, 2009/10/14 10:12:39 version 1.4.2.9, 2013/10/17 19:13:47
Line 27 
Line 27 
 // //
 ////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
 // //
   // This code implements part of PEP#348 - The CMPI infrastructure using SCMO
   // (Single Chunk Memory Objects).
   // The design document can be found on the OpenPegasus website openpegasus.org
   // at https://collaboration.opengroup.org/pegasus/pp/documents/21210/PEP_348.pdf
   //
 //%///////////////////////////////////////////////////////////////////////////// //%/////////////////////////////////////////////////////////////////////////////
  
 #include <Pegasus/Common/Config.h> #include <Pegasus/Common/Config.h>
 #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);
           }
       }
   }
   
   // EXP_PULL_BEGIN
   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::appendValueInstanceWithPathElement(
                   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::appendValueInstanceWithPathElement(
                   out,
                   _scmoInstances[i],
                   true,
                   nodes);
           }
       }
   }
   //EXP_PULL_END
  
   // 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");
 } }
Line 53 
Line 195 
     const SCMOInstance& scmoInstance)     const SCMOInstance& scmoInstance)
 { {
     out << STRLIT("<INSTANCENAME CLASSNAME=\"");     out << STRLIT("<INSTANCENAME CLASSNAME=\"");
     Uint64 len;      Uint32 len;
     const char * className = scmoInstance.getClassName_l(len);     const char * className = scmoInstance.getClassName_l(len);
     out.append(className,len-1);      out.append(className,len);
     out << STRLIT("\">\n");      // TODO: check performance impact
       out.append('"','>','\n');
  
     for (Uint32 i = 0, n = scmoInstance.getKeyBindingCount(); i < n; i++)     for (Uint32 i = 0, n = scmoInstance.getKeyBindingCount(); i < n; i++)
     {     {
Line 65 
Line 208 
         CIMType kbType;         CIMType kbType;
         Uint32 kbNameLen;         Uint32 kbNameLen;
  
         scmoInstance._getKeyBindingDataAtNodeIndex(          SCMO_RC smrc = scmoInstance._getKeyBindingDataAtNodeIndex(
             i,             i,
             &kbName,             &kbName,
             kbNameLen,             kbNameLen,
Line 74 
Line 217 
  
         out << STRLIT("<KEYBINDING NAME=\"");         out << STRLIT("<KEYBINDING NAME=\"");
         out.append(kbName,kbNameLen-1);         out.append(kbName,kbNameLen-1);
         out << STRLIT("\">\n");          out.append('"','>','\n');
  
         if (kbType == CIMTYPE_REFERENCE)         if (kbType == CIMTYPE_REFERENCE)
         {         {
               if (SCMO_OK == smrc)
               {
             SCMOInstance * ref = kbValue->extRefPtr;             SCMOInstance * ref = kbValue->extRefPtr;
             appendValueReferenceElement(out, *ref, true);             appendValueReferenceElement(out, *ref, true);
         }         }
           }
         else         else
         {         {
             out << STRLIT("<KEYVALUE VALUETYPE=\"");             out << STRLIT("<KEYVALUE VALUETYPE=\"");
             out << xmlWriterKeyTypeStrings(kbType);             out << xmlWriterKeyTypeStrings(kbType);
             out << STRLIT("\">");              out.append('"','>');
  
               if (SCMO_OK == smrc)
               {
             SCMOXmlWriter::appendSCMBUnion(             SCMOXmlWriter::appendSCMBUnion(
                 out,                 out,
                 *kbValue,                 *kbValue,
                 kbType,                 kbType,
                 scmoInstance.inst.base);                 scmoInstance.inst.base);
               }
             out << STRLIT("</KEYVALUE>\n");             out << STRLIT("</KEYVALUE>\n");
         }         }
         out << STRLIT("</KEYBINDING>\n");         out << STRLIT("</KEYBINDING>\n");
Line 112 
Line 260 
 //------------------------------------------------------------------------------ //------------------------------------------------------------------------------
 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:
  
     out << STRLIT("<INSTANCE CLASSNAME=\"");     out << STRLIT("<INSTANCE CLASSNAME=\"");
     Uint64 len;      Uint32 len;
     const char * className = scmoInstance.getClassName_l(len);     const char * className = scmoInstance.getClassName_l(len);
     out.append(className,len-1);      out.append(className,len);
     out << STRLIT("\" >\n");      out.append('"',' ','>','\n');
       //out << STRLIT("\" >\n");
  
     // Append Instance Qualifiers:     // Append Instance Qualifiers:
     if (scmoInstance.inst.hdr->flags.includeQualifiers)     if (scmoInstance.inst.hdr->flags.includeQualifiers)
     {     {
         SCMBClass_Main *classMain=scmoInstance.inst.hdr->theClass->cls.hdr;          SCMBClass_Main *classMain=scmoInstance.inst.hdr->theClass.ptr->cls.hdr;
         char* clsbase = scmoInstance.inst.hdr->theClass->cls.base;          char* clsbase = scmoInstance.inst.hdr->theClass.ptr->cls.base;
  
         SCMBQualifier *theArray =         SCMBQualifier *theArray =
             (SCMBQualifier*)&(clsbase[classMain->qualifierArray.start]);             (SCMBQualifier*)&(clsbase[classMain->qualifierArray.start]);
Line 138 
Line 289 
     }     }
  
     // Append Properties:     // Append Properties:
     for (Uint32 i=0,k=scmoInstance.getPropertyCount();i<k;i++)      if(!filtered)
     {     {
         if (scmoInstance.inst.hdr->flags.isFiltered &&          for (Uint32 i=0,k=scmoInstance.inst.hdr->numberProperties;i<k;i++)
             !scmoInstance._isPropertyInFilter(i))  
         {         {
             // Property is filtered, ignore and go to next              SCMOXmlWriter::appendPropertyElement(out,scmoInstance,i);
             continue;          }
         }         }
         else         else
         {         {
             SCMOXmlWriter::appendPropertyElement(out,scmoInstance,i);          for (Uint32 i=0,k=nodes.size();i<k;i++)
           {
               SCMOXmlWriter::appendPropertyElement(out,scmoInstance,nodes[i]);
         }         }
     }     }
     // Instance closing element:     // Instance closing element:
Line 180 
Line 332 
         {         {
             out.append(             out.append(
                 &(base[theQualifier.userDefName.start]),                 &(base[theQualifier.userDefName.start]),
                 theQualifier.userDefName.length-1);                  theQualifier.userDefName.size-1);
         }         }
     }     }
     else     else
     {     {
         out << SCMOClass::qualifierNameStrLit(theQualifier.name);         out << SCMOClass::qualifierNameStrLit(theQualifier.name);
     }     }
       out.append('"',' ');
     out << STRLIT("\" ");      //out << STRLIT("\" ");
  
     // Append type     // Append type
     out << xmlWriterTypeStrings(theQualifier.value.valueType);     out << xmlWriterTypeStrings(theQualifier.value.valueType);
Line 202 
Line 354 
         out,         out,
         CIMFlavor(theQualifier.flavor));         CIMFlavor(theQualifier.flavor));
  
     out << STRLIT(">\n");      out.append('>','\n');
       //out << STRLIT(">\n");
     // append the value of the qualifier     // append the value of the qualifier
     SCMOXmlWriter::appendValueElement(out, theQualifier.value, base);     SCMOXmlWriter::appendValueElement(out, theQualifier.value, base);
  
Line 236 
Line 389 
 //              %Propagated;> //              %Propagated;>
 // //
 //------------------------------------------------------------------------------ //------------------------------------------------------------------------------
   
 void SCMOXmlWriter::appendPropertyElement( void SCMOXmlWriter::appendPropertyElement(
     Buffer& out,     Buffer& out,
     const SCMOInstance& scmoInstance,     const SCMOInstance& scmoInstance,
     Uint32 pos)     Uint32 pos)
 { {
     // Get most of the property data from the instance  
     const char* propertyName;  
     Uint32 propertyNameLen;  
     CIMType propertyType;     CIMType propertyType;
  
     // This is an absolute pointer at a SCMBValue     // This is an absolute pointer at a SCMBValue
Line 254 
Line 403 
     SCMBClassProperty * propertyDef;     SCMBClassProperty * propertyDef;
     // This is the absolute pointer at which the class info for the given     // This is the absolute pointer at which the class info for the given
     // instance starts     // instance starts
     const char* clsbase = scmoInstance.inst.hdr->theClass->cls.base;      const char* clsbase = scmoInstance.inst.hdr->theClass.ptr->cls.base;
  
     SCMO_RC rc = scmoInstance.getPropertyAt(      scmoInstance._getPropertyAt(
         pos,         pos,
         &propertyValue,         &propertyValue,
         &propertyValueBase,         &propertyValueBase,
Line 264 
Line 413 
  
     propertyType = propertyValue->valueType;     propertyType = propertyValue->valueType;
  
   
     if (propertyValue->flags.isArray)     if (propertyValue->flags.isArray)
     {     {
           Uint32 arraySize=propertyValue->valueArraySize;
   
         out << STRLIT("<PROPERTY.ARRAY NAME=\"");         out << STRLIT("<PROPERTY.ARRAY NAME=\"");
  
         out.append(         out.append(
             &(clsbase[propertyDef->name.start]),             &(clsbase[propertyDef->name.start]),
             propertyDef->name.length-1);              (propertyDef->name.size-1));
  
         out << STRLIT("\" ");          out.append('"',' ');
           //out << STRLIT("\" ");
         if (propertyType == CIMTYPE_OBJECT)         if (propertyType == CIMTYPE_OBJECT)
         {         {
 /*          TODO: Implement writing CIM_OBJECT  
             // If the property array type is CIMObject, then             // If the property array type is CIMObject, then
             //    encode the property in CIM-XML as a string array with the             //    encode the property in CIM-XML as a string array with the
             //    EmbeddedObject attribute (there is not currently a CIM-XML             //    EmbeddedObject attribute (there is not currently a CIM-XML
             //    "object" datatype)             //    "object" datatype)
   
             Array<CIMObject> a;  
             rep->getValue().get(a);  
             out << STRLIT(" TYPE=\"string\"");             out << STRLIT(" TYPE=\"string\"");
             // If the Embedded Object is an instance, always add the             // If the Embedded Object is an instance, always add the
             // EmbeddedObject attribute.             // EmbeddedObject attribute.
             if (a.size() > 0 && a[0].isInstance())              SCMOInstance * instPtr = propertyValue->value.extRefPtr;
               if ((0 != instPtr) &&
                       (arraySize > 0) &&
                           !(instPtr->inst.hdr->flags.isClassOnly))
             {             {
                 out << STRLIT(" EmbeddedObject=\"object\""                 out << STRLIT(" EmbeddedObject=\"object\""
                               " EMBEDDEDOBJECT=\"object\"");                               " EMBEDDEDOBJECT=\"object\"");
             }             }
 #ifndef PEGASUS_SNIA_INTEROP_COMPATIBILITY  
             else  
 #endif  
             {  
                 // Else the Embedded Object is a class, always add the  
                 // EmbeddedObject qualifier.  Note that if the macro  
                 // PEGASUS_SNIA_INTEROP_COMPATIBILITY is defined, then  
                 // the EmbeddedObject qualifier will always be added,  
                 // whether it's a class or an instance.  
                 if (rep->findQualifier(PEGASUS_QUALIFIERNAME_EMBEDDEDOBJECT)  
                    == PEG_NOT_FOUND)  
                 {  
                     // Note that addQualifiers() cannot be called on a const  
                     // CIMQualifierRep.In this case we really do want to add  
                     // the EmbeddedObject qualifier, so we cast away the  
                     // constness.  
                     CIMPropertyRep* tmpRep=const_cast<CIMPropertyRep*>(rep);  
                     tmpRep->addQualifier(  
                         CIMQualifier(PEGASUS_QUALIFIERNAME_EMBEDDEDOBJECT,  
                                      true));  
                 }  
             }  
 */  
         }         }
         else if (propertyType == CIMTYPE_INSTANCE)         else if (propertyType == CIMTYPE_INSTANCE)
         {         {
 /*          TODO: Implement writing embedded instance  
             // If the property array type is CIMInstance, then             // If the property array type is CIMInstance, then
             //   encode the property in CIM-XML as a string array with the             //   encode the property in CIM-XML as a string array with the
             //   EmbeddedObject attribute (there is not currently a CIM-XML             //   EmbeddedObject attribute (there is not currently a CIM-XML
             //   "instance" datatype)             //   "instance" datatype)
   
             Array<CIMInstance> a;  
             rep->getValue().get(a);  
             out << STRLIT(" TYPE=\"string\"");             out << STRLIT(" TYPE=\"string\"");
   
             // add the EmbeddedObject attribute             // add the EmbeddedObject attribute
             if (a.size() > 0)              if (arraySize > 0)
             {             {
                 out << STRLIT(" EmbeddedObject=\"instance\""                 out << STRLIT(" EmbeddedObject=\"instance\""
                               " EMBEDDEDOBJECT=\"instance\"");                               " EMBEDDEDOBJECT=\"instance\"");
   
                 // Note that if the macro PEGASUS_SNIA_INTEROP_COMPATIBILITY  
                 // is defined, then the EmbeddedInstance qualifier will be  
                 // added  
 # ifdef PEGASUS_SNIA_INTEROP_COMPATIBILITY  
                 if (rep->findQualifier(  
                         PEGASUS_QUALIFIERNAME_EMBEDDEDINSTANCE ==  
                         PEG_NOT_FOUND)  
                 {  
                     // Note that addQualifiers() cannot be called on a const  
                     // CIMQualifierRep.In this case we really do want to add  
                     // the EmbeddedInstance qualifier, so we cast away the  
                     // constness.  
   
                     // For now, we assume that all the embedded instances in  
                     // the array are of the same type  
                     CIMPropertyRep* tmpRep=const_cast<CIMPropertyRep*>(rep);  
                     tmpRep->addQualifier(CIMQualifier(  
                         PEGASUS_QUALIFIERNAME_EMBEDDEDINSTANCE,  
                         a[0].getClassName().getString()));  
                 }  
 # endif  
             }             }
 */  
         }         }
         else         else
         {         {
Line 364 
Line 463 
             out << xmlWriterTypeStrings(propertyType);             out << xmlWriterTypeStrings(propertyType);
         }         }
  
         Uint32 arraySize=propertyValue->valueArraySize;  
   
         if (0 != arraySize)         if (0 != arraySize)
         {         {
             out << STRLIT(" ARRAYSIZE=\"");             out << STRLIT(" ARRAYSIZE=\"");
Line 381 
Line 478 
                 out << STRLIT(" CLASSORIGIN=\"");                 out << STRLIT(" CLASSORIGIN=\"");
                 out.append(                 out.append(
                     &(clsbase[propertyDef->originClassName.start]),                     &(clsbase[propertyDef->originClassName.start]),
                     propertyDef->originClassName.length-1);                      (propertyDef->originClassName.size-1));
                 out.append('"');                 out.append('"');
             }             }
         }         }
Line 390 
Line 487 
             out << STRLIT(" PROPAGATED=\"true\"");             out << STRLIT(" PROPAGATED=\"true\"");
         }         }
  
         out << STRLIT(">\n");          out.append('>','\n');
           //out << STRLIT(">\n");
  
         // Append Instance Qualifiers:         // Append Instance Qualifiers:
         if (scmoInstance.inst.hdr->flags.includeQualifiers)         if (scmoInstance.inst.hdr->flags.includeQualifiers)
Line 407 
Line 505 
                     clsbase);                     clsbase);
             }             }
         }         }
   
         SCMOXmlWriter::appendValueElement(out,*propertyValue,propertyValueBase);         SCMOXmlWriter::appendValueElement(out,*propertyValue,propertyValueBase);
   
         out << STRLIT("</PROPERTY.ARRAY>\n");         out << STRLIT("</PROPERTY.ARRAY>\n");
     }     }
     else if (propertyType == CIMTYPE_REFERENCE)     else if (propertyType == CIMTYPE_REFERENCE)
Line 417 
Line 513 
         out << STRLIT("<PROPERTY.REFERENCE NAME=\"");         out << STRLIT("<PROPERTY.REFERENCE NAME=\"");
         out.append(         out.append(
             &(clsbase[propertyDef->name.start]),             &(clsbase[propertyDef->name.start]),
             propertyDef->name.length-1);              (propertyDef->name.size-1));
         out << STRLIT("\" ");          out.append('"',' ');
           //out << STRLIT("\" ");
  
         if (0 != propertyDef->refClassName.start)         if (0 != propertyDef->refClassName.start)
         {         {
             out << STRLIT(" REFERENCECLASS=\"");             out << STRLIT(" REFERENCECLASS=\"");
             out.append(             out.append(
                 &(clsbase[propertyDef->refClassName.start]),                 &(clsbase[propertyDef->refClassName.start]),
                 propertyDef->refClassName.length-1);                  (propertyDef->refClassName.size-1));
             out.append('"');             out.append('"');
         }         }
  
Line 436 
Line 533 
                 out << STRLIT(" CLASSORIGIN=\"");                 out << STRLIT(" CLASSORIGIN=\"");
                 out.append(                 out.append(
                     &(clsbase[propertyDef->originClassName.start]),                     &(clsbase[propertyDef->originClassName.start]),
                     propertyDef->originClassName.length-1);                      (propertyDef->originClassName.size-1));
                 out.append('"');                 out.append('"');
             }             }
         }         }
Line 444 
Line 541 
         {         {
             out << STRLIT(" PROPAGATED=\"true\"");             out << STRLIT(" PROPAGATED=\"true\"");
         }         }
         out << STRLIT(">\n");          out.append('>','\n');
           //out << STRLIT(">\n");
         // Append Instance Qualifiers:         // Append Instance Qualifiers:
         if (scmoInstance.inst.hdr->flags.includeQualifiers)         if (scmoInstance.inst.hdr->flags.includeQualifiers)
         {         {
Line 469 
Line 567 
  
         out.append(         out.append(
             &(clsbase[propertyDef->name.start]),             &(clsbase[propertyDef->name.start]),
             propertyDef->name.length-1);              (propertyDef->name.size-1));
  
         out << STRLIT("\" ");          out.append('"',' ');
           //out << STRLIT("\" ");
  
         if (scmoInstance.inst.hdr->flags.includeClassOrigin)         if (scmoInstance.inst.hdr->flags.includeClassOrigin)
         {         {
Line 480 
Line 579 
                 out << STRLIT(" CLASSORIGIN=\"");                 out << STRLIT(" CLASSORIGIN=\"");
                 out.append(                 out.append(
                     &(clsbase[propertyDef->originClassName.start]),                     &(clsbase[propertyDef->originClassName.start]),
                     propertyDef->originClassName.length-1);                      (propertyDef->originClassName.size-1));
                 out.append('"');                 out.append('"');
             }             }
         }         }
Line 491 
Line 590 
  
         if (propertyType == CIMTYPE_OBJECT)         if (propertyType == CIMTYPE_OBJECT)
         {         {
 /*          TODO: Implement writing Embedded Object  
             // If the property type is CIMObject, then             // If the property type is CIMObject, then
             //   encode the property in CIM-XML as a string with the             //   encode the property in CIM-XML as a string with the
             //   EmbeddedObject attribute (there is not currently a CIM-XML             //   EmbeddedObject attribute (there is not currently a CIM-XML
             //   "object" datatype)             //   "object" datatype)
   
             CIMObject a;  
             rep->getValue().get(a);  
             out << STRLIT(" TYPE=\"string\"");             out << STRLIT(" TYPE=\"string\"");
   
             // If the Embedded Object is an instance, always add the             // If the Embedded Object is an instance, always add the
             // EmbeddedObject attribute.             // EmbeddedObject attribute.
             if (a.isInstance())              SCMOInstance * a = propertyValue->value.extRefPtr;
               if (a && !(a->inst.hdr->flags.isClassOnly))
             {             {
                 out << STRLIT(" EmbeddedObject=\"object\""                 out << STRLIT(" EmbeddedObject=\"object\""
                               " EMBEDDEDOBJECT=\"object\"");                               " EMBEDDEDOBJECT=\"object\"");
             }             }
             // Else the Embedded Object is a class, always add the  
             // EmbeddedObject qualifier.  
 #ifndef PEGASUS_SNIA_INTEROP_COMPATIBILITY  
             else  
 #endif  
             {  
                 // Note that if the macro PEGASUS_SNIA_INTEROP_COMPATIBILITY  
                 // is defined, then the EmbeddedObject qualifier will always  
                 // be added, whether it's a class or an instance.  
                 if (rep->findQualifier(PEGASUS_QUALIFIERNAME_EMBEDDEDOBJECT)  
                     == PEG_NOT_FOUND)  
                 {  
                     // Note that addQualifiers() cannot be called on a const  
                     // CIMQualifierRep.  In this case we really do want to  
                     // add the EmbeddedObject qualifier, so we cast away the  
                     // constness.  
                     CIMPropertyRep* tmpRep=const_cast<CIMPropertyRep*>(rep);  
                     tmpRep->addQualifier(  
                         CIMQualifier(PEGASUS_QUALIFIERNAME_EMBEDDEDOBJECT,  
                                      true));  
                 }  
             }  
 */  
             }             }
             else if (propertyType == CIMTYPE_INSTANCE)             else if (propertyType == CIMTYPE_INSTANCE)
             {             {
 /*              TODO: Implement writing Embedded Instance  
                 CIMInstance a;  
                 rep->getValue().get(a);  
                 out << STRLIT(" TYPE=\"string\""                 out << STRLIT(" TYPE=\"string\""
                               " EmbeddedObject=\"instance\""                               " EmbeddedObject=\"instance\""
                               " EMBEDDEDOBJECT=\"instance\"");                               " EMBEDDEDOBJECT=\"instance\"");
   
 # ifdef PEGASUS_SNIA_INTEROP_COMPATIBILITY  
                 if (rep->findQualifier(PEGASUS_QUALIFIERNAME_EMBEDDEDOBJECT)  
                     == PEG_NOT_FOUND)  
                 {  
                     // Note that addQualifiers() cannot be called on a const  
                     // CIMQualifierRep.  In this case we really do want to add  
                     // the EmbeddedInstance qualifier, so we cast away the  
                     // constness.  
                     CIMPropertyRep* tmpRep = const_cast<CIMPropertyRep*>(rep);  
                     tmpRep->addQualifier(CIMQualifier(  
                         PEGASUS_QUALIFIERNAME_EMBEDDEDINSTANCE,  
                         a.getClassName().getString()));  
                 }  
 # endif  
 */  
         }         }
         else         else
         {         {
             out.append(' ');             out.append(' ');
             out << xmlWriterTypeStrings(propertyType);             out << xmlWriterTypeStrings(propertyType);
         }         }
         out << STRLIT(">\n");          out.append('>','\n');
           //out << STRLIT(">\n");
  
         // Append Instance Qualifiers:         // Append Instance Qualifiers:
         if (scmoInstance.inst.hdr->flags.includeQualifiers)         if (scmoInstance.inst.hdr->flags.includeQualifiers)
Line 617 
Line 671 
     else if (value.valueType == CIMTYPE_REFERENCE)     else if (value.valueType == CIMTYPE_REFERENCE)
     {     {
         SCMOInstance * ref = value.value.extRefPtr;         SCMOInstance * ref = value.value.extRefPtr;
           if (ref)
           {
         appendValueReferenceElement(out, *ref, true);         appendValueReferenceElement(out, *ref, true);
     }     }
       }
     else     else
     {     {
         out << STRLIT("<VALUE>");         out << STRLIT("<VALUE>");
Line 666 
Line 723 
         }         }
         else         else
         {         {
             Uint64 classNameLength=0;              Uint32 classNameLength=0;
             const char* className = ref.getClassName_l(classNameLength);             const char* className = ref.getClassName_l(classNameLength);
             appendClassNameElement(out, className, classNameLength-1);              appendClassNameElement(out, className, classNameLength);
         }         }
     }     }
     else     else
Line 700 
Line 757 
     const SCMOInstance& instancePath)     const SCMOInstance& instancePath)
 { {
     out << STRLIT("<LOCALINSTANCEPATH>\n");     out << STRLIT("<LOCALINSTANCEPATH>\n");
     Uint64 nsLength=0;      Uint32 nsLength=0;
     const char* ns=instancePath.getNameSpace_l(nsLength);     const char* ns=instancePath.getNameSpace_l(nsLength);
     appendLocalNameSpacePathElement(out, ns, nsLength-1);      appendLocalNameSpacePathElement(out, ns, nsLength);
     appendInstanceNameElement(out, instancePath);     appendInstanceNameElement(out, instancePath);
     out << STRLIT("</LOCALINSTANCEPATH>\n");     out << STRLIT("</LOCALINSTANCEPATH>\n");
 } }
Line 715 
Line 772 
 { {
     out << STRLIT("<INSTANCEPATH>\n");     out << STRLIT("<INSTANCEPATH>\n");
  
     Uint64 hostnameLength=0;      Uint32 hostnameLength=0;
     const char* hostname=instancePath.getHostName_l(hostnameLength);     const char* hostname=instancePath.getHostName_l(hostnameLength);
     Uint64 nsLength=0;      Uint32 nsLength=0;
     const char* ns=instancePath.getNameSpace_l(nsLength);     const char* ns=instancePath.getNameSpace_l(nsLength);
     appendNameSpacePathElement(out,hostname,hostnameLength-1,ns,nsLength-1);      appendNameSpacePathElement(out,hostname,hostnameLength,ns,nsLength);
  
     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);
   
           }
       }
   }
   
   //EXP_PULL_BEGIN
   //------------------------------------------------------------------------------
   //
   // 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");
   }
   //EXP_PULL_END
   
   // appendValueObjectWithPathElement()
   //     <!ELEMENT VALUE.OBJECTWITHPATH
   //         ((CLASSPATH,CLASS)|(INSTANCEPATH,INSTANCE))>
   void SCMOXmlWriter::appendValueObjectWithPathElement(
       Buffer& out,
       const SCMOInstance& objectWithPath,
       bool filtered,
       const Array<Uint32> & nodes)
   {
       out << STRLIT("<VALUE.OBJECTWITHPATH>\n");
   
       appendValueReferenceElement(out, objectWithPath, false);
       appendObjectElement(out, objectWithPath,filtered,nodes);
   
       out << STRLIT("</VALUE.OBJECTWITHPATH>\n");
   }
   
   // appendObjectElement()
   // May refer to a CLASS or an INSTANCE
   void SCMOXmlWriter::appendObjectElement(
       Buffer& out,
       const SCMOInstance& object,
       bool filtered,
       const Array<Uint32> & nodes)
   {
       if (object.inst.hdr->flags.isClassOnly)
       {
           appendClassElement(out, object);
       }
       else
       {
           appendInstanceElement(out, object,filtered,nodes);
       }
   }
   
   //------------------------------------------------------------------------------
   //
   // appendClassElement()
   //
   //     <!ELEMENT CLASS
   //         (QUALIFIER*,(PROPERTY|PROPERTY.ARRAY|PROPERTY.REFERENCE)*,METHOD*)>
   //     <!ATTLIST CLASS
   //         %CIMName;
   //         %SuperClass;>
   //
   //------------------------------------------------------------------------------
   
   void SCMOXmlWriter::appendClassElement(
       Buffer& out,
       const SCMOInstance& cimClass)
   {
   
       SCMBClass_Main* ptrClass = cimClass.inst.hdr->theClass.ptr->cls.hdr;
       const char* clsBase = cimClass.inst.hdr->theClass.ptr->cls.base;
   
       // Class opening element:
       out << STRLIT("<CLASS NAME=\"");
       out.append(
           &(clsBase[ptrClass->className.start]),
           (ptrClass->className.size-1));
   
       out.append('"',' ');
       if (0 != ptrClass->superClassName.start)
       {
           out << STRLIT(" SUPERCLASS=\"");
           out.append(
               &(clsBase[ptrClass->superClassName.start]),
               (ptrClass->superClassName.size-1));
           out.append('"',' ');
       }
       out.append('>','\n');
   
       // Append class qualifiers
       SCMBQualifier *theArray =
           (SCMBQualifier*)&(clsBase[ptrClass->qualifierArray.start]);
       for (Uint32 i=0, n=ptrClass->numberOfQualifiers;i<n;i++)
       {
           SCMOXmlWriter::appendQualifierElement(out,theArray[i],clsBase);
       }
   
       // Append Property definitions:
       for (Uint32 i=0,k=cimClass.getPropertyCount();i<k;i++)
       {
               SCMOXmlWriter::appendPropertyElement(out,cimClass,i);
       }
   
       // ATTN: No method definitions with SCMO today, so do nothing with them
       //       Actually this code does not serve a purpose, but is kept here
       //       for completeness.
   
       // Class closing element:
       out << STRLIT("</CLASS>\n");
   }
   
 // appendLocalClassPathElement() // appendLocalClassPathElement()
 //     <!ELEMENT LOCALCLASSPATH (LOCALNAMESPACEPATH, CLASSNAME)> //     <!ELEMENT LOCALCLASSPATH (LOCALNAMESPACEPATH, CLASSNAME)>
 void SCMOXmlWriter::appendLocalClassPathElement( void SCMOXmlWriter::appendLocalClassPathElement(
Line 732 
Line 947 
     const SCMOInstance& classPath)     const SCMOInstance& classPath)
 { {
     out << STRLIT("<LOCALCLASSPATH>\n");     out << STRLIT("<LOCALCLASSPATH>\n");
     Uint64 hostnameLength=0;      Uint32 hostnameLength=0;
     const char* hostname=classPath.getHostName_l(hostnameLength);     const char* hostname=classPath.getHostName_l(hostnameLength);
     Uint64 nsLength=0;      Uint32 nsLength=0;
     const char* ns=classPath.getNameSpace_l(nsLength);     const char* ns=classPath.getNameSpace_l(nsLength);
  
     appendNameSpacePathElement(out,hostname,hostnameLength-1,ns,nsLength-1);      appendNameSpacePathElement(out,hostname,hostnameLength,ns,nsLength);
  
     Uint64 classNameLength=0;      Uint32 classNameLength=0;
     const char* className = classPath.getClassName_l(classNameLength);     const char* className = classPath.getClassName_l(classNameLength);
     appendClassNameElement(out, className, classNameLength-1);      appendClassNameElement(out, className, classNameLength);
     out << STRLIT("</LOCALCLASSPATH>\n");     out << STRLIT("</LOCALCLASSPATH>\n");
 } }
  
Line 753 
Line 968 
 { {
     out << STRLIT("<CLASSPATH>\n");     out << STRLIT("<CLASSPATH>\n");
  
     Uint64 hostnameLength=0;      Uint32 hostnameLength=0;
     const char* hostname=classPath.getHostName_l(hostnameLength);     const char* hostname=classPath.getHostName_l(hostnameLength);
     Uint64 nsLength=0;      Uint32 nsLength=0;
     const char* ns=classPath.getNameSpace_l(nsLength);     const char* ns=classPath.getNameSpace_l(nsLength);
  
     appendNameSpacePathElement(out,hostname,hostnameLength,ns,nsLength);     appendNameSpacePathElement(out,hostname,hostnameLength,ns,nsLength);
  
     Uint64 classNameLength=0;      Uint32 classNameLength=0;
     const char* className = classPath.getClassName_l(classNameLength);     const char* className = classPath.getClassName_l(classNameLength);
  
     appendClassNameElement(out, className, classNameLength-1);      appendClassNameElement(out, className, classNameLength);
     out << STRLIT("</CLASSPATH>\n");     out << STRLIT("</CLASSPATH>\n");
 } }
  
Line 777 
Line 992 
     {     {
         case CIMTYPE_BOOLEAN:         case CIMTYPE_BOOLEAN:
         {         {
               if (u.simple.hasValue)
               {
             SCMOXmlWriter::append(out, u.simple.val.bin);             SCMOXmlWriter::append(out, u.simple.val.bin);
               }
             break;             break;
         }         }
  
         case CIMTYPE_UINT8:         case CIMTYPE_UINT8:
         {         {
               if (u.simple.hasValue)
               {
             SCMOXmlWriter::append(out, u.simple.val.u8);             SCMOXmlWriter::append(out, u.simple.val.u8);
               }
             break;             break;
         }         }
  
         case CIMTYPE_SINT8:         case CIMTYPE_SINT8:
         {         {
               if (u.simple.hasValue)
               {
             SCMOXmlWriter::append(out, u.simple.val.s8);             SCMOXmlWriter::append(out, u.simple.val.s8);
               }
             break;             break;
         }         }
  
         case CIMTYPE_UINT16:         case CIMTYPE_UINT16:
         {         {
               if (u.simple.hasValue)
               {
             SCMOXmlWriter::append(out, u.simple.val.u16);             SCMOXmlWriter::append(out, u.simple.val.u16);
               }
             break;             break;
         }         }
  
         case CIMTYPE_SINT16:         case CIMTYPE_SINT16:
         {         {
               if (u.simple.hasValue)
               {
             SCMOXmlWriter::append(out, u.simple.val.s16);             SCMOXmlWriter::append(out, u.simple.val.s16);
               }
             break;             break;
         }         }
  
         case CIMTYPE_UINT32:         case CIMTYPE_UINT32:
         {         {
               if (u.simple.hasValue)
               {
             SCMOXmlWriter::append(out, u.simple.val.u32);             SCMOXmlWriter::append(out, u.simple.val.u32);
               }
             break;             break;
         }         }
  
         case CIMTYPE_SINT32:         case CIMTYPE_SINT32:
         {         {
               if (u.simple.hasValue)
               {
             SCMOXmlWriter::append(out, u.simple.val.s32);             SCMOXmlWriter::append(out, u.simple.val.s32);
               }
             break;             break;
         }         }
  
         case CIMTYPE_UINT64:         case CIMTYPE_UINT64:
         {         {
               if (u.simple.hasValue)
               {
             SCMOXmlWriter::append(out, u.simple.val.u64);             SCMOXmlWriter::append(out, u.simple.val.u64);
               }
             break;             break;
         }         }
  
         case CIMTYPE_SINT64:         case CIMTYPE_SINT64:
         {         {
               if (u.simple.hasValue)
               {
             SCMOXmlWriter::append(out, u.simple.val.s64);             SCMOXmlWriter::append(out, u.simple.val.s64);
               }
             break;             break;
         }         }
  
         case CIMTYPE_REAL32:         case CIMTYPE_REAL32:
         {         {
               if (u.simple.hasValue)
               {
             SCMOXmlWriter::append(out, u.simple.val.r32);             SCMOXmlWriter::append(out, u.simple.val.r32);
               }
             break;             break;
         }         }
  
         case CIMTYPE_REAL64:         case CIMTYPE_REAL64:
         {         {
               if (u.simple.hasValue)
               {
             SCMOXmlWriter::append(out, u.simple.val.r64);             SCMOXmlWriter::append(out, u.simple.val.r64);
               }
             break;             break;
         }         }
  
         case CIMTYPE_CHAR16:         case CIMTYPE_CHAR16:
         {         {
               if (u.simple.hasValue)
               {
             SCMOXmlWriter::appendSpecial(             SCMOXmlWriter::appendSpecial(
                 out,                 out,
                 u.simple.val.c16);                      Char16(u.simple.val.c16));
               }
             break;             break;
         }         }
  
         case CIMTYPE_STRING:         case CIMTYPE_STRING:
         {         {
               if (u.stringValue.start)
               {
             SCMOXmlWriter::appendSpecial(             SCMOXmlWriter::appendSpecial(
                 out,                 out,
                 &(base[u.stringValue.start]),                 &(base[u.stringValue.start]),
                 u.stringValue.length-1);                      (u.stringValue.size-1));
               }
             break;             break;
         }         }
  
Line 863 
Line 1117 
             // an SCMBDateTime is a CIMDateTimeRep             // an SCMBDateTime is a CIMDateTimeRep
             // this should help us to reuse existing optimized Datetime             // this should help us to reuse existing optimized Datetime
             char buffer[26];             char buffer[26];
             _DateTimetoCStr(&(u.dateTimeValue), buffer);              _DateTimetoCStr(u.dateTimeValue, buffer);
             // datetime value is formatted with a \0 at end, ignore             // datetime value is formatted with a \0 at end, ignore
             out.append(buffer,sizeof(buffer)-1);             out.append(buffer,sizeof(buffer)-1);
             break;             break;
         }         }
 /*          // Object and Instance are both written the same way, namely as
           // object element which then is encoded using appendSpecial
         case CIMTYPE_OBJECT:         case CIMTYPE_OBJECT:
         {  
             CIMObject v;  
             value.get(v);  
             _xmlWritter_appendValue(out, v);  
             break;  
         }  
         case CIMTYPE_INSTANCE:         case CIMTYPE_INSTANCE:
         {         {
             CIMInstance v;              Buffer toEncodeObject(4000);
             value.get(v);              SCMOInstance * obj = u.extRefPtr;
             _xmlWritter_appendValue(out, v);              if (obj)
               {
                   appendObjectElement(toEncodeObject, *obj);
                   SCMOXmlWriter::appendSpecial(
                       out,
                       toEncodeObject.getData(),
                       toEncodeObject.size());
               }
             break;             break;
         }         }
         default:         default:
             PEGASUS_ASSERT(false);              // CIMTYPE_REFERENCE has been handled upfront, do nothing here
 */              break;
     }     }
 } }
  
Line 1058 
Line 1314 
             while (numElements--)             while (numElements--)
             {             {
                 out << STRLIT("<VALUE>");                 out << STRLIT("<VALUE>");
                 SCMOXmlWriter::append(out, arr->simple.val.bin);                  SCMOXmlWriter::appendSpecial(out, Char16(arr->simple.val.c16));
                 SCMOXmlWriter::appendSpecial(out, arr->simple.val.c16);  
                 arr++;                 arr++;
                 out << STRLIT("</VALUE>\n");                 out << STRLIT("</VALUE>\n");
             }             }
Line 1073 
Line 1328 
             while (numElements--)             while (numElements--)
             {             {
                 out << STRLIT("<VALUE>");                 out << STRLIT("<VALUE>");
                   if (0!=arr->stringValue.start)
                   {
                 SCMOXmlWriter::appendSpecial(                 SCMOXmlWriter::appendSpecial(
                     out,                     out,
                     &(base[arr->stringValue.start]),                     &(base[arr->stringValue.start]),
                     arr->stringValue.length-1);                          (arr->stringValue.size-1));
                   }
                 arr++;                 arr++;
                 out << STRLIT("</VALUE>\n");                 out << STRLIT("</VALUE>\n");
             }             }
Line 1094 
Line 1352 
                 out << STRLIT("<VALUE>");                 out << STRLIT("<VALUE>");
                 // an SCMBDateTime is a CIMDateTimeRep                 // an SCMBDateTime is a CIMDateTimeRep
                 // this should help us to reuse existing optimized Datetime                 // this should help us to reuse existing optimized Datetime
                 _DateTimetoCStr(&(arr->dateTimeValue), buffer);                  _DateTimetoCStr(arr->dateTimeValue, buffer);
                 // datetime value is formatted with a \0 at end, ignore                 // datetime value is formatted with a \0 at end, ignore
                 out.append(buffer,sizeof(buffer)-1);                 out.append(buffer,sizeof(buffer)-1);
                 arr++;                 arr++;
Line 1103 
Line 1361 
             out << STRLIT("</VALUE.ARRAY>\n");             out << STRLIT("</VALUE.ARRAY>\n");
             break;             break;
         }         }
 /*          case CIMTYPE_REFERENCE:
         case CIMTYPE_OBJECT:  
         {         {
             CIMObject v;              out << STRLIT("<VALUE.REFARRAY>\n");
             value.get(v);              while (numElements--)
             _xmlWritter_appendValue(out, v);              {
                   SCMOInstance * ref = arr->extRefPtr;
                   if (ref)
                   {
                       appendValueReferenceElement(out, *ref, true);
                   }
                   arr++;
               }
               out << STRLIT("</VALUE.REFARRAY>\n");
             break;             break;
         }         }
           case CIMTYPE_OBJECT:
         case CIMTYPE_INSTANCE:         case CIMTYPE_INSTANCE:
         {         {
             CIMInstance v;              out << STRLIT("<VALUE.ARRAY>\n");
             value.get(v);              Buffer toEncodeObject(4000);
             _xmlWritter_appendValue(out, v);              while (numElements--)
               {
                   toEncodeObject.clear();
                   out << STRLIT("<VALUE>");
                   SCMOInstance * obj = arr->extRefPtr;
                   if (obj)
                   {
                       appendObjectElement(toEncodeObject, *obj);
                       SCMOXmlWriter::appendSpecial(
                           out,
                           toEncodeObject.getData(),
                           toEncodeObject.size());
                   }
                   arr++;
                   out << STRLIT("</VALUE>\n");
               }
               out << STRLIT("</VALUE.ARRAY>\n");
             break;             break;
         }         }
         default:         default:
             PEGASUS_ASSERT(false);              PEGASUS_DEBUG_ASSERT(false);
 */  
     }     }
  
 } }


Legend:
Removed from v.1.1.2.6  
changed lines
  Added in v.1.4.2.9

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2