version 1.36.2.2, 2005/09/30 20:35:55
|
version 1.46, 2008/03/05 21:31:45
|
|
|
//%2005//////////////////////////////////////////////////////////////////////// |
//%2006//////////////////////////////////////////////////////////////////////// |
// | // |
// Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development | // Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development |
// Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems. | // Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems. |
|
|
// IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group. | // IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group. |
// Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.; | // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.; |
// EMC Corporation; VERITAS Software Corporation; The Open Group. | // 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 |
|
|
// | // |
//============================================================================== | //============================================================================== |
// | // |
// Author: Mike Brasher (mbrasher@bmc.com) |
|
// |
|
// Modified By: 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 "CIMParameter.h" | #include "CIMParameter.h" |
#include "CIMParameterRep.h" | #include "CIMParameterRep.h" |
#include "Indentor.h" |
|
#include "CIMName.h" | #include "CIMName.h" |
#include "CIMScope.h" | #include "CIMScope.h" |
#include "XmlWriter.h" |
#include "StrLit.h" |
| |
PEGASUS_NAMESPACE_BEGIN | PEGASUS_NAMESPACE_BEGIN |
| |
CIMParameterRep::CIMParameterRep() |
|
{ |
|
} |
|
|
|
CIMParameterRep::CIMParameterRep(const CIMParameterRep& x) : | CIMParameterRep::CIMParameterRep(const CIMParameterRep& x) : |
Sharable(), | Sharable(), |
_name(x._name), | _name(x._name), |
_type(x._type), | _type(x._type), |
_isArray(x._isArray), | _isArray(x._isArray), |
_arraySize(x._arraySize), | _arraySize(x._arraySize), |
_referenceClassName(x._referenceClassName) |
_referenceClassName(x._referenceClassName), |
|
_ownerCount(0) |
{ | { |
x._qualifiers.cloneTo(_qualifiers); | x._qualifiers.cloneTo(_qualifiers); |
|
// Set the CIM name tag. |
|
_nameTag = generateCIMNameTag(_name); |
} | } |
| |
CIMParameterRep::CIMParameterRep( | CIMParameterRep::CIMParameterRep( |
|
|
const CIMName& referenceClassName) | const CIMName& referenceClassName) |
: _name(name), _type(type), | : _name(name), _type(type), |
_isArray(isArray), _arraySize(arraySize), | _isArray(isArray), _arraySize(arraySize), |
_referenceClassName(referenceClassName) |
_referenceClassName(referenceClassName), |
|
_ownerCount(0) |
{ | { |
// ensure name is not null | // ensure name is not null |
if(name.isNull()) | if(name.isNull()) |
{ | { |
throw UninitializedObjectException(); | throw UninitializedObjectException(); |
} | } |
|
// Set the CIM name tag. |
|
_nameTag = generateCIMNameTag(_name); |
| |
if((_arraySize != 0) && !_isArray) | if((_arraySize != 0) && !_isArray) |
{ | { |
|
|
{ | { |
throw UninitializedObjectException(); | throw UninitializedObjectException(); |
} | } |
|
if (_ownerCount != 0 && _name != name) |
|
{ |
|
MessageLoaderParms parms( |
|
"Common.CIMParameterRep.CONTAINED_PARAMETER_NAMECHANGEDEXCEPTION", |
|
"Attempted to change the name of a parameter" |
|
" already in a container."); |
|
throw Exception(parms); |
|
} |
_name = name; | _name = name; |
|
// Set the CIM name tag. |
|
_nameTag = generateCIMNameTag(_name); |
} | } |
| |
void CIMParameterRep::removeQualifier(Uint32 index) | void CIMParameterRep::removeQualifier(Uint32 index) |
|
|
true); | true); |
} | } |
| |
void CIMParameterRep::toXml(Buffer& out) const |
Boolean CIMParameterRep::identical(const CIMParameterRep* x) const |
{ |
|
if (_isArray) |
|
{ |
|
if (_type == CIMTYPE_REFERENCE) |
|
{ |
|
out << LIT("<PARAMETER.REFARRAY"); |
|
out << LIT(" NAME=\"") << _name; |
|
out.append('"'); |
|
|
|
if (!_referenceClassName.isNull()) |
|
{ |
|
out << LIT(" REFERENCECLASS=\""); |
|
out << _referenceClassName.getString(); |
|
out.append('"'); |
|
} |
|
|
|
if (_arraySize) |
|
{ |
|
char buffer[32]; |
|
sprintf(buffer, "%d", _arraySize); |
|
out << LIT(" ARRAYSIZE=\"") << buffer; |
|
out.append('"'); |
|
} |
|
|
|
out << LIT(">\n"); |
|
|
|
_qualifiers.toXml(out); |
|
|
|
out << LIT("</PARAMETER.REFARRAY>\n"); |
|
} |
|
else |
|
{ |
|
out << LIT("<PARAMETER.ARRAY"); |
|
out << LIT(" NAME=\"") << _name << LIT("\" "); |
|
out << LIT(" TYPE=\"") << cimTypeToString (_type); |
|
out.append('"'); |
|
|
|
if (_arraySize) |
|
{ |
|
char buffer[32]; |
|
sprintf(buffer, "%d", _arraySize); |
|
out << LIT(" ARRAYSIZE=\"") << buffer; |
|
out.append('"'); |
|
} |
|
|
|
out << LIT(">\n"); |
|
|
|
_qualifiers.toXml(out); |
|
|
|
out << LIT("</PARAMETER.ARRAY>\n"); |
|
} |
|
} |
|
else if (_type == CIMTYPE_REFERENCE) |
|
{ |
|
out << LIT("<PARAMETER.REFERENCE"); |
|
out << LIT(" NAME=\"") << _name; |
|
out.append('"'); |
|
|
|
if (!_referenceClassName.isNull()) |
|
{ |
|
out << LIT(" REFERENCECLASS=\""); |
|
out << _referenceClassName.getString(); |
|
out.append('"'); |
|
} |
|
out << LIT(">\n"); |
|
|
|
_qualifiers.toXml(out); |
|
|
|
out << LIT("</PARAMETER.REFERENCE>\n"); |
|
} |
|
else |
|
{ |
|
out << LIT("<PARAMETER"); |
|
out << LIT(" NAME=\"") << _name << LIT("\" "); |
|
out << LIT(" TYPE=\"") << cimTypeToString (_type); |
|
out.append('"'); |
|
out << LIT(">\n"); |
|
|
|
_qualifiers.toXml(out); |
|
|
|
out << LIT("</PARAMETER>\n"); |
|
} |
|
} |
|
|
|
/** toMof - puts the Mof representation of teh Parameter 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 CIMParameterRep::toMof(Buffer& out) const |
|
{ |
|
// Output the qualifiers for the parameter |
|
_qualifiers.toMof(out); |
|
|
|
if (_qualifiers.getCount()) |
|
out.append(' '); |
|
|
|
// Output the data type and name |
|
out << cimTypeToString (_type); |
|
out.append(' '); |
|
out << _name; |
|
|
|
if (_isArray) |
|
{ | { |
//Output the array indicator "[ [arraysize] ]" |
// If the pointers are the same, the objects must be identical |
if (_arraySize) |
if (this == x) |
{ | { |
char buffer[32]; |
return true; |
sprintf(buffer, "[%d]", _arraySize); |
|
out << buffer; |
|
} |
|
else |
|
out << LIT("[]"); |
|
} |
|
} | } |
| |
|
|
Boolean CIMParameterRep::identical(const CIMParameterRep* x) const |
|
{ |
|
if (!_name.equal (x->_name)) | if (!_name.equal (x->_name)) |
return false; | return false; |
| |