version 1.1, 2001/07/01 22:21:57
|
version 1.24, 2002/05/23 16:52:14
|
|
|
// | // |
// 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) |
// | // |
//%///////////////////////////////////////////////////////////////////////////// | //%///////////////////////////////////////////////////////////////////////////// |
| |
#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/String.h> |
#include <Pegasus/Common/CIMInstance.h> |
#include <Pegasus/Common/Array.h> |
|
#include <Pegasus/Common/CIMProperty.h> |
|
#include <Pegasus/Common/CIMQualifier.h> |
| |
PEGASUS_NAMESPACE_BEGIN | PEGASUS_NAMESPACE_BEGIN |
| |
/** This class contains either a class or an instance (both CIM objects). |
class CIMConstObject; |
Initializers are provided for both CIMClass and CIMInstance. The |
class CIMObjectRep; |
isClass() and isInstance() methods are provided for determining the |
class CIMClass; |
type of contained object. Methods are also provided for getting |
class CIMConstClass; |
the internal object (into a CIMClass or CIMInstance). |
class CIMInstance; |
|
class CIMConstInstance; |
|
|
|
//////////////////////////////////////////////////////////////////////////////// |
|
// |
|
// 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: |
| |
CIMObject() : _rep(0) |
/** Constructor. |
{ |
*/ |
|
CIMObject(); |
| |
} |
/** Copy constructor. |
|
*/ |
|
CIMObject(const CIMObject& x); |
| |
CIMObject(const CIMObject& x) |
/** Construction from CIMClass. |
{ |
*/ |
Inc(_rep = x._rep); |
CIMObject(const CIMClass& x); |
} |
|
| |
CIMObject(const CIMClass& x) |
/** Construction from CIMInstance. |
{ |
*/ |
Inc(_rep = x._rep); |
CIMObject(const CIMInstance& x); |
} |
|
| |
CIMObject(const CIMInstance& x) |
/** Assignment operator. |
{ |
*/ |
Inc(_rep = x._rep); |
CIMObject& operator=(const CIMObject& x); |
} |
|
| |
CIMObject& operator=(const CIMObject& x) |
/** Assignment operator. |
{ |
*/ |
if (x._rep != _rep) |
CIMObject& operator=(const CIMClass& x); |
{ |
|
Dec(_rep); |
|
Inc(_rep = x._rep); |
|
} |
|
return *this; |
|
} |
|
| |
CIMObject& operator=(const CIMClass& x) |
/** Assignment operator. |
{ |
*/ |
if (x._rep != _rep) |
CIMObject& operator=(const CIMInstance& x); |
{ |
|
Dec(_rep); |
|
Inc(_rep = x._rep); |
|
} |
|
return *this; |
|
} |
|
| |
CIMObject& operator=(const CIMInstance& x) |
/** Destructor. |
{ |
*/ |
if (x._rep != _rep) |
~CIMObject(); |
{ |
|
Dec(_rep); |
|
Inc(_rep = x._rep); |
|
} |
|
return *this; |
|
} |
|
| |
~CIMObject() |
/** Accessor for ClassName component of the object. |
{ |
@return - Returns the ClassName of the object in |
Dec(_rep); |
a String parameter. |
} |
<pre> |
|
String className; |
|
CIMClass myclass("myclass", "superclass"); |
|
className = myclass.getClassName; |
|
</pre> |
|
*/ |
|
const String& getClassName() const; |
| |
Boolean isClass() const |
const CIMObjectPath& getPath() const; |
{ |
|
_checkRep(); |
|
return dynamic_cast<CIMClassRep*>(_rep) != 0; |
|
} |
|
| |
Boolean isInstance() const |
/** |
{ |
Sets the object path for the object |
_checkRep(); |
@param path CIMObjectPath containing the object path |
return dynamic_cast<CIMInstanceRep*>(_rep) != 0; |
*/ |
} |
void setPath (const CIMObjectPath & path); |
| |
/** Returns the class contained by this object (if an class). |
/** addQualifier - Adds the CIMQualifier object to the instance. |
@return CIMClass |
Thows an exception of the CIMQualifier already exists in the instance |
@exception throws TypeMismatch if object does not contain a CIMClass. |
@param CIMQualifier object to add to instance |
|
@return ATTN: |
|
@exception Throws AlreadyExists. |
*/ | */ |
CIMClass getClass(); |
CIMObject& addQualifier(const CIMQualifier& qualifier); |
| |
/** Returns the instance contained by this object (if an instance). |
/** findQualifier - Searches the instance for the qualifier object |
@return CIMInstance |
defined by the input parameter. |
@exception throws TypeMismatch if object does not contain a CIMInstance. |
@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. |
*/ | */ |
CIMInstance getInstance(); |
Uint32 findQualifier(const String& name) const; |
| |
operator int() const |
/** existsQualifier - Searches the instance for the qualifier object |
{ |
defined by the input parameter. |
return _rep != 0; |
@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) const; |
|
|
|
/** 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); |
|
|
|
/** 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; |
|
|
|
void removeQualifier(Uint32 pos); |
|
|
|
/** getQualifierCount - Gets the number of CIMQualifier objects |
|
defined for this CIMObject. |
|
@return Count of the number of CIMQualifier objects in the |
|
CIMObject. |
|
@exception Throws the OutOfBounds exception if the index |
|
is out of bounds |
|
*/ |
|
Uint32 getQualifierCount() const; |
|
|
|
/** 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); |
|
|
|
/** 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) const; |
|
|
|
/** existsProperty - 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) const; |
|
|
|
/** 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); |
|
|
|
/** 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; |
|
|
|
/** 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); |
|
|
|
/** getPropertyCount - Gets the number 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; |
|
|
|
/** Clones the given object. |
|
*/ |
|
CIMObject clone() const; |
|
|
|
/** Returns true if the two classes are structurally identical. |
|
*/ |
|
Boolean identical(const CIMConstObject& x) const; |
|
|
|
#ifdef PEGASUS_INTERNALONLY |
|
/** isNull() - ATTN: */ |
|
Boolean isNull() const; |
|
#endif |
| |
private: | private: |
| |
void _checkRep() const |
CIMObjectRep* _rep; |
|
|
|
#ifdef PEGASUS_INTERNALONLY |
|
CIMObject(CIMObjectRep* rep); |
|
|
|
void _checkRep() const; |
|
|
|
friend class CIMConstObject; |
|
friend class CIMClass; |
|
friend class CIMConstClass; |
|
friend class CIMInstance; |
|
friend class CIMConstInstance; |
|
#endif |
|
}; |
|
|
|
//////////////////////////////////////////////////////////////////////////////// |
|
// |
|
// CIMConstObject |
|
// |
|
//////////////////////////////////////////////////////////////////////////////// |
|
|
|
class PEGASUS_COMMON_LINKAGE CIMConstObject |
{ | { |
if (!_rep) |
public: |
ThrowUnitializedHandle(); |
|
} |
CIMConstObject(); |
|
|
|
CIMConstObject(const CIMConstObject& x); |
|
|
|
CIMConstObject(const CIMObject& x); |
|
|
|
/** 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); |
|
|
|
CIMConstObject& operator=(const CIMObject& x); |
| |
// Point to either a CIMClass or CIMInstance: |
CIMConstObject& operator=(const CIMClass& x); |
| |
Sharable* _rep; |
CIMConstObject& operator=(const CIMConstClass& x); |
|
|
|
CIMConstObject& operator=(const CIMInstance& x); |
|
|
|
CIMConstObject& operator=(const CIMConstInstance& x); |
|
|
|
~CIMConstObject(); |
|
|
|
const String& getClassName() const; |
|
|
|
const CIMObjectPath& getPath() const; |
|
|
|
Uint32 findQualifier(const String& name) const; |
|
|
|
CIMConstQualifier getQualifier(Uint32 pos) const; |
|
|
|
Uint32 getQualifierCount() const; |
|
|
|
Uint32 findProperty(const String& name) const; |
|
|
|
CIMConstProperty getProperty(Uint32 pos) const; |
|
|
|
Uint32 getPropertyCount() const; |
|
|
|
CIMObject clone() const; |
|
|
|
Boolean identical(const CIMConstObject& x) const; |
|
|
|
#ifdef PEGASUS_INTERNALONLY |
|
Boolean isNull() const; |
|
#endif |
|
|
|
private: |
|
|
|
CIMObjectRep* _rep; |
|
|
|
#ifdef PEGASUS_INTERNALONLY |
|
void _checkRep() const; |
|
|
|
friend class CIMObject; |
|
friend class CIMClass; |
|
friend class CIMConstClass; |
|
friend class CIMInstance; |
|
friend class CIMConstInstance; |
|
#endif |
}; | }; |
| |
/** The CIMObjectWithPath encapsulates a CIMReference and CIMObject. |
/** The CIMObjectWithPath encapsulates a CIMObjectPath and CIMObject. |
Accessors are provided for getting the two parts. Constructors are | Accessors are provided for getting the two parts. Constructors are |
provided for initializing it from a CIMObject. | provided for initializing it from a CIMObject. |
*/ | */ |
|
|
{ | { |
public: | public: |
| |
|
/** Constructor |
|
*/ |
CIMObjectWithPath(); | CIMObjectWithPath(); |
| |
CIMObjectWithPath(CIMReference& reference, CIMObject& object); |
/** constructor |
|
*/ |
|
CIMObjectWithPath(const CIMObjectPath& 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 CIMObjectPath& reference, const CIMObject& object); |
| |
const CIMReference& getReference() const { return _reference; } |
/** |
|
*/ |
|
const CIMObjectPath& getReference() const; |
| |
const CIMObject& getObject() const { return _object; } |
/** |
|
*/ |
|
const CIMObject& getObject() const; |
| |
CIMReference& getReference() { return _reference; } |
/** |
|
*/ |
|
CIMObjectPath& getReference(); |
| |
CIMObject& getObject() { return _object; } |
/** |
|
*/ |
|
CIMObject& getObject(); |
| |
private: | private: |
| |
CIMReference _reference; |
CIMObjectPath _reference; |
CIMObject _object; | CIMObject _object; |
}; | }; |
| |
PEGASUS_NAMESPACE_END | PEGASUS_NAMESPACE_END |
| |
#endif /* Pegasus_CIMObject_h */ |
#endif /* Pegasus_Object_h */ |