version 1.3, 2002/01/28 15:26:48
|
version 1.23, 2005/10/31 17:39:11
|
|
|
//%///////////////////////////////////////////////////////////////////////////// |
//%2005//////////////////////////////////////////////////////////////////////// |
// | // |
// 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. |
// | // |
// 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 |
|
|
// | // |
// 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 <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" |
| |
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 << "<PARAMVALUE NAME=\"" << _parameterName << "\""; |
// superClass's method with the same name). This method |
|
// 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) |
// If the property type is CIMObject, then |
|
// encode the property in CIM-XML as a string with the EMBEDDEDOBJECT attribute |
|
// (there is not currently a CIM-XML "object" datatype) |
|
// else |
|
// output the real type |
|
if (type == CIMTYPE_OBJECT) |
{ | { |
out << " ARGUMENT.ARRAY"; |
out << " PARAMTYPE=\"string\""; |
|
out << " EMBEDDEDOBJECT=\"object\""; |
out << " PARAMETER_NAME=\"" << _parameter.getName() << "\""; |
|
|
|
out << " PARAMETER_TYPE=\"" << TypeToString(_parameter.getType()) << "\""; |
|
|
|
out << " VALUE=\""; |
|
_value.toXml(out); |
|
out << "\""; |
|
|
|
if (_arraySize) |
|
{ |
|
char buffer[32]; |
|
sprintf(buffer, "%d", _arraySize); |
|
out << " ARRAYSIZE=\"" << buffer << "\""; |
|
} |
|
|
|
out << ">\n"; |
|
|
|
_qualifiers.toXml(out); |
|
|
|
out << "</PARAMETER.ARRAY>\n"; |
|
} | } |
else | else |
{ | { |
out << " ARGUMENT"; |
out << " PARAMTYPE=\"" << cimTypeToString (type) << "\""; |
out << " PARAMETER.NAME=\"" << _parameter.getName() << "\""; |
|
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 |
out << ">\n"; |
the output parameter array |
XmlWriter::appendValueElement(out, _value); |
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 |
|
{ |
|
if (_parameter != x->_parameter) |
|
return false; |
|
|
|
if (_value != x->_value) |
|
return false; |
|
|
|
if (_referenceClassName != x->_referenceClassName) |
|
return false; |
|
|
|
if (!_qualifiers.identical(x->_qualifiers)) |
|
return false; |
|
| |
return true; |
out << "</PARAMVALUE>\n"; |
} | } |
| |
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) |
|
{ | { |
return *this; |
|
} | } |
| |
void CIMParamValueRep::setParameter(CIMParameter parameter) |
void CIMParamValueRep::setParameterName(String& parameterName) |
{ | { |
_parameter = parameter; |
// ensure parameterName is not null |
|
if(parameterName.size() == 0) |
if (_referenceClassName.size() == 0) |
|
{ | { |
throw MissingReferenceClassName(); |
throw UninitializedObjectException(); |
} | } |
|
|
|
_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 |