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

Diff for /pegasus/src/Pegasus/Common/CIMParamValueRep.cpp between version 1.2 and 1.25

version 1.2, 2001/12/13 14:53:53 version 1.25, 2006/01/30 16:16:47
Line 1 
Line 1 
 //%/////////////////////////////////////////////////////////////////////////////  //%2006////////////////////////////////////////////////////////////////////////
 // //
 // Copyright (c) 2000, 2001 BMC Software, Hewlett-Packard Company, IBM,  // Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development
 // The Open Group, Tivoli Systems  // Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems.
   // Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L.P.;
   // IBM Corp.; EMC Corporation, The Open Group.
   // Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.;
   // IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group.
   // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;
   // EMC Corporation; VERITAS Software Corporation; The Open Group.
   // Copyright (c) 2006 Hewlett-Packard Development Company, L.P.; IBM Corp.;
   // EMC Corporation; Symantec Corporation; The Open Group.
 // //
 // Permission is hereby granted, free of charge, to any person obtaining a copy // Permission is hereby granted, free of charge, to any person obtaining a copy
 // of this software and associated documentation files (the "Software"), to // of this software and associated documentation files (the "Software"), to
Line 23 
Line 31 
 // //
 // Author: Nitin Upasani, Hewlett-Packard Company (Nitin_Upasani@hp.com) // Author: Nitin Upasani, Hewlett-Packard Company (Nitin_Upasani@hp.com)
 // //
 // Modified By:  // Modified By: Roger Kumpf, Hewlett-Packard Company (roger_kumpf@hp.com)
   //              Carol Ann Krug Graves, Hewlett-Packard Company
   //                  (carolann_graves@hp.com)
   //              David Dillard, VERITAS Software Corp.
   //                  (david.dillard@veritas.com)
 // //
 //%///////////////////////////////////////////////////////////////////////////// //%/////////////////////////////////////////////////////////////////////////////
  
   #include <Pegasus/Common/Config.h>
 #include <cstdio> #include <cstdio>
 #include "CIMParamValue.h"  
 #include "Indentor.h"  
 #include "CIMName.h"  
 #include "CIMScope.h"  
 #include "XmlWriter.h" #include "XmlWriter.h"
   #include "CIMParamValueRep.h"
   #include "StrLit.h"
  
 PEGASUS_NAMESPACE_BEGIN PEGASUS_NAMESPACE_BEGIN
  
 CIMParamValueRep::CIMParamValueRep( CIMParamValueRep::CIMParamValueRep(
     CIMParameter parameter,      String parameterName,
     CIMValue value,     CIMValue value,
     Boolean isArray,      Boolean isTyped)
     Uint32 arraySize,      : _parameterName(parameterName), _value(value), _isTyped(isTyped)
     const String& referenceClassName)  
     : _parameter(parameter), _value(value),  
     _isArray(isArray), _arraySize(arraySize),  
     _referenceClassName(referenceClassName)  
 { {
     if (_arraySize && !_isArray)      // ensure parameterName is not null
         throw IncompatibleTypes();      if(parameterName.size() == 0)
   
     if (referenceClassName.size())  
     {     {
         if (!CIMName::legal(referenceClassName))          throw UninitializedObjectException();
             throw IllegalName();  
     }     }
 } }
  
 CIMParamValueRep::~CIMParamValueRep() CIMParamValueRep::~CIMParamValueRep()
 { {
   
 } }
  
 void CIMParamValueRep::resolve(  //------------------------------------------------------------------------------
     DeclContext* declContext,  //
     const String& nameSpace)  //     <!ELEMENT PARAMVALUE (VALUE|VALUE.REFERENCE|VALUE.ARRAY|VALUE.REFARRAY)?>
   //     <!ATTLIST PARAMVALUE
   //         %CIMName;
   //         %EmbeddedObject; #IMPLIED
   //         %ParamType;>
   //
   //------------------------------------------------------------------------------
   void CIMParamValueRep::toXml(Buffer& out) const
 { {
     // Validate the qualifiers of the method (according to      out << STRLIT("<PARAMVALUE NAME=\"") << _parameterName;
     // superClass's method with the same name). This method      out.append('"');
     // will throw an exception if the validation fails.  
   
     CIMQualifierList dummy;  
  
     _qualifiers.resolve(      CIMType type = _value.getType();
         declContext,  
         nameSpace,  
         CIMScope::PARAMETER,  
         false,  
         dummy);  
 }  
  
 void CIMParamValueRep::toXml(Array<Sint8>& out) const      if (_isTyped)
 {  
     if (_isArray)  
     {     {
         out << " ARGUMENT.ARRAY";          // If the property type is CIMObject, then
           //   encode the property in CIM-XML as a string with the EMBEDDEDOBJECT attribute
         out << " PARAMETER_NAME=\"" << _parameter.getName() << "\"";          //   (there is not currently a CIM-XML "object" datatype)
           // else
         out << " PARAMETER_TYPE=\"" << TypeToString(_parameter.getType()) << "\"";          //   output the real type
           if (type == CIMTYPE_OBJECT)
         out << " VALUE=\"";  
         _value.toXml(out);  
         out << "\"";  
   
         if (_arraySize)  
         {         {
             char buffer[32];              out << STRLIT(" PARAMTYPE=\"string\" EMBEDDEDOBJECT=\"object\"");
             sprintf(buffer, "%d", _arraySize);  
             out << " ARRAYSIZE=\"" << buffer << "\"";  
         }  
   
         out << ">\n";  
   
         _qualifiers.toXml(out);  
   
         out << "</PARAMETER.ARRAY>\n";  
     }     }
     else     else
     {     {
         out << " ARGUMENT";              out << STRLIT(" PARAMTYPE=\"") << cimTypeToString (type);
         out << " PARAMETER.NAME=\"" << _parameter.getName() << "\"";              out.append('"');
         out << " PARAMETER.TYPE=\"" << TypeToString(_parameter.getType()) << "\"";  
         out << " PARAMETER.VALUE=\"";  
         _value.toXml(out);  
         out << "\"";  
         out << ">\n";  
         _qualifiers.toXml(out);  
         out << "</ARGUMENT>\n";  
     }  
 }  
   
 /** toMof - puts the Mof representation of the ParamValue object to  
     the output parameter array  
     The BNF for this conversion is:  
     parameterList    =  parameter *( "," parameter )  
   
         parameter    =  [ qualifierList ] (dataType|objectRef) parameterName  
                                 [ array ]  
   
         parameterName=  IDENTIFIER  
   
         array        =  "[" [positiveDecimalValue] "]"  
   
     Format on a single line.  
     */  
 void CIMParamValueRep::toMof(Array<Sint8>& out) const  
 {  
     // Output the qualifiers for the parameter  
     _qualifiers.toMof(out);  
   
     if (_qualifiers.getCount())  
         out << " ";  
   
     // Output the data parameter and value  
     out << _parameter.getName()  
         << " " << TypeToString(_parameter.getType())  
         << " ";  
     _value.toXml(out);  
   
     if (_isArray)  
     {  
         //Output the array indicator "[ [arraysize] ]"  
         if (_arraySize)  
         {  
             char buffer[32];  
             sprintf(buffer, "[%d]", _arraySize);  
             out << buffer;  
         }         }
         else  
             out << "[]";  
     }  
 }  
   
 void CIMParamValueRep::print(PEGASUS_STD(ostream) &os) const  
 {  
     Array<Sint8> tmp;  
     toXml(tmp);  
     tmp.append('\0');  
     os << tmp.getData() << PEGASUS_STD(endl);  
 } }
  
 Boolean CIMParamValueRep::identical(const CIMParamValueRep* x) const      out << STRLIT(">\n");
 {      XmlWriter::appendValueElement(out, _value);
     if (_parameter != x->_parameter)  
         return false;  
  
     if (_value != x->_value)      out << STRLIT("</PARAMVALUE>\n");
         return false;  
   
     if (_referenceClassName != x->_referenceClassName)  
         return false;  
   
     if (!_qualifiers.identical(x->_qualifiers))  
         return false;  
   
     return true;  
 } }
  
 CIMParamValueRep::CIMParamValueRep() CIMParamValueRep::CIMParamValueRep()
 { {
   
 } }
  
 CIMParamValueRep::CIMParamValueRep(const CIMParamValueRep& x) : CIMParamValueRep::CIMParamValueRep(const CIMParamValueRep& x) :
     Sharable(),     Sharable(),
     _parameter(x._parameter),      _parameterName(x._parameterName),
     _value(x._value),     _value(x._value),
     _isArray(x._isArray),      _isTyped(x._isTyped)
     _arraySize(x._arraySize),  
     _referenceClassName(x._referenceClassName)  
 { {
     x._qualifiers.cloneTo(_qualifiers);  
 } }
  
 CIMParamValueRep& CIMParamValueRep::operator=(const CIMParamValueRep& x)  void CIMParamValueRep::setParameterName(String& parameterName)
 { {
     return *this;      // ensure parameterName is not null
 }      if(parameterName.size() == 0)
   
 void CIMParamValueRep::setParameter(CIMParameter parameter)  
 { {
     _parameter = parameter;          throw UninitializedObjectException();
   
     if (_referenceClassName.size() == 0)  
     {  
         throw MissingReferenceClassName();  
     }     }
   
       _parameterName = parameterName;
 } }
  
 void CIMParamValueRep::setValue(CIMValue value)  void CIMParamValueRep::setValue(CIMValue& value)
 { {
     _value = value;     _value = value;
   }
  
     if (_referenceClassName.size() == 0)  void CIMParamValueRep::setIsTyped(Boolean isTyped)
     {     {
         throw MissingReferenceClassName();      _isTyped = isTyped;
     }  
 } }
  
 PEGASUS_NAMESPACE_END PEGASUS_NAMESPACE_END


Legend:
Removed from v.1.2  
changed lines
  Added in v.1.25

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2