version 1.40, 2004/10/17 20:39:16
|
version 1.58, 2008/04/11 17:14:03
|
|
|
//%2004//////////////////////////////////////////////////////////////////////// |
//%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, The Open Group. | // IBM Corp.; EMC Corporation, The Open Group. |
// Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.; | // Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.; |
// 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.; |
|
// 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) |
|
// |
|
//%///////////////////////////////////////////////////////////////////////////// | //%///////////////////////////////////////////////////////////////////////////// |
| |
#include <Pegasus/Common/Config.h> | #include <Pegasus/Common/Config.h> |
#include "CIMMethod.h" | #include "CIMMethod.h" |
#include "CIMMethodRep.h" | #include "CIMMethodRep.h" |
#include "Resolver.h" | #include "Resolver.h" |
#include "Indentor.h" |
|
#include "CIMName.h" | #include "CIMName.h" |
#include "CIMScope.h" | #include "CIMScope.h" |
#include "XmlWriter.h" |
#include <Pegasus/Common/MessageLoader.h> |
#include "MofWriter.h" |
#include "StrLit.h" |
#include <Pegasus/Common/MessageLoader.h> //l10n |
|
| |
PEGASUS_NAMESPACE_BEGIN | PEGASUS_NAMESPACE_BEGIN |
| |
|
CIMMethodRep::CIMMethodRep(const CIMMethodRep& x) : |
|
Sharable(), |
|
_name(x._name), |
|
_type(x._type), |
|
_classOrigin(x._classOrigin), |
|
_propagated(x._propagated), |
|
_ownerCount(0) |
|
{ |
|
x._qualifiers.cloneTo(_qualifiers); |
|
// Set the CIM name tag. |
|
_nameTag = generateCIMNameTag(_name); |
|
|
|
_parameters.reserveCapacity(x._parameters.size()); |
|
|
|
for (Uint32 i = 0, n = x._parameters.size(); i < n; i++) |
|
{ |
|
_parameters.append(x._parameters[i].clone()); |
|
} |
|
} |
|
|
CIMMethodRep::CIMMethodRep( | CIMMethodRep::CIMMethodRep( |
const CIMName& name, | const CIMName& name, |
CIMType type, | CIMType type, |
const CIMName& classOrigin, | const CIMName& classOrigin, |
Boolean propagated) | Boolean propagated) |
: _name(name), _type(type), | : _name(name), _type(type), |
_classOrigin(classOrigin), _propagated(propagated) |
_classOrigin(classOrigin), |
|
_propagated(propagated), |
|
_ownerCount(0) |
{ | { |
} |
// ensure name is not null |
|
if (name.isNull()) |
CIMMethodRep::~CIMMethodRep() |
|
{ | { |
|
throw UninitializedObjectException(); |
|
} |
|
// Set the CIM name tag. |
|
_nameTag = generateCIMNameTag(_name); |
} | } |
| |
void CIMMethodRep::setName(const CIMName& name) | void CIMMethodRep::setName(const CIMName& name) |
{ | { |
_name = name; |
// ensure name is not null |
|
if (name.isNull()) |
|
{ |
|
throw UninitializedObjectException(); |
} | } |
|
if (_ownerCount != 0 && _name != name) |
void CIMMethodRep::setClassOrigin(const CIMName& classOrigin) |
|
{ | { |
_classOrigin = classOrigin; |
MessageLoaderParms parms( |
|
"Common.CIMMethodRep.CONTAINED_METHOD_NAMECHANGEDEXCEPTION", |
|
"Attempted to change the name of a method" |
|
" already in a container."); |
|
throw Exception(parms); |
|
} |
|
_name = name; |
|
// Set the CIM name tag. |
|
_nameTag = generateCIMNameTag(_name); |
} | } |
| |
void CIMMethodRep::addParameter(const CIMParameter& x) | void CIMMethodRep::addParameter(const CIMParameter& x) |
|
|
if (x.isUninitialized()) | if (x.isUninitialized()) |
throw UninitializedObjectException(); | throw UninitializedObjectException(); |
| |
if (findParameter(x.getName()) != PEG_NOT_FOUND){ |
if (findParameter(x.getName()) != PEG_NOT_FOUND) |
//l10n |
{ |
//throw AlreadyExistsException |
|
//("parameter \"" + x.getName().getString () + "\""); |
|
MessageLoaderParms parms("Common.CIMMethodRep.PARAMETER", | MessageLoaderParms parms("Common.CIMMethodRep.PARAMETER", |
"parameter \"$0\"", | "parameter \"$0\"", |
x.getName().getString()); | x.getName().getString()); |
|
|
_parameters.append(x); | _parameters.append(x); |
} | } |
| |
Uint32 CIMMethodRep::findParameter(const CIMName& name) const |
|
{ |
|
for (Uint32 i = 0, n = _parameters.size(); i < n; i++) |
|
{ |
|
if (name.equal(_parameters[i].getName())) |
|
return i; |
|
} |
|
|
|
return PEG_NOT_FOUND; |
|
} |
|
|
|
CIMParameter CIMMethodRep::getParameter(Uint32 index) |
|
{ |
|
if (index >= _parameters.size()) |
|
throw IndexOutOfBoundsException(); |
|
|
|
return _parameters[index]; |
|
} |
|
|
|
void CIMMethodRep::removeParameter(Uint32 index) |
|
{ |
|
if (index >= _parameters.size()) |
|
throw IndexOutOfBoundsException(); |
|
|
|
_parameters.remove (index); |
|
} |
|
|
|
Uint32 CIMMethodRep::getParameterCount() const |
|
{ |
|
return _parameters.size(); |
|
} |
|
|
|
void CIMMethodRep::resolve( | void CIMMethodRep::resolve( |
DeclContext* declContext, | DeclContext* declContext, |
const CIMNamespaceName& nameSpace, | const CIMNamespaceName& nameSpace, |
|
|
| |
// Validate each of the parameters: | // Validate each of the parameters: |
| |
for (size_t i = 0; i < _parameters.size(); i++) |
for (Uint32 i = 0; i < _parameters.size(); i++) |
Resolver::resolveParameter (_parameters[i], declContext, nameSpace); | Resolver::resolveParameter (_parameters[i], declContext, nameSpace); |
| |
_classOrigin = inheritedMethod.getClassOrigin(); | _classOrigin = inheritedMethod.getClassOrigin(); |
|
|
| |
// Validate each of the parameters: | // Validate each of the parameters: |
| |
for (size_t i = 0; i < _parameters.size(); i++) |
for (Uint32 i = 0; i < _parameters.size(); i++) |
Resolver::resolveParameter (_parameters[i], declContext, nameSpace); | Resolver::resolveParameter (_parameters[i], declContext, nameSpace); |
} | } |
| |
static const char* _toString(Boolean x) |
Boolean CIMMethodRep::identical(const CIMMethodRep* x) const |
{ |
|
return x ? "true" : "false"; |
|
} |
|
|
|
void CIMMethodRep::toXml(Array<Sint8>& out) const |
|
{ |
|
out << "<METHOD"; |
|
|
|
out << " NAME=\"" << _name << "\""; |
|
|
|
out << " TYPE=\"" << cimTypeToString (_type) << "\""; |
|
|
|
if (!_classOrigin.isNull()) |
|
out << " CLASSORIGIN=\"" << _classOrigin << "\""; |
|
|
|
if (_propagated != false) |
|
out << " PROPAGATED=\"" << _toString(_propagated) << "\""; |
|
|
|
out << ">\n"; |
|
|
|
_qualifiers.toXml(out); |
|
|
|
for (Uint32 i = 0, n = _parameters.size(); i < n; i++) |
|
XmlWriter::appendParameterElement(out, _parameters[i]); |
|
|
|
out << "</METHOD>\n"; |
|
} |
|
|
|
/** |
|
The BNF for this is; |
|
methodDeclaration = [ qualifierList ] dataType methodName |
|
"(" [ parameterList ] ")" ";" |
|
|
|
parameterList = parameter *( "," parameter ) |
|
Format with qualifiers on one line and declaration on another. Start |
|
with newline but none at the end. |
|
*/ |
|
void CIMMethodRep::toMof(Array<Sint8>& out) const //ATTNKS: |
|
{ |
|
// Output the qualifier list starting on new line |
|
if (_qualifiers.getCount()) |
|
out << "\n"; |
|
|
|
_qualifiers.toMof(out); |
|
|
|
// output the type, MethodName and ParmeterList left enclosure |
|
out << "\n" << cimTypeToString (_type) << " " << _name << "("; |
|
|
|
// output the param list separated by commas. |
|
|
|
for (Uint32 i = 0, n = _parameters.size(); i < n; i++) |
|
{ |
|
// If not first, output comma separator |
|
if (i) |
|
out << ", "; |
|
|
|
MofWriter::appendParameterElement(out, _parameters[i]); |
|
} |
|
|
|
// output the parameterlist and method terminator |
|
out << ");"; |
|
} |
|
|
|
|
|
CIMMethodRep::CIMMethodRep() |
|
{ | { |
|
// If the pointers are the same, the objects must be identical |
} |
if (this == x) |
|
|
CIMMethodRep::CIMMethodRep(const CIMMethodRep& x) : |
|
Sharable(), |
|
_name(x._name), |
|
_type(x._type), |
|
_classOrigin(x._classOrigin), |
|
_propagated(x._propagated) |
|
{ | { |
x._qualifiers.cloneTo(_qualifiers); |
return true; |
|
|
_parameters.reserveCapacity(x._parameters.size()); |
|
|
|
for (Uint32 i = 0, n = x._parameters.size(); i < n; i++) |
|
_parameters.append(x._parameters[i].clone()); |
|
} | } |
| |
Boolean CIMMethodRep::identical(const CIMMethodRep* x) const |
|
{ |
|
if (!_name.equal (x->_name)) | if (!_name.equal (x->_name)) |
return false; | return false; |
| |
|
|
return true; | return true; |
} | } |
| |
void CIMMethodRep::setType(CIMType type) |
|
{ |
|
_type = type; |
|
} |
|
|
|
PEGASUS_NAMESPACE_END | PEGASUS_NAMESPACE_END |