version 1.36.2.1, 2005/09/30 16:28:15
|
version 1.48, 2008/04/11 17:14:03
|
|
|
//%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) |
{ | { |
|
|
} | } |
} | } |
| |
CIMParameterRep::~CIMParameterRep() |
|
{ |
|
} |
|
|
|
void CIMParameterRep::setName(const CIMName& name) | void CIMParameterRep::setName(const CIMName& name) |
{ | { |
// ensure name is not null | // ensure name is not null |
|
|
{ | { |
throw UninitializedObjectException(); | throw UninitializedObjectException(); |
} | } |
|
if (_ownerCount != 0 && _name != name) |
_name = name; |
|
} |
|
|
|
void CIMParameterRep::removeQualifier(Uint32 index) |
|
{ | { |
if (index >= _qualifiers.getCount()) |
MessageLoaderParms parms( |
throw IndexOutOfBoundsException(); |
"Common.CIMParameterRep.CONTAINED_PARAMETER_NAMECHANGEDEXCEPTION", |
|
"Attempted to change the name of a parameter" |
_qualifiers.removeQualifier (index); |
" already in a container."); |
|
throw Exception(parms); |
|
} |
|
_name = name; |
|
// Set the CIM name tag. |
|
_nameTag = generateCIMNameTag(_name); |
} | } |
| |
void CIMParameterRep::resolve( | void CIMParameterRep::resolve( |
|
|
true); | true); |
} | } |
| |
void CIMParameterRep::toXml(Buffer& out) const |
Boolean CIMParameterRep::identical(const CIMParameterRep* x) const |
{ |
|
if (_isArray) |
|
{ |
|
if (_type == CIMTYPE_REFERENCE) |
|
{ |
|
out << "<PARAMETER.REFARRAY"; |
|
out << " NAME=\"" << _name << "\""; |
|
|
|
if (!_referenceClassName.isNull()) |
|
{ |
|
out << " REFERENCECLASS=\"" << _referenceClassName.getString() |
|
<< "\""; |
|
} |
|
|
|
if (_arraySize) |
|
{ |
|
char buffer[32]; |
|
sprintf(buffer, "%d", _arraySize); |
|
out << " ARRAYSIZE=\"" << buffer << "\""; |
|
} |
|
|
|
out << ">\n"; |
|
|
|
_qualifiers.toXml(out); |
|
|
|
out << "</PARAMETER.REFARRAY>\n"; |
|
} |
|
else |
|
{ |
|
out << "<PARAMETER.ARRAY"; |
|
out << " NAME=\"" << _name << "\" "; |
|
out << " TYPE=\"" << cimTypeToString (_type) << "\""; |
|
|
|
if (_arraySize) |
|
{ |
|
char buffer[32]; |
|
sprintf(buffer, "%d", _arraySize); |
|
out << " ARRAYSIZE=\"" << buffer << "\""; |
|
} |
|
|
|
out << ">\n"; |
|
|
|
_qualifiers.toXml(out); |
|
|
|
out << "</PARAMETER.ARRAY>\n"; |
|
} |
|
} |
|
else if (_type == CIMTYPE_REFERENCE) |
|
{ |
|
out << "<PARAMETER.REFERENCE"; |
|
out << " NAME=\"" << _name << "\""; |
|
if (!_referenceClassName.isNull()) |
|
{ |
|
out << " REFERENCECLASS=\"" << _referenceClassName.getString() << |
|
"\""; |
|
} |
|
out << ">\n"; |
|
|
|
_qualifiers.toXml(out); |
|
|
|
out << "</PARAMETER.REFERENCE>\n"; |
|
} |
|
else |
|
{ |
|
out << "<PARAMETER"; |
|
out << " NAME=\"" << _name << "\" "; |
|
out << " TYPE=\"" << cimTypeToString (_type) << "\""; |
|
out << ">\n"; |
|
|
|
_qualifiers.toXml(out); |
|
|
|
out << "</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 << " "; |
|
|
|
// Output the data type and name |
|
out << cimTypeToString (_type) << " " << _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 << "[]"; |
|
} |
|
} | } |
| |
|
|
Boolean CIMParameterRep::identical(const CIMParameterRep* x) const |
|
{ |
|
if (!_name.equal (x->_name)) | if (!_name.equal (x->_name)) |
return false; | return false; |
| |