version 1.2, 2001/07/02 01:50:09
|
version 1.15, 2002/04/30 18:03:11
|
|
|
// | // |
//%///////////////////////////////////////////////////////////////////////////// | //%///////////////////////////////////////////////////////////////////////////// |
| |
#ifndef Pegasus_CIMObject_h |
#ifndef Pegasus_Object_h |
#define Pegasus_CIMObject_h |
#define Pegasus_Object_h |
| |
#include <Pegasus/Common/Config.h> | #include <Pegasus/Common/Config.h> |
#include <Pegasus/Common/CIMClass.h> |
#include <Pegasus/Common/CIMObjectRep.h> |
#include <Pegasus/Common/CIMInstance.h> |
|
| |
PEGASUS_NAMESPACE_BEGIN | PEGASUS_NAMESPACE_BEGIN |
| |
/** This class contains either a class or an instance (both CIM objects). |
class CIMClass; |
Initializers are provided for both CIMClass and CIMInstance. The |
class CIMConstClass; |
isClass() and isInstance() methods are provided for determining the |
class CIMInstance; |
type of contained object. Methods are also provided for getting |
class CIMConstInstance; |
the internal object (into a CIMClass or CIMInstance). |
|
|
//////////////////////////////////////////////////////////////////////////////// |
|
// |
|
// CIMObject |
|
// |
|
//////////////////////////////////////////////////////////////////////////////// |
|
|
|
class CIMConstObject; |
|
class CIMObject; |
|
|
|
/** This class either refers to a CIMInstance or a CIMClass. |
|
|
|
The CIMObjectRep data member points to either a CIMInstanceRep or |
|
CIMClassRep. |
*/ | */ |
class PEGASUS_COMMON_LINKAGE CIMObject | class PEGASUS_COMMON_LINKAGE CIMObject |
{ | { |
public: | public: |
| |
|
/** Constructor. |
|
*/ |
CIMObject() : _rep(0) | CIMObject() : _rep(0) |
{ | { |
| |
} | } |
| |
|
/** Copy constructor. |
|
*/ |
CIMObject(const CIMObject& x) | CIMObject(const CIMObject& x) |
{ | { |
Inc(_rep = x._rep); | Inc(_rep = x._rep); |
} | } |
| |
CIMObject(const CIMClass& x) |
/** Construction from CIMClass. |
|
*/ |
|
CIMObject(const CIMClass& x); |
|
|
|
/** Construction from CIMInstance. |
|
*/ |
|
CIMObject(const CIMInstance& x); |
|
|
|
/** Assignment operator. |
|
*/ |
|
CIMObject& operator=(const CIMObject& x) |
|
{ |
|
if (x._rep != _rep) |
|
{ |
|
if (_rep) |
{ | { |
|
Dec(_rep); |
|
} |
Inc(_rep = x._rep); | Inc(_rep = x._rep); |
} | } |
|
return *this; |
|
} |
|
|
|
/** Assignment operator. |
|
*/ |
|
CIMObject& operator=(const CIMClass& x); |
| |
CIMObject(const CIMInstance& x) |
/** Assignment operator. |
|
*/ |
|
CIMObject& operator=(const CIMInstance& x); |
|
|
|
/** Destructor. |
|
*/ |
|
~CIMObject() |
{ | { |
Inc(_rep = x._rep); |
if (_rep) |
|
{ |
|
Dec(_rep); |
|
} |
} | } |
| |
CIMObject& operator=(const CIMObject& x) |
/** Accessor for ClassName component of the object. |
|
@return - Returns the ClassName of the object in |
|
a String parameter. |
|
<pre> |
|
String className; |
|
CIMClass myclass("myclass", "superclass"); |
|
className = myclass.getClassName; |
|
</pre> |
|
*/ |
|
const String& getClassName() const |
{ | { |
if (x._rep != _rep) |
_checkRep(); |
|
return _rep->getClassName(); |
|
} |
|
|
|
/** equalClassName Compares ClassName with a String. This test performs |
|
a comparison of the classname component of the object |
|
with a String. Note that this function was included specifically |
|
because the equality compare is not just a straight comparison |
|
because classnames are case independent. |
|
@param classname String containing the name for comparison |
|
@return True if it is the same class name (equalNoCase compare passes) |
|
or false if not. |
|
*/ |
|
const Boolean equalClassName(const String& classname) const |
{ | { |
Dec(_rep); |
_checkRep(); |
Inc(_rep = x._rep); |
return _rep->equalClassName(classname); |
|
|
|
} |
|
const CIMReference& getPath() const |
|
{ |
|
_checkRep(); |
|
return _rep->getPath(); |
|
} |
|
|
|
/** addQualifier - Adds the CIMQualifier object to the instance. |
|
Thows an exception of the CIMQualifier already exists in the instance |
|
@param CIMQualifier object to add to instance |
|
@return ATTN: |
|
@exception Throws AlreadyExists. |
|
*/ |
|
CIMObject& addQualifier(const CIMQualifier& qualifier) |
|
{ |
|
_checkRep(); |
|
_rep->addQualifier(qualifier); |
|
return *this; |
|
} |
|
|
|
/** findQualifier - Searches the instance for the qualifier object |
|
defined by the input parameter. |
|
@param String defining the qualifier object to be found. |
|
@return - Position of the qualifier to be used in subsequent |
|
operations or PEG_NOT_FOUND if the qualifier is not found. |
|
*/ |
|
Uint32 findQualifier(const String& name) |
|
{ |
|
_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 |
|
index input parameter. @ index for the qualifier object. |
|
The index to qualifier objects is zero-origin and continuous |
|
so that incrementing loops can be used to get all qualifier |
|
objects in a CIMInstnace. |
|
@return: Returns qualifier object defined by index. |
|
@exception Throws the OutOfBounds exception if the index |
|
is out of bounds |
|
*/ |
|
CIMQualifier getQualifier(Uint32 pos) |
|
{ |
|
_checkRep(); |
|
return _rep->getQualifier(pos); |
|
} |
|
|
|
/** getQualifier - Retrieves the qualifier object defined by the |
|
index input parameter. @ index for the qualifier object. |
|
The index to qualifier objects is zero-origin and continuous |
|
so that incrementing loops can be used to get all qualifier |
|
objects in a CIMInstnace. |
|
@return: Returns qualifier object defined by index. |
|
@exception Throws the OutOfBounds exception if the index |
|
is out of bounds |
|
ATTN: What is effect of out of range index??? |
|
ATTN: Is the above statement correct??? |
|
*/ |
|
CIMConstQualifier getQualifier(Uint32 pos) const |
|
{ |
|
_checkRep(); |
|
return _rep->getQualifier(pos); |
|
} |
|
|
|
void removeQualifier(Uint32 pos) |
|
{ |
|
_checkRep(); |
|
_rep->removeQualifier(pos); |
|
} |
|
|
|
/** getQualifierCount - Gets the numbercount of CIMQualifierobjects |
|
defined for this CIMObject. |
|
@return Count of the number of CIMQalifier objects in the |
|
CIMObject. |
|
@exception Throws the OutOfBounds exception if the index |
|
is out of bounds |
|
*/ |
|
Uint32 getQualifierCount() const |
|
{ |
|
_checkRep(); |
|
return _rep->getQualifierCount(); |
|
} |
|
|
|
/** addProperty - Adds a property object defined by the input |
|
parameter to the CIMObject |
|
@param Property Object to be added. See the CIM Property |
|
class for definition of the property object |
|
@return ATTN: |
|
@exception Throws the exception AlreadyExists if the property |
|
already exists. |
|
*/ |
|
CIMObject& addProperty(const CIMProperty& x) |
|
{ |
|
_checkRep(); |
|
_rep->addProperty(x); |
return *this; | return *this; |
} | } |
| |
CIMObject& operator=(const CIMClass& x) |
/** findProperty - Searches the CIMProperty objects installed in the |
|
CIMObject for property objects with the name defined by the |
|
input. |
|
@param String with the name of the property object to be found |
|
@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 |
|
input. |
|
*/ |
|
Uint32 findProperty(const String& name) |
|
{ |
|
_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 |
|
{ |
|
_checkRep(); |
|
return _rep->existsProperty(name); |
|
} |
|
|
|
/** getProperty - Gets the CIMproperty object in the CIMObject defined |
|
by the input index parameter. |
|
@param Index to the property object in the CIMObject. |
|
The index to qualifier objects is zero-origin and continuous |
|
so that incrementing loops can be used to get all qualifier |
|
objects in a CIMObject. |
|
@return CIMProperty object corresponding to the index. |
|
@exception Throws the OutOfBounds exception if the index |
|
is out of bounds |
|
|
|
ATTN: What is the effect of out of range? |
|
*/ |
|
CIMProperty getProperty(Uint32 pos) |
|
{ |
|
_checkRep(); |
|
return _rep->getProperty(pos); |
|
} |
|
|
|
/** getProperty - Gets the CIMproperty object in the CIMObject defined |
|
by the input index parameter. |
|
@param Index to the property object in the CIMObject. |
|
The index to qualifier objects is zero-origin and continuous |
|
so that incrementing loops can be used to get all qualifier |
|
objects in a CIMInstnace. |
|
@return CIMProperty object corresponding to the index. |
|
@exception Throws the OutOfBounds exception if the index |
|
is out of bounds |
|
|
|
ATTN: What is the effect of out of range? |
|
*/ |
|
CIMConstProperty getProperty(Uint32 pos) const |
|
{ |
|
_checkRep(); |
|
return _rep->getProperty(pos); |
|
} |
|
|
|
/** removeProperty - Removes the property represented |
|
by the position input parameter from the instance. |
|
@param pos Index to the property to be removed from the |
|
instance. Normally this is obtained by getProperty(); |
|
@exception Throws OutofBounds if index is not a property object |
|
*/ |
|
void removeProperty(Uint32 pos) |
|
{ |
|
_checkRep(); |
|
_rep->removeProperty(pos); |
|
} |
|
|
|
/** getPropertyCount - Gets the numbercount of CIMProperty |
|
objects defined for this CIMObject. |
|
@return Count of the number of CIMProperty objects in the |
|
CIMObject. Zero indicates that no CIMProperty objects |
|
are contained in the CIMObject |
|
@exception Throws the OutOfBounds exception if the index |
|
is out of bounds |
|
|
|
*/ |
|
Uint32 getPropertyCount() const |
|
{ |
|
_checkRep(); |
|
return _rep->getPropertyCount(); |
|
} |
|
|
|
/** operator int() - ATTN: */ |
|
operator int() const { return _rep != 0; } |
|
|
|
/** Returns true if the two classes are structurally identical. |
|
*/ |
|
Boolean identical(const CIMConstObject& x) const; |
|
|
|
/** Convert object to XML format. |
|
*/ |
|
void toXml(Array<Sint8>& out) const |
|
{ |
|
_checkRep(); |
|
_rep->toXml(out); |
|
} |
|
|
|
/** Clones the given object. |
|
*/ |
|
CIMObject clone() const |
|
{ |
|
_checkRep(); |
|
return CIMObject(_rep->clone()); |
|
} |
|
|
|
private: |
|
|
|
CIMObject(CIMObjectRep* rep) : _rep(rep) |
|
{ |
|
|
|
} |
|
|
|
void _checkRep() const |
|
{ |
|
if (!_rep) |
|
ThrowUnitializedHandle(); |
|
} |
|
|
|
CIMObjectRep* _rep; |
|
|
|
friend class CIMConstObject; |
|
friend class CIMClass; |
|
friend class CIMConstClass; |
|
friend class CIMInstance; |
|
friend class CIMConstInstance; |
|
}; |
|
|
|
//////////////////////////////////////////////////////////////////////////////// |
|
// |
|
// CIMConstObject |
|
// |
|
//////////////////////////////////////////////////////////////////////////////// |
|
|
|
class PEGASUS_COMMON_LINKAGE CIMConstObject |
|
{ |
|
public: |
|
|
|
CIMConstObject() : _rep(0) |
|
{ |
|
|
|
} |
|
|
|
CIMConstObject(const CIMConstObject& x) |
|
{ |
|
Inc(_rep = x._rep); |
|
} |
|
|
|
CIMConstObject(const CIMObject& x) |
|
{ |
|
Inc(_rep = x._rep); |
|
} |
|
|
|
/** Construction from CIMClass. |
|
*/ |
|
CIMConstObject(const CIMClass& x); |
|
|
|
/** Construction from CIMInstance. |
|
*/ |
|
CIMConstObject(const CIMInstance& x); |
|
|
|
/** Construction from CIMClass. |
|
*/ |
|
CIMConstObject(const CIMConstClass& x); |
|
|
|
/** Construction from CIMInstance. |
|
*/ |
|
CIMConstObject(const CIMConstInstance& x); |
|
|
|
CIMConstObject& operator=(const CIMConstObject& x) |
{ | { |
if (x._rep != _rep) | if (x._rep != _rep) |
{ | { |
|
if (_rep) |
|
{ |
Dec(_rep); | Dec(_rep); |
|
} |
Inc(_rep = x._rep); | Inc(_rep = x._rep); |
} | } |
return *this; | return *this; |
} | } |
| |
CIMObject& operator=(const CIMInstance& x) |
CIMConstObject& operator=(const CIMObject& x) |
{ | { |
if (x._rep != _rep) | if (x._rep != _rep) |
{ | { |
|
if (_rep) |
|
{ |
Dec(_rep); | Dec(_rep); |
|
} |
Inc(_rep = x._rep); | Inc(_rep = x._rep); |
} | } |
return *this; | return *this; |
} | } |
| |
~CIMObject() |
CIMConstObject& operator=(const CIMClass& x); |
|
|
|
CIMConstObject& operator=(const CIMConstClass& x); |
|
|
|
CIMConstObject& operator=(const CIMInstance& x); |
|
|
|
CIMConstObject& operator=(const CIMConstInstance& x); |
|
|
|
~CIMConstObject() |
|
{ |
|
if (_rep) |
{ | { |
Dec(_rep); | Dec(_rep); |
} | } |
|
} |
| |
Boolean isClass() const |
const String& getClassName() const |
{ | { |
_checkRep(); | _checkRep(); |
return dynamic_cast<CIMClassRep*>(_rep) != 0; |
return _rep->getClassName(); |
} | } |
| |
Boolean isInstance() const |
const CIMReference& getPath() const |
{ | { |
_checkRep(); | _checkRep(); |
return dynamic_cast<CIMInstanceRep*>(_rep) != 0; |
return _rep->getPath(); |
} | } |
| |
/** Returns the class contained by this object (if an class). |
Uint32 findQualifier(const String& name) const |
@return CIMClass |
{ |
@exception throws TypeMismatch if object does not contain a CIMClass. |
_checkRep(); |
*/ |
return _rep->findQualifier(name); |
CIMClass getClass(); |
} |
| |
/** Const version of getClass() */ |
CIMConstQualifier getQualifier(Uint32 pos) const |
|
{ |
|
_checkRep(); |
|
return _rep->getQualifier(pos); |
|
} |
| |
CIMConstClass getClass() const; |
Uint32 getQualifierCount() const |
|
{ |
|
_checkRep(); |
|
return _rep->getQualifierCount(); |
|
} |
| |
/** Returns the instance contained by this object (if an instance). |
Uint32 findProperty(const String& name) const |
@return CIMInstance |
{ |
@exception throws TypeMismatch if object does not contain a CIMInstance. |
_checkRep(); |
*/ |
return _rep->findProperty(name); |
CIMInstance getInstance(); |
} |
| |
/** Const version of getInstance() */ |
CIMConstProperty getProperty(Uint32 pos) const |
|
{ |
|
_checkRep(); |
|
return _rep->getProperty(pos); |
|
} |
| |
CIMConstInstance getInstance() const; |
Uint32 getPropertyCount() const |
|
{ |
|
_checkRep(); |
|
return _rep->getPropertyCount(); |
|
} |
| |
operator int() const |
operator int() const { return _rep != 0; } |
|
|
|
void toXml(Array<Sint8>& out) const |
{ | { |
return _rep != 0; |
_checkRep(); |
|
_rep->toXml(out); |
} | } |
| |
void toXml(Array<Sint8>& out) const; |
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 |
|
{ |
|
return CIMObject(_rep->clone()); |
|
} |
| |
private: | private: |
| |
|
|
ThrowUnitializedHandle(); | ThrowUnitializedHandle(); |
} | } |
| |
// Point to either a CIMClass or CIMInstance: |
CIMObjectRep* _rep; |
| |
Sharable* _rep; |
friend class CIMObject; |
|
friend class CIMClass; |
|
friend class CIMConstClass; |
|
friend class CIMInstance; |
|
friend class CIMConstInstance; |
}; | }; |
| |
/** The CIMObjectWithPath encapsulates a CIMReference and CIMObject. | /** The CIMObjectWithPath encapsulates a CIMReference and CIMObject. |
|
|
{ | { |
public: | public: |
| |
|
/** Constructor |
|
*/ |
CIMObjectWithPath(); | CIMObjectWithPath(); |
| |
CIMObjectWithPath(CIMReference& reference, CIMObject& object); |
/** constructor |
|
*/ |
|
CIMObjectWithPath(const CIMReference& reference, const CIMObject& object); |
| |
|
/** Constructor - Constructs a CIMObjectWithPath Object from |
|
another CimObjectWithPath |
|
@param - ATTN |
|
*/ |
CIMObjectWithPath(const CIMObjectWithPath& x); | CIMObjectWithPath(const CIMObjectWithPath& x); |
| |
~CIMObjectWithPath(); | ~CIMObjectWithPath(); |
| |
CIMObjectWithPath& operator=(const CIMObjectWithPath& x); | CIMObjectWithPath& operator=(const CIMObjectWithPath& x); |
| |
void set(CIMReference& reference, CIMObject& object); |
/** set - |
|
*/ |
|
void set(const CIMReference& reference, const CIMObject& object); |
| |
|
/** |
|
*/ |
const CIMReference& getReference() const { return _reference; } | const CIMReference& getReference() const { return _reference; } |
| |
|
/** |
|
*/ |
const CIMObject& getObject() const { return _object; } | const CIMObject& getObject() const { return _object; } |
| |
|
/** |
|
*/ |
CIMReference& getReference() { return _reference; } | CIMReference& getReference() { return _reference; } |
| |
|
/** |
|
*/ |
CIMObject& getObject() { return _object; } | CIMObject& getObject() { return _object; } |
| |
|
/** |
|
*/ |
void toXml(Array<Sint8>& out) const; | void toXml(Array<Sint8>& out) const; |
| |
private: | private: |
|
|
| |
PEGASUS_NAMESPACE_END | PEGASUS_NAMESPACE_END |
| |
#endif /* Pegasus_CIMObject_h */ |
#endif /* Pegasus_Object_h */ |