version 1.58, 2003/10/22 14:26:02
|
version 1.71.2.1, 2006/02/10 16:09:33
|
|
|
//%2003//////////////////////////////////////////////////////////////////////// |
//%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. |
// Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L. P.; | // Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L. P.; |
// 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.; |
|
// 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 |
|
|
// Roger Kumpf, Hewlett-Packard Company (roger_kumpf@hp.com) | // Roger Kumpf, Hewlett-Packard Company (roger_kumpf@hp.com) |
// Carol Ann Krug Graves, Hewlett-Packard Company | // Carol Ann Krug Graves, Hewlett-Packard Company |
// (carolann_graves@hp.com) | // (carolann_graves@hp.com) |
|
// David Dillard, VERITAS Software Corp. |
|
// (david.dillard@veritas.com) |
// | // |
//%///////////////////////////////////////////////////////////////////////////// | //%///////////////////////////////////////////////////////////////////////////// |
| |
|
|
#include "MofWriter.h" | #include "MofWriter.h" |
#include <Pegasus/Common/Tracer.h> | #include <Pegasus/Common/Tracer.h> |
#include <Pegasus/Common/MessageLoader.h> //l10n | #include <Pegasus/Common/MessageLoader.h> //l10n |
|
#include "CIMNameUnchecked.h" |
|
#include "StrLit.h" |
| |
PEGASUS_NAMESPACE_BEGIN | PEGASUS_NAMESPACE_BEGIN |
PEGASUS_USING_STD; | PEGASUS_USING_STD; |
|
|
value.get(flag); | value.get(flag); |
return flag; | return flag; |
} | } |
|
|
void CIMClassRep::setSuperClassName(const CIMName& superClassName) | void CIMClassRep::setSuperClassName(const CIMName& superClassName) |
{ | { |
_superClassName = superClassName; | _superClassName = superClassName; |
|
|
| |
} | } |
| |
// Set the class origin: |
// Reject addition of a reference property without a referenceClassName |
// ATTN: put this check in other places: |
|
| |
if (x.getClassOrigin().isNull()) |
if ((x.getType() == CIMTYPE_REFERENCE) && |
CIMProperty(x).setClassOrigin(_reference.getClassName()); |
(x.getReferenceClassName().isNull())) |
|
{ |
|
throw TypeMismatchException(); |
|
} |
| |
// Add the property: | // Add the property: |
| |
|
|
MessageLoaderParms("Common.CIMClassRep.NON_ASSOCIATION_CLASS_CONTAINS_REFERENCE_PROPERTY", | MessageLoaderParms("Common.CIMClassRep.NON_ASSOCIATION_CLASS_CONTAINS_REFERENCE_PROPERTY", |
"Non-assocation class contains reference property")); | "Non-assocation class contains reference property")); |
| |
|
|
} | } |
| |
|
|
Uint32 index = superClass.findProperty(property.getName()); | Uint32 index = superClass.findProperty(property.getName()); |
| |
if (index == PEG_NOT_FOUND) | if (index == PEG_NOT_FOUND) |
{ | { |
Resolver::resolveProperty (property, context, | Resolver::resolveProperty (property, context, |
nameSpace, false, true); | nameSpace, false, true); |
|
if (property.getClassOrigin().isNull()) |
|
{ |
|
property.setClassOrigin(getClassName()); |
|
} |
|
property.setPropagated(false); |
} | } |
else | else |
{ | { |
|
|
superClass.getProperty(index); | superClass.getProperty(index); |
Resolver::resolveProperty (property, context, | Resolver::resolveProperty (property, context, |
nameSpace, false, superClassProperty, true); | nameSpace, false, superClassProperty, true); |
|
if (property.getClassOrigin().isNull()) |
|
{ |
|
property.setClassOrigin( |
|
superClassProperty.getClassOrigin()); |
|
} |
} | } |
} | } |
| |
|
|
//cout << "KSTEST Class Resolve, No Super class " << getClassName() << endl; | //cout << "KSTEST Class Resolve, No Super class " << getClassName() << endl; |
| |
for (Uint32 i = 0, n = _properties.size(); i < n; i++) | for (Uint32 i = 0, n = _properties.size(); i < n; i++) |
|
{ |
Resolver::resolveProperty (_properties[i], context, | Resolver::resolveProperty (_properties[i], context, |
nameSpace, false, true); | nameSpace, false, true); |
|
_properties[i].setClassOrigin(getClassName()); |
|
_properties[i].setPropagated(false); |
|
} |
| |
//---------------------------------------------------------------------- | //---------------------------------------------------------------------- |
// Resolve each method: | // Resolve each method: |
|
|
// _resolved = true; | // _resolved = true; |
} | } |
| |
void CIMClassRep::toXml(Array<Sint8>& out) const |
CIMInstance CIMClassRep::buildInstance(Boolean includeQualifiers, |
|
Boolean includeClassOrigin, |
|
const CIMPropertyList& propertyList) const |
|
{ |
|
|
|
// Create the new instance |
|
CIMInstance newInstance(_reference.getClassName()); |
|
|
|
// Copy qualifiers if required |
|
if (includeQualifiers) |
|
{ |
|
for (Uint32 i = 0 ; i < getQualifierCount() ; i++) |
|
{ |
|
newInstance.addQualifier(getQualifier(i).clone()); |
|
} |
|
} |
|
|
|
// Copy Properties |
|
for (Uint32 i = 0 ; i < _properties.size() ; i++) |
|
{ |
|
CIMConstProperty p = getProperty(i); |
|
CIMName name = p.getName(); |
|
Array<CIMName> pl = propertyList.getPropertyNameArray(); |
|
if (propertyList.isNull() || Contains(pl, name)) |
|
{ |
|
CIMProperty p = getProperty(i).clone(); |
|
if (!includeQualifiers && p.getQualifierCount() != 0) |
|
{ |
|
for (Uint32 j = 0 ; j < getQualifierCount() ; j++) |
|
{ |
|
p.removeQualifier(i - 1); |
|
} |
|
} |
|
if (!includeClassOrigin) |
|
{ |
|
p.setClassOrigin(CIMName()); |
|
} |
|
newInstance.addProperty(p); |
|
|
|
// Delete class origin attribute if required |
|
} |
|
} |
|
|
|
return(newInstance); |
|
} |
|
|
|
void CIMClassRep::toXml(Buffer& out) const |
{ | { |
// Class opening element: | // Class opening element: |
| |
out << "<CLASS "; |
out << STRLIT("<CLASS "); |
out << " NAME=\"" << _reference.getClassName() << "\" "; |
out << STRLIT(" NAME=\"") << _reference.getClassName() << STRLIT("\" "); |
| |
if (!_superClassName.isNull()) | if (!_superClassName.isNull()) |
out << " SUPERCLASS=\"" << _superClassName << "\" "; |
out << STRLIT(" SUPERCLASS=\"") << _superClassName << STRLIT("\" "); |
| |
out << ">\n"; |
out << STRLIT(">\n"); |
| |
// Qualifiers: | // Qualifiers: |
| |
|
|
| |
// Class closing element: | // Class closing element: |
| |
out << "</CLASS>\n"; |
out << STRLIT("</CLASS>\n"); |
} | } |
/** toMof prepares an 8-bit string with the MOF for the class. | /** toMof prepares an 8-bit string with the MOF for the class. |
The BNF for this is: | The BNF for this is: |
|
|
| |
*/ | */ |
| |
void CIMClassRep::toMof(Array<Sint8>& out) const |
void CIMClassRep::toMof(Buffer& out) const |
{ | { |
// Get and format the class qualifiers | // Get and format the class qualifiers |
out << "\n// Class " << _reference.getClassName(); |
out << STRLIT("\n// Class ") << _reference.getClassName(); |
if (_qualifiers.getCount()) | if (_qualifiers.getCount()) |
out << "\n"; |
out.append('\n'); |
out << "\n"; |
out.append('\n'); |
_qualifiers.toMof(out); | _qualifiers.toMof(out); |
| |
// Separate qualifiers from Class Name | // Separate qualifiers from Class Name |
out << "\n"; |
out.append('\n'); |
| |
// output class statement | // output class statement |
out << "class " << _reference.getClassName(); |
out << STRLIT("class ") << _reference.getClassName(); |
| |
if (!_superClassName.isNull()) | if (!_superClassName.isNull()) |
out << " : " << _superClassName; |
out << STRLIT(" : ") << _superClassName; |
| |
out << "\n{"; |
out << STRLIT("\n{"); |
| |
// format the Properties: | // format the Properties: |
for (Uint32 i = 0, n = _properties.size(); i < n; i++) | for (Uint32 i = 0, n = _properties.size(); i < n; i++) |
|
|
} | } |
| |
// Class closing element: | // Class closing element: |
out << "\n};\n"; |
out << STRLIT("\n};\n"); |
} | } |
| |
| |
|
|
CIMConstProperty property = getProperty(i); | CIMConstProperty property = getProperty(i); |
| |
Uint32 index; | Uint32 index; |
if ((index = property.findQualifier (CIMName ("key"))) != PEG_NOT_FOUND) |
if ((index = property.findQualifier( |
|
CIMNameUnchecked("key"))) != PEG_NOT_FOUND) |
{ | { |
CIMValue value; | CIMValue value; |
value = property.getQualifier (index).getValue (); | value = property.getQualifier (index).getValue (); |
|
|
CIMConstProperty property = getProperty(i); | CIMConstProperty property = getProperty(i); |
| |
Uint32 index; | Uint32 index; |
if ((index = property.findQualifier (CIMName ("key"))) != PEG_NOT_FOUND) |
if ((index = property.findQualifier( |
|
CIMNameUnchecked("key"))) != PEG_NOT_FOUND) |
{ | { |
CIMValue value; | CIMValue value; |
value = property.getQualifier (index).getValue (); | value = property.getQualifier (index).getValue (); |