version 1.2, 2001/07/02 01:50:09
|
version 1.36, 2005/10/31 17:39:11
|
|
|
//%///////////////////////////////////////////////////////////////////////////// |
//%2005//////////////////////////////////////////////////////////////////////// |
// | // |
// Copyright (c) 2000, 2001 The Open group, BMC Software, Tivoli Systems, IBM |
// Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development |
|
// 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: Mike Brasher (mbrasher@bmc.com) | // Author: Mike Brasher (mbrasher@bmc.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) |
|
// Dave Sudlik, IBM (dsudlik@us.ibm.com) |
|
// David Dillard, VERITAS Software Corp. |
|
// (david.dillard@veritas.com) |
// | // |
//%///////////////////////////////////////////////////////////////////////////// | //%///////////////////////////////////////////////////////////////////////////// |
| |
|
#include "CIMClassRep.h" |
|
#include "CIMInstanceRep.h" |
|
#include "CIMObjectRep.h" |
#include "CIMObject.h" | #include "CIMObject.h" |
|
#include "CIMClass.h" |
|
#include "CIMInstance.h" |
#include "XmlWriter.h" | #include "XmlWriter.h" |
| |
PEGASUS_USING_STD; |
|
|
|
PEGASUS_NAMESPACE_BEGIN | PEGASUS_NAMESPACE_BEGIN |
| |
|
#define PEGASUS_ARRAY_T CIMObject |
|
# include "ArrayImpl.h" |
|
#undef PEGASUS_ARRAY_T |
|
|
//////////////////////////////////////////////////////////////////////////////// | //////////////////////////////////////////////////////////////////////////////// |
// | // |
// CIMObject | // CIMObject |
// | // |
//////////////////////////////////////////////////////////////////////////////// | //////////////////////////////////////////////////////////////////////////////// |
| |
CIMClass CIMObject::getClass() |
CIMObject::CIMObject() |
|
: _rep(0) |
{ | { |
CIMClassRep* rep = dynamic_cast<CIMClassRep*>(_rep); |
} |
| |
if (!rep) |
CIMObject::CIMObject(const CIMObject& x) |
throw TypeMismatch(); |
{ |
|
Inc(_rep = x._rep); |
|
} |
| |
return CIMClass(rep); |
CIMObject::CIMObject(const CIMClass& x) |
|
{ |
|
Inc(_rep = x._rep); |
} | } |
| |
CIMConstClass CIMObject::getClass() const |
CIMObject::CIMObject(const CIMInstance& x) |
{ | { |
CIMClassRep* rep = dynamic_cast<CIMClassRep*>(_rep); |
Inc(_rep = x._rep); |
|
} |
| |
if (!rep) |
CIMObject::CIMObject(CIMObjectRep* rep) |
throw TypeMismatch(); |
: _rep(rep) |
|
{ |
|
} |
| |
return CIMConstClass(rep); |
CIMObject& CIMObject::operator=(const CIMObject& x) |
|
{ |
|
if (x._rep != _rep) |
|
{ |
|
Dec(_rep); |
|
Inc(_rep = x._rep); |
|
} |
|
return *this; |
} | } |
| |
CIMInstance CIMObject::getInstance() |
CIMObject::~CIMObject() |
{ | { |
CIMInstanceRep* rep = dynamic_cast<CIMInstanceRep*>(_rep); |
Dec(_rep); |
|
} |
| |
if (!rep) |
const CIMName& CIMObject::getClassName() const |
throw TypeMismatch(); |
{ |
|
_checkRep(); |
|
return _rep->getClassName(); |
|
} |
| |
return CIMInstance(rep); |
const CIMObjectPath& CIMObject::getPath() const |
|
{ |
|
_checkRep(); |
|
return _rep->getPath(); |
} | } |
| |
CIMConstInstance CIMObject::getInstance() const |
void CIMObject::setPath (const CIMObjectPath & path) |
{ | { |
CIMInstanceRep* rep = dynamic_cast<CIMInstanceRep*>(_rep); |
_checkRep (); |
|
_rep->setPath (path); |
|
} |
| |
if (!rep) |
CIMObject& CIMObject::addQualifier(const CIMQualifier& qualifier) |
throw TypeMismatch(); |
{ |
|
_checkRep(); |
|
_rep->addQualifier(qualifier); |
|
return *this; |
|
} |
| |
return CIMConstInstance(rep); |
Uint32 CIMObject::findQualifier(const CIMName& name) const |
|
{ |
|
_checkRep(); |
|
return _rep->findQualifier(name); |
} | } |
| |
void CIMObject::toXml(Array<Sint8>& out) const |
CIMQualifier CIMObject::getQualifier(Uint32 index) |
{ | { |
if (!_rep) |
_checkRep(); |
throw NullPointer(); |
return _rep->getQualifier(index); |
|
} |
|
|
|
CIMConstQualifier CIMObject::getQualifier(Uint32 index) const |
|
{ |
|
_checkRep(); |
|
return _rep->getQualifier(index); |
|
} |
|
|
|
void CIMObject::removeQualifier(Uint32 index) |
|
{ |
|
_checkRep(); |
|
_rep->removeQualifier(index); |
|
} |
|
|
|
Uint32 CIMObject::getQualifierCount() const |
|
{ |
|
_checkRep(); |
|
return _rep->getQualifierCount(); |
|
} |
|
|
|
CIMObject& CIMObject::addProperty(const CIMProperty& x) |
|
{ |
|
_checkRep(); |
|
_rep->addProperty(x); |
|
return *this; |
|
} |
|
|
|
Uint32 CIMObject::findProperty(const CIMName& name) const |
|
{ |
|
_checkRep(); |
|
return _rep->findProperty(name); |
|
} |
|
|
|
CIMProperty CIMObject::getProperty(Uint32 index) |
|
{ |
|
_checkRep(); |
|
return _rep->getProperty(index); |
|
} |
|
|
|
CIMConstProperty CIMObject::getProperty(Uint32 index) const |
|
{ |
|
_checkRep(); |
|
return _rep->getProperty(index); |
|
} |
|
|
|
void CIMObject::removeProperty(Uint32 index) |
|
{ |
|
_checkRep(); |
|
_rep->removeProperty(index); |
|
} |
|
|
|
Uint32 CIMObject::getPropertyCount() const |
|
{ |
|
_checkRep(); |
|
return _rep->getPropertyCount(); |
|
} |
|
|
|
Boolean CIMObject::isUninitialized() const |
|
{ |
|
return (_rep == 0)? true : false; |
|
} |
|
|
|
String CIMObject::toString () const |
|
{ |
|
Buffer out; |
|
|
|
_checkRep(); |
|
_rep->toXml(out); |
|
out.append('\0'); |
|
|
|
return out.getData(); |
|
} |
|
|
|
Boolean CIMObject::isClass () const |
|
{ |
|
try |
|
{ |
|
const CIMClass c (*this); |
|
return true; |
|
} |
|
catch (DynamicCastFailedException&) |
|
{ |
|
return false; |
|
} |
|
} |
|
|
|
Boolean CIMObject::isInstance () const |
|
{ |
|
try |
|
{ |
|
const CIMInstance i (*this); |
|
return true; |
|
} |
|
catch (DynamicCastFailedException&) |
|
{ |
|
return false; |
|
} |
|
} |
| |
if (isClass()) |
Boolean CIMObject::identical(const CIMConstObject& x) const |
{ | { |
CIMConstClass cimClass = getClass(); |
x._checkRep(); |
cimClass.toXml(out); |
_checkRep(); |
|
return _rep->identical(x._rep); |
} | } |
else |
|
|
CIMObject CIMObject::clone() const |
{ | { |
CIMConstInstance cimInstance = getInstance(); |
_checkRep(); |
cimInstance.toXml(out); |
return CIMObject(_rep->clone()); |
} | } |
|
|
|
void CIMObject::_checkRep() const |
|
{ |
|
if (!_rep) |
|
throw UninitializedObjectException(); |
} | } |
| |
//////////////////////////////////////////////////////////////////////////////// | //////////////////////////////////////////////////////////////////////////////// |
// | // |
// CIMObjectWithPath |
// CIMConstObject |
// | // |
//////////////////////////////////////////////////////////////////////////////// | //////////////////////////////////////////////////////////////////////////////// |
| |
CIMObjectWithPath::CIMObjectWithPath() |
CIMConstObject::CIMConstObject() |
|
: _rep(0) |
{ | { |
|
|
} | } |
| |
CIMObjectWithPath::CIMObjectWithPath( |
CIMConstObject::CIMConstObject(const CIMConstObject& x) |
CIMReference& reference, |
|
CIMObject& object) |
|
: _reference(reference), _object(object) |
|
{ | { |
|
Inc(_rep = x._rep); |
|
} |
| |
|
CIMConstObject::CIMConstObject(const CIMObject& x) |
|
{ |
|
Inc(_rep = x._rep); |
} | } |
| |
CIMObjectWithPath::CIMObjectWithPath(const CIMObjectWithPath& x) |
CIMConstObject::CIMConstObject(const CIMClass& x) |
: _reference(x._reference), _object(x._object) |
|
{ | { |
|
Inc(_rep = x._rep); |
|
} |
| |
|
CIMConstObject::CIMConstObject(const CIMConstClass& x) |
|
{ |
|
Inc(_rep = x._rep); |
} | } |
| |
CIMObjectWithPath::~CIMObjectWithPath() |
CIMConstObject::CIMConstObject(const CIMInstance& x) |
{ | { |
|
Inc(_rep = x._rep); |
|
} |
| |
|
CIMConstObject::CIMConstObject(const CIMConstInstance& x) |
|
{ |
|
Inc(_rep = x._rep); |
} | } |
| |
CIMObjectWithPath& CIMObjectWithPath::operator=(const CIMObjectWithPath& x) |
CIMConstObject& CIMConstObject::operator=(const CIMConstObject& x) |
{ | { |
if (this != &x) |
if (x._rep != _rep) |
{ | { |
_reference = x._reference; |
Dec(_rep); |
_object = x._object; |
Inc(_rep = x._rep); |
} | } |
return *this; | return *this; |
} | } |
| |
void CIMObjectWithPath::set(CIMReference& reference, CIMObject& object) |
CIMConstObject::~CIMConstObject() |
{ | { |
_reference = reference; |
Dec(_rep); |
_object = object; |
|
} | } |
| |
//------------------------------------------------------------------------------ |
const CIMName& CIMConstObject::getClassName() const |
// |
{ |
// <!ELEMENT VALUE.OBJECTWITHPATH ((CLASSPATH,CLASS)|(INSTANCEPATH,INSTANCE))> |
_checkRep(); |
// |
return _rep->getClassName(); |
//------------------------------------------------------------------------------ |
} |
| |
void CIMObjectWithPath::toXml(Array<Sint8>& out) const |
const CIMObjectPath& CIMConstObject::getPath() const |
{ | { |
out << "<VALUE.OBJECTWITHPATH>\n"; |
_checkRep(); |
|
return _rep->getPath(); |
|
} |
| |
_reference.toXml(out, false); |
Uint32 CIMConstObject::findQualifier(const CIMName& name) const |
_object.toXml(out); |
{ |
|
_checkRep(); |
|
return _rep->findQualifier(name); |
|
} |
|
|
|
CIMConstQualifier CIMConstObject::getQualifier(Uint32 index) const |
|
{ |
|
_checkRep(); |
|
return _rep->getQualifier(index); |
|
} |
| |
out << "</VALUE.OBJECTWITHPATH>\n"; |
Uint32 CIMConstObject::getQualifierCount() const |
|
{ |
|
_checkRep(); |
|
return _rep->getQualifierCount(); |
|
} |
|
|
|
Uint32 CIMConstObject::findProperty(const CIMName& name) const |
|
{ |
|
_checkRep(); |
|
return _rep->findProperty(name); |
|
} |
|
|
|
CIMConstProperty CIMConstObject::getProperty(Uint32 index) const |
|
{ |
|
_checkRep(); |
|
return _rep->getProperty(index); |
|
} |
|
|
|
Uint32 CIMConstObject::getPropertyCount() const |
|
{ |
|
_checkRep(); |
|
return _rep->getPropertyCount(); |
|
} |
|
|
|
Boolean CIMConstObject::isUninitialized() const |
|
{ |
|
return (_rep == 0)? true : false; |
|
} |
|
|
|
String CIMConstObject::toString () const |
|
{ |
|
Buffer out; |
|
|
|
_checkRep(); |
|
_rep->toXml(out); |
|
out.append('\0'); |
|
|
|
return out.getData(); |
|
} |
|
|
|
Boolean CIMConstObject::isClass() const |
|
{ |
|
try |
|
{ |
|
const CIMConstClass c(*this); |
|
return true; |
|
} |
|
catch (DynamicCastFailedException&) |
|
{ |
|
return false; |
|
} |
|
} |
|
|
|
Boolean CIMConstObject::isInstance() const |
|
{ |
|
try |
|
{ |
|
const CIMConstInstance i(*this); |
|
return true; |
|
} |
|
catch (DynamicCastFailedException&) |
|
{ |
|
return false; |
|
} |
|
} |
|
|
|
Boolean CIMConstObject::identical(const CIMConstObject& x) const |
|
{ |
|
x._checkRep(); |
|
_checkRep(); |
|
return _rep->identical(x._rep); |
|
} |
|
|
|
CIMObject CIMConstObject::clone() const |
|
{ |
|
return CIMObject(_rep->clone()); |
|
} |
|
|
|
void CIMConstObject::_checkRep() const |
|
{ |
|
if (!_rep) |
|
throw UninitializedObjectException(); |
} | } |
| |
PEGASUS_NAMESPACE_END | PEGASUS_NAMESPACE_END |