version 1.9, 2002/01/07 21:14:28
|
version 1.33, 2002/07/31 22:05:08
|
|
|
//%///////////////////////////////////////////////////////////////////////////// | //%///////////////////////////////////////////////////////////////////////////// |
// | // |
// Copyright (c) 2000, 2001 The Open group, BMC Software, Tivoli Systems, IBM |
// Copyright (c) 2000, 2001, 2002 BMC Software, Hewlett-Packard Company, IBM, |
|
// The Open Group, Tivoli Systems |
// | // |
// 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) |
// | // |
//%///////////////////////////////////////////////////////////////////////////// | //%///////////////////////////////////////////////////////////////////////////// |
| |
|
|
#define Pegasus_Object_h | #define Pegasus_Object_h |
| |
#include <Pegasus/Common/Config.h> | #include <Pegasus/Common/Config.h> |
#include <Pegasus/Common/CIMObjectRep.h> |
#include <Pegasus/Common/Linkage.h> |
|
#include <Pegasus/Common/String.h> |
|
#include <Pegasus/Common/CIMName.h> |
|
#include <Pegasus/Common/Array.h> |
|
#include <Pegasus/Common/CIMProperty.h> |
|
#include <Pegasus/Common/CIMQualifier.h> |
| |
PEGASUS_NAMESPACE_BEGIN | PEGASUS_NAMESPACE_BEGIN |
| |
|
class CIMConstObject; |
|
class CIMObjectRep; |
class CIMClass; | class CIMClass; |
class CIMConstClass; | class CIMConstClass; |
class CIMInstance; | class CIMInstance; |
|
|
// | // |
//////////////////////////////////////////////////////////////////////////////// | //////////////////////////////////////////////////////////////////////////////// |
| |
class CIMConstObject; |
|
class CIMObject; |
|
|
|
/** This class either refers to a CIMInstance or a CIMClass. | /** This class either refers to a CIMInstance or a CIMClass. |
| |
The CIMObjectRep data member points to either a CIMInstanceRep or | The CIMObjectRep data member points to either a CIMInstanceRep or |
|
|
| |
/** Constructor. | /** Constructor. |
*/ | */ |
CIMObject() : _rep(0) |
CIMObject(); |
{ |
|
|
|
} |
|
| |
/** Copy constructor. | /** Copy constructor. |
*/ | */ |
CIMObject(const CIMObject& x) |
CIMObject(const CIMObject& x); |
{ |
|
Inc(_rep = x._rep); |
|
} |
|
| |
/** Construction from CIMClass. | /** Construction from CIMClass. |
*/ | */ |
|
|
| |
/** Assignment operator. | /** Assignment operator. |
*/ | */ |
CIMObject& operator=(const CIMObject& x) |
CIMObject& operator=(const CIMObject& x); |
{ |
|
if (x._rep != _rep) |
|
{ |
|
Dec(_rep); |
|
Inc(_rep = x._rep); |
|
} |
|
return *this; |
|
} |
|
| |
/** Assignment operator. | /** Assignment operator. |
*/ | */ |
|
|
| |
/** Destructor. | /** Destructor. |
*/ | */ |
~CIMObject() |
~CIMObject(); |
{ |
|
Dec(_rep); |
|
} |
|
| |
/** Accessor. |
/** Accessor for ClassName component of the object. |
|
@return - Returns the ClassName of the object in |
|
a CIMName parameter. |
|
<pre> |
|
CIMName className; |
|
CIMClass myclass("myclass", "superclass"); |
|
className = myclass.getClassName; |
|
</pre> |
*/ | */ |
const CIMReference & getPath(void) const |
const CIMName& getClassName() const; |
{ |
|
_checkRep(); |
|
return _rep->getPath(); |
|
} |
|
| |
/** Accessor. |
const CIMObjectPath& getPath() const; |
|
|
|
/** |
|
Sets the object path for the object |
|
@param path CIMObjectPath containing the object path |
*/ | */ |
const String& getClassName() const |
void setPath (const CIMObjectPath & path); |
{ |
|
_checkRep(); |
|
return _rep->getClassName(); |
|
} |
|
| |
/** addQualifier - Adds the CIMQualifier object to the instance. | /** addQualifier - Adds the CIMQualifier object to the instance. |
Thows an exception of the CIMQualifier already exists in the instance | Thows an exception of the CIMQualifier already exists in the instance |
@param CIMQualifier object to add to instance | @param CIMQualifier object to add to instance |
@return ATTN: |
@return the resulting object. |
@exception Throws AlreadyExists. | @exception Throws AlreadyExists. |
*/ | */ |
CIMObject& addQualifier(const CIMQualifier& qualifier) |
CIMObject& addQualifier(const CIMQualifier& qualifier); |
{ |
|
_checkRep(); |
|
_rep->addQualifier(qualifier); |
|
return *this; |
|
} |
|
| |
/** findQualifier - Searches the instance for the qualifier object | /** findQualifier - Searches the instance for the qualifier object |
defined by the input parameter. | defined by the input parameter. |
@param String defining the qualifier object to be found. |
@param CIMName defining the qualifier object to be found. |
@return - Position of the qualifier to be used in subsequent | @return - Position of the qualifier to be used in subsequent |
operations or PEG_NOT_FOUND if the qualifier is not found. | operations or PEG_NOT_FOUND if the qualifier is not found. |
*/ | */ |
Uint32 findQualifier(const String& name) |
Uint32 findQualifier(const CIMName& name) const; |
{ |
|
_checkRep(); |
|
return _rep->findQualifier(name); |
|
} |
|
|
|
Uint32 findQualifier(const String& name) const |
|
{ |
|
_checkRep(); |
|
return _rep->findQualifier(name); |
|
} |
|
|
|
/** existsQualifier - Searches the instance for the qualifier object |
|
defined by the input parameter. |
|
@param String defining the qualifier object to be found. |
|
@return - Returns True if the qualifier object exists or false |
|
if the qualifier is not found. |
|
*/ |
|
Boolean existsQualifier(const String& name) |
|
{ |
|
_checkRep(); |
|
return _rep->existsQualifier(name); |
|
} |
|
|
|
Boolean existsQualifier(const String& name) const |
|
{ |
|
_checkRep(); |
|
return _rep->existsQualifier(name); |
|
} |
|
| |
/** getQualifier - Retrieves the qualifier object defined by the | /** getQualifier - Retrieves the qualifier object defined by the |
index input parameter. @ index for the qualifier object. | index input parameter. @ index for the qualifier object. |
|
|
@exception Throws the OutOfBounds exception if the index | @exception Throws the OutOfBounds exception if the index |
is out of bounds | is out of bounds |
*/ | */ |
CIMQualifier getQualifier(Uint32 pos) |
CIMQualifier getQualifier(Uint32 pos); |
{ |
|
_checkRep(); |
|
return _rep->getQualifier(pos); |
|
} |
|
| |
/** getQualifier - Retrieves the qualifier object defined by the | /** getQualifier - Retrieves the qualifier object defined by the |
index input parameter. @ index for the qualifier object. | index input parameter. @ index for the qualifier object. |
|
|
@return: Returns qualifier object defined by index. | @return: Returns qualifier object defined by index. |
@exception Throws the OutOfBounds exception if the index | @exception Throws the OutOfBounds exception if the index |
is out of bounds | is out of bounds |
ATTN: What is effect of out of range index??? |
|
ATTN: Is the above statement correct??? |
|
*/ | */ |
CIMConstQualifier getQualifier(Uint32 pos) const |
CIMConstQualifier getQualifier(Uint32 pos) const; |
{ |
|
_checkRep(); |
void removeQualifier(Uint32 pos); |
return _rep->getQualifier(pos); |
|
} |
|
| |
/** getQualifierCount - Gets the numbercount of CIMQualifierobjects |
/** getQualifierCount - Gets the number of CIMQualifier objects |
defined for this CIMObject. | defined for this CIMObject. |
@return Count of the number of CIMQalifier objects in the |
@return Count of the number of CIMQualifier objects in the |
CIMObject. | CIMObject. |
@exception Throws the OutOfBounds exception if the index | @exception Throws the OutOfBounds exception if the index |
is out of bounds | is out of bounds |
*/ | */ |
Uint32 getQualifierCount() const |
Uint32 getQualifierCount() const; |
{ |
|
_checkRep(); |
|
return _rep->getQualifierCount(); |
|
} |
|
| |
/** addProperty - Adds a property object defined by the input | /** addProperty - Adds a property object defined by the input |
parameter to the CIMObject | parameter to the CIMObject |
@param Property Object to be added. See the CIM Property | @param Property Object to be added. See the CIM Property |
class for definition of the property object | class for definition of the property object |
@return ATTN: |
@return the resulting object. |
@exception Throws the exception AlreadyExists if the property | @exception Throws the exception AlreadyExists if the property |
already exists. | already exists. |
*/ | */ |
CIMObject& addProperty(const CIMProperty& x) |
CIMObject& addProperty(const CIMProperty& x); |
{ |
|
_checkRep(); |
|
_rep->addProperty(x); |
|
return *this; |
|
} |
|
| |
/** findProperty - Searches the CIMProperty objects installed in the | /** findProperty - Searches the CIMProperty objects installed in the |
CIMObject for property objects with the name defined by the | CIMObject for property objects with the name defined by the |
input. | input. |
@param String with the name of the property object to be found |
@param CIMName with the name of the property object to be found |
@return Position in the CIM object to the property object if found or | @return Position in the CIM object to the property object if found or |
PEG_NOT_FOUND if no property object found with the name defined by the | PEG_NOT_FOUND if no property object found with the name defined by the |
input. | input. |
*/ | */ |
Uint32 findProperty(const String& name) |
Uint32 findProperty(const CIMName& name) const; |
{ |
|
_checkRep(); |
|
return _rep->findProperty(name); |
|
} |
|
|
|
Uint32 findProperty(const String& name) const |
|
{ |
|
_checkRep(); |
|
return _rep->findProperty(name); |
|
} |
|
|
|
/** existsPropery - Determines if a property object with the |
|
name defined by the input parameter exists in the class. |
|
@parm String parameter with the property name. |
|
@return True if the property object exists. |
|
*/ |
|
Boolean existsProperty(const String& name) |
|
{ |
|
_checkRep(); |
|
return _rep->existsProperty(name); |
|
} |
|
| |
Boolean existsProperty(const String& name) const |
/** getProperty - Gets the CIMProperty object in the CIMObject defined |
{ |
|
_checkRep(); |
|
return _rep->existsProperty(name); |
|
} |
|
|
|
/** getProperty - Gets the CIMproperty object in the CIMObject defined |
|
by the input index parameter. | by the input index parameter. |
@param Index to the property object in the CIMObject. | @param Index to the property object in the CIMObject. |
The index to qualifier objects is zero-origin and continuous | The index to qualifier objects is zero-origin and continuous |
|
|
@return CIMProperty object corresponding to the index. | @return CIMProperty object corresponding to the index. |
@exception Throws the OutOfBounds exception if the index | @exception Throws the OutOfBounds exception if the index |
is out of bounds | is out of bounds |
|
|
ATTN: What is the effect of out of range? |
|
*/ | */ |
CIMProperty getProperty(Uint32 pos) |
CIMProperty getProperty(Uint32 pos); |
{ |
|
_checkRep(); |
|
return _rep->getProperty(pos); |
|
} |
|
| |
/** getProperty - Gets the CIMproperty object in the CIMObject defined | /** getProperty - Gets the CIMproperty object in the CIMObject defined |
by the input index parameter. | by the input index parameter. |
|
|
@return CIMProperty object corresponding to the index. | @return CIMProperty object corresponding to the index. |
@exception Throws the OutOfBounds exception if the index | @exception Throws the OutOfBounds exception if the index |
is out of bounds | is out of bounds |
|
|
ATTN: What is the effect of out of range? |
|
*/ | */ |
CIMConstProperty getProperty(Uint32 pos) const |
CIMConstProperty getProperty(Uint32 pos) const; |
{ |
|
_checkRep(); |
|
return _rep->getProperty(pos); |
|
} |
|
| |
/** removeProperty - Removes the property represented | /** removeProperty - Removes the property represented |
by the position input parameter from the instance. | by the position input parameter from the instance. |
|
|
instance. Normally this is obtained by getProperty(); | instance. Normally this is obtained by getProperty(); |
@exception Throws OutofBounds if index is not a property object | @exception Throws OutofBounds if index is not a property object |
*/ | */ |
void removeProperty(Uint32 pos) |
void removeProperty(Uint32 pos); |
{ |
|
_checkRep(); |
|
_rep->removeProperty(pos); |
|
} |
|
| |
/** getPropertyCount - Gets the numbercount of CIMProperty |
/** getPropertyCount - Gets the number of CIMProperty |
objects defined for this CIMObject. | objects defined for this CIMObject. |
@return Count of the number of CIMProperty objects in the | @return Count of the number of CIMProperty objects in the |
CIMObject. Zero indicates that no CIMProperty objects | CIMObject. Zero indicates that no CIMProperty objects |
|
|
is out of bounds | is out of bounds |
| |
*/ | */ |
Uint32 getPropertyCount() const |
Uint32 getPropertyCount() const; |
{ |
|
_checkRep(); |
|
return _rep->getPropertyCount(); |
|
} |
|
| |
/** operator int() - ATTN: */ |
/** Clones the given object. |
operator int() const { return _rep != 0; } |
*/ |
|
CIMObject clone() const; |
| |
/** Returns true if the two classes are structurally identical. | /** Returns true if the two classes are structurally identical. |
*/ | */ |
Boolean identical(const CIMConstObject& x) const; | Boolean identical(const CIMConstObject& x) const; |
| |
/** Convert object to XML format. |
/** |
*/ |
Determines if the object has not been initialized. |
void toXml(Array<Sint8>& out) const |
|
{ |
|
_checkRep(); |
|
_rep->toXml(out); |
|
} |
|
| |
/** Clones the given object. |
@return True if the object has not been initialized, |
|
False otherwise |
*/ | */ |
CIMObject clone() const |
Boolean isUninitialized() const; |
{ |
|
_checkRep(); |
|
return CIMObject(_rep->clone()); |
|
} |
|
| |
private: | private: |
| |
CIMObject(CIMObjectRep* rep) : _rep(rep) |
CIMObjectRep* _rep; |
{ |
|
|
|
} |
|
| |
void _checkRep() const |
#ifdef PEGASUS_INTERNALONLY |
{ |
CIMObject(CIMObjectRep* rep); |
if (!_rep) |
|
ThrowUnitializedHandle(); |
|
} |
|
| |
CIMObjectRep* _rep; |
void _checkRep() const; |
| |
friend class CIMConstObject; | friend class CIMConstObject; |
friend class CIMClass; | friend class CIMClass; |
friend class CIMConstClass; | friend class CIMConstClass; |
friend class CIMInstance; | friend class CIMInstance; |
friend class CIMConstInstance; | friend class CIMConstInstance; |
|
#endif |
}; | }; |
| |
|
#define PEGASUS_ARRAY_T CIMObject |
|
# include <Pegasus/Common/ArrayInter.h> |
|
#undef PEGASUS_ARRAY_T |
|
|
//////////////////////////////////////////////////////////////////////////////// | //////////////////////////////////////////////////////////////////////////////// |
// | // |
// CIMConstObject | // CIMConstObject |
|
|
{ | { |
public: | public: |
| |
CIMConstObject() : _rep(0) |
CIMConstObject(); |
{ |
|
| |
} |
CIMConstObject(const CIMConstObject& x); |
| |
CIMConstObject(const CIMConstObject& x) |
CIMConstObject(const CIMObject& x); |
{ |
|
Inc(_rep = x._rep); |
|
} |
|
|
|
CIMConstObject(const CIMObject& x) |
|
{ |
|
Inc(_rep = x._rep); |
|
} |
|
| |
/** Construction from CIMClass. | /** Construction from CIMClass. |
*/ | */ |
|
|
*/ | */ |
CIMConstObject(const CIMConstInstance& x); | CIMConstObject(const CIMConstInstance& x); |
| |
CIMConstObject& operator=(const CIMConstObject& x) |
CIMConstObject& operator=(const CIMConstObject& x); |
{ |
|
if (x._rep != _rep) |
|
{ |
|
Dec(_rep); |
|
Inc(_rep = x._rep); |
|
} |
|
return *this; |
|
} |
|
| |
CIMConstObject& operator=(const CIMObject& x) |
CIMConstObject& operator=(const CIMObject& x); |
{ |
|
if (x._rep != _rep) |
|
{ |
|
Dec(_rep); |
|
Inc(_rep = x._rep); |
|
} |
|
return *this; |
|
} |
|
| |
CIMConstObject& operator=(const CIMClass& x); | CIMConstObject& operator=(const CIMClass& x); |
| |
|
|
| |
CIMConstObject& operator=(const CIMConstInstance& x); | CIMConstObject& operator=(const CIMConstInstance& x); |
| |
~CIMConstObject() |
~CIMConstObject(); |
{ |
|
Dec(_rep); |
|
} |
|
| |
const CIMReference & getPath(void) const |
const CIMName& getClassName() const; |
{ |
|
_checkRep(); |
|
return _rep->getPath(); |
|
} |
|
| |
const String& getClassName() const |
const CIMObjectPath& getPath() const; |
{ |
|
_checkRep(); |
|
return _rep->getClassName(); |
|
} |
|
| |
Uint32 findQualifier(const String& name) const |
Uint32 findQualifier(const CIMName& name) const; |
{ |
|
_checkRep(); |
|
return _rep->findQualifier(name); |
|
} |
|
| |
CIMConstQualifier getQualifier(Uint32 pos) const |
CIMConstQualifier getQualifier(Uint32 pos) const; |
{ |
|
_checkRep(); |
|
return _rep->getQualifier(pos); |
|
} |
|
| |
Uint32 getQualifierCount() const |
Uint32 getQualifierCount() const; |
{ |
|
_checkRep(); |
|
return _rep->getQualifierCount(); |
|
} |
|
| |
Uint32 findProperty(const String& name) const |
Uint32 findProperty(const CIMName& name) const; |
{ |
|
_checkRep(); |
|
return _rep->findProperty(name); |
|
} |
|
| |
CIMConstProperty getProperty(Uint32 pos) const |
CIMConstProperty getProperty(Uint32 pos) const; |
{ |
|
_checkRep(); |
|
return _rep->getProperty(pos); |
|
} |
|
| |
Uint32 getPropertyCount() const |
Uint32 getPropertyCount() const; |
{ |
|
_checkRep(); |
|
return _rep->getPropertyCount(); |
|
} |
|
| |
operator int() const { return _rep != 0; } |
CIMObject clone() const; |
| |
void toXml(Array<Sint8>& out) const |
Boolean identical(const CIMConstObject& x) const; |
{ |
|
_checkRep(); |
|
_rep->toXml(out); |
|
} |
|
|
|
void print(PEGASUS_STD(ostream) &o=PEGASUS_STD(cout)) const |
|
{ |
|
_checkRep(); |
|
_rep->print(o); |
|
} |
|
|
|
Boolean identical(const CIMConstObject& x) const |
|
{ |
|
x._checkRep(); |
|
_checkRep(); |
|
return _rep->identical(x._rep); |
|
} |
|
| |
CIMObject clone() const |
Boolean isUninitialized() const; |
{ |
|
return CIMObject(_rep->clone()); |
|
} |
|
| |
private: | private: |
| |
void _checkRep() const |
|
{ |
|
if (!_rep) |
|
ThrowUnitializedHandle(); |
|
} |
|
|
|
CIMObjectRep* _rep; | CIMObjectRep* _rep; |
| |
|
#ifdef PEGASUS_INTERNALONLY |
|
void _checkRep() const; |
|
|
friend class CIMObject; | friend class CIMObject; |
friend class CIMClass; | friend class CIMClass; |
friend class CIMConstClass; | friend class CIMConstClass; |
friend class CIMInstance; | friend class CIMInstance; |
friend class CIMConstInstance; | friend class CIMConstInstance; |
}; |
#endif |
|
|
/** The CIMObjectWithPath encapsulates a CIMReference and CIMObject. |
|
Accessors are provided for getting the two parts. Constructors are |
|
provided for initializing it from a CIMObject. |
|
*/ |
|
class PEGASUS_COMMON_LINKAGE CIMObjectWithPath |
|
{ |
|
public: |
|
|
|
/** Constructor |
|
*/ |
|
CIMObjectWithPath(); |
|
|
|
/** constructor |
|
*/ |
|
CIMObjectWithPath(const CIMReference& reference, const CIMObject& object); |
|
|
|
/** Constructor - Constructs a CIMObjectWithPath Object from |
|
another CimObjectWithPath |
|
@param - ATTN |
|
*/ |
|
CIMObjectWithPath(const CIMObjectWithPath& x); |
|
|
|
~CIMObjectWithPath(); |
|
|
|
CIMObjectWithPath& operator=(const CIMObjectWithPath& x); |
|
|
|
/** set - |
|
*/ |
|
void set(const CIMReference& reference, const CIMObject& object); |
|
|
|
/** |
|
*/ |
|
const CIMReference& getReference() const { return _reference; } |
|
|
|
/** |
|
*/ |
|
const CIMObject& getObject() const { return _object; } |
|
|
|
/** |
|
*/ |
|
CIMReference& getReference() { return _reference; } |
|
|
|
/** |
|
*/ |
|
CIMObject& getObject() { return _object; } |
|
|
|
/** |
|
*/ |
|
void toXml(Array<Sint8>& out) const; |
|
|
|
private: |
|
|
|
CIMReference _reference; |
|
CIMObject _object; |
|
}; | }; |
| |
PEGASUS_NAMESPACE_END | PEGASUS_NAMESPACE_END |