version 1.3, 2001/07/03 14:57:38
|
version 1.44, 2005/02/05 22:59:23
|
|
|
//%///////////////////////////////////////////////////////////////////////////// |
//%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) |
|
// |
|
// Modified By: |
|
// |
|
//%///////////////////////////////////////////////////////////////////////////// | //%///////////////////////////////////////////////////////////////////////////// |
| |
#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/Linkage.h> |
#include <Pegasus/Common/CIMInstance.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 |
| |
/** 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; |
|
class CIMProperty; |
|
class CIMConstProperty; |
|
class CIMQualifier; |
|
class CIMConstQualifier; |
|
|
|
//////////////////////////////////////////////////////////////////////////////// |
|
// |
|
// CIMObject |
|
// |
|
//////////////////////////////////////////////////////////////////////////////// |
|
|
|
/** The CIMObject class is the superclass for the CIMInstance and |
|
CIMClass classes. |
|
|
|
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), _type(TYPE_NONE) |
/** Creates CIMObject instance with null values (default constructor). |
{ |
*/ |
|
CIMObject(); |
| |
} |
/** Creates a new CIMObject instance (copy constructor). |
|
@param x Specifies the name of the CIMObject instance to create. |
|
*/ |
|
CIMObject(const CIMObject& x); |
| |
CIMObject(const CIMObject& x) : _type(x._type) |
/** Construction of a CIMObject instance based on the CIMClass object. |
{ |
*/ |
Inc(_rep = x._rep); |
CIMObject(const CIMClass& x); |
} |
|
| |
CIMObject(const CIMClass& x) : _type(TYPE_CLASS) |
/** Construction of a CIMObject instance based on the CIMInstance object. |
{ |
*/ |
Inc(_rep = x._rep); |
CIMObject(const CIMInstance& x); |
} |
|
| |
CIMObject(const CIMInstance& x) : _type(TYPE_INSTANCE) |
/** Assign the values of the CIMObject instance to CIMObject. |
{ |
@param x Specifies the name of the CIMObject instance. |
Inc(_rep = x._rep); |
*/ |
} |
CIMObject& operator=(const CIMObject& x); |
| |
CIMObject& operator=(const CIMObject& x) |
/** Destroys CIMObject. |
{ |
*/ |
if (x._rep != _rep) |
~CIMObject(); |
{ |
|
Dec(_rep); |
|
Inc(_rep = x._rep); |
|
_type = x._type; |
|
} |
|
return *this; |
|
} |
|
| |
CIMObject& operator=(const CIMClass& x) |
/** Gets the ClassName of the object. |
{ |
@return ClassName of the object in a CIMName parameter. For example, |
if (x._rep != _rep) |
<pre> |
{ |
CIMName className; |
Dec(_rep); |
CIMClass myclass("myclass", "superclass"); |
Inc(_rep = x._rep); |
className = myclass.getClassName; |
_type = TYPE_CLASS; |
</pre> |
} |
*/ |
return *this; |
const CIMName& getClassName() const; |
} |
|
| |
CIMObject& operator=(const CIMInstance& x) |
/** REVIEWERS: Insert description here. |
{ |
*/ |
if (x._rep != _rep) |
const CIMObjectPath& getPath() const; |
{ |
|
Dec(_rep); |
|
Inc(_rep = x._rep); |
|
_type = TYPE_INSTANCE; |
|
} |
|
return *this; |
|
} |
|
| |
~CIMObject() |
/** Sets the object path for the object. |
{ |
@param path Specifies the CIMObjectPath that contains the object path. |
Dec(_rep); |
*/ |
} |
void setPath (const CIMObjectPath & path); |
| |
Boolean isClass() const |
/** Adds the CIMQualifier object to the instance. |
{ |
@param qualifier CIMQualifier object to add to instance. |
return _type == TYPE_CLASS; |
@return The resulting CIMObject. |
} |
@exception AlreadyExistsException True if the CIMQualifier already |
|
exists in the instance; otherwise, false. |
|
*/ |
|
CIMObject& addQualifier(const CIMQualifier& qualifier); |
| |
Boolean isInstance() const |
/** Searches the instance for the qualifier object |
{ |
defined by the input parameter. |
return _type == TYPE_INSTANCE; |
@param name CIMName that defines the qualifier object to be found. |
} |
@return Position of the qualifier to use in subsequent |
|
operations or PEG_NOT_FOUND if the qualifier is not found. |
|
*/ |
|
Uint32 findQualifier(const CIMName& name) const; |
| |
/** Returns the class contained by this object (if an class). |
/** Retrieves the qualifier object defined by the input parameter. |
@return CIMClass |
@param index Specifies the index for the qualifier object. The index to |
@exception throws TypeMismatch if object does not contain a CIMClass. |
qualifier objects is zero-origin and continuous so that |
|
incrementing loops can be used to get all qualifier |
|
objects in a CIMInstance. |
|
@return CIMQualifier object defined by the index. |
|
@exception IndexOutOfBoundsException True if the index |
|
is out of bounds; otherwise, false. |
*/ | */ |
CIMClass getClass(); |
CIMQualifier getQualifier(Uint32 index); |
| |
/** Const version of getClass() */ |
/** Retrieves the qualifier object defined by the input parameter. |
|
@param index Specifies the 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 CIMInstance. |
|
@return CIMConstQualifier object defined by the index. |
|
@exception IndexOutOfBoundsException True if the index |
|
is out of bounds; otherwise, false. |
|
*/ |
|
CIMConstQualifier getQualifier(Uint32 index) const; |
| |
CIMConstClass getClass() const; |
/** REVIEWERS: Insert description here. |
|
*/ |
|
void removeQualifier(Uint32 index); |
| |
/** Returns the instance contained by this object (if an instance). |
/** Gets the number of CIMQualifier objects defined for |
@return CIMInstance |
this CIMObject. |
@exception throws TypeMismatch if object does not contain a CIMInstance. |
@return Count of the number of CIMQualifier objects in the |
|
CIMObject. |
*/ | */ |
CIMInstance getInstance(); |
Uint32 getQualifierCount() const; |
| |
/** Const version of getInstance() */ |
/** Adds a property object defined by the input parameter to |
|
the CIMObject. |
|
@param x Property Object to be added. See the CIM Property |
|
class for definition of the property object. |
|
@return The resulting CIMObject. |
|
@exception AlreadyExistsException True if the property already exists |
|
otherwise, false. |
|
*/ |
|
CIMObject& addProperty(const CIMProperty& x); |
| |
CIMConstInstance getInstance() const; |
/** Searches the CIMProperty objects in the |
|
CIMObject for a property object with the name defined by the |
|
input parameter. |
|
@param name CIMName with the name of the property object to be found. |
|
@return Position in the CIM object of the property object if found or |
|
PEG_NOT_FOUND if no property object found with the name defined by the |
|
input parameter. |
|
*/ |
|
Uint32 findProperty(const CIMName& name) const; |
| |
operator int() const |
/** Gets the CIMProperty object in the CIMObject defined |
{ |
by the input parameter. |
return _rep != 0; |
@param index Specifies the 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 IndexOutOfBoundsException True if the index |
|
is out of bounds; otherwise, false. |
|
*/ |
|
CIMProperty getProperty(Uint32 index); |
|
|
|
/** Gets the CIMproperty object in the CIMObject defined |
|
by the input parameter. |
|
@param index Specifies the index to the property object in the CIMObject. |
|
@return CIMProperty object corresponding to the index. |
|
@exception IndexOutOfBoundsException True if the index is outside the |
|
range of properties in this object; otherwise, false. |
|
*/ |
|
CIMConstProperty getProperty(Uint32 index) const; |
|
|
|
/** Remove the specified property from the instance. |
|
@param index Specifies the index to the property to be removed from the |
|
instance. Normally this is obtained by findProperty(); |
|
@exception IndexOutOfBoundsException True if the index is outside the |
|
range of properties in this object; otherwise, false. |
|
*/ |
|
void removeProperty(Uint32 index); |
|
|
|
/** 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. |
|
*/ |
|
Uint32 getPropertyCount() const; |
|
|
|
/** Makes a deep copy (clone) of the given object. |
|
@return Copy of the CIMObject. |
|
*/ |
|
CIMObject clone() const; |
|
|
|
/** Compares with another CIM Object. |
|
@param x CIM object for comparison. |
|
@return True if the objects are identical; otherwise, false. |
|
*/ |
|
Boolean identical(const CIMConstObject& x) const; |
|
|
|
/** Determines if the object has not been initialized. |
|
@return True if the object has not been initialized; otherwise, false. |
| |
void toXml(Array<Sint8>& out) const; |
*/ |
|
Boolean isUninitialized() const; |
|
|
|
/** Returns a string representing the value of the CIMObject. |
|
With the inclusion of CIMObject as a CIMValue, the intent |
|
of the toString() method is to produce a "human-readable" string |
|
consistent with other CIMValue types. The string will be a MOF |
|
representation of the object (ie. either CIMClass or CIMInstance) |
|
using the _rep's toMof() method. |
|
@return String representing the CIMObject value. |
|
*/ |
|
String toString () const; |
|
|
|
/** Determines if the object represents a CIMClass. |
|
@return True if the object represents a CIMClass; otherwise, false. |
|
*/ |
|
Boolean isClass () const; |
|
|
|
/** Determines if the object represents a CIMInstance. |
|
@return True if the object represents a CIMInstance; otherwise, false. |
|
*/ |
|
Boolean isInstance () const; |
| |
private: | private: |
| |
void _checkRep() const |
CIMObjectRep* _rep; |
{ |
|
if (!_rep) |
|
ThrowUnitializedHandle(); |
|
} |
|
| |
// Point to either a CIMClass or CIMInstance: |
CIMObject(CIMObjectRep* rep); |
| |
Sharable* _rep; |
void _checkRep() const; |
| |
enum Type { TYPE_CLASS, TYPE_INSTANCE, TYPE_NONE }; |
friend class CIMConstObject; |
Type _type; |
friend class CIMClass; |
|
friend class CIMConstClass; |
|
friend class CIMInstance; |
|
friend class CIMConstInstance; |
}; | }; |
| |
/** The CIMObjectWithPath encapsulates a CIMReference and CIMObject. |
#define PEGASUS_ARRAY_T CIMObject |
Accessors are provided for getting the two parts. Constructors are |
# include <Pegasus/Common/ArrayInter.h> |
provided for initializing it from a CIMObject. |
#undef PEGASUS_ARRAY_T |
|
|
|
//////////////////////////////////////////////////////////////////////////////// |
|
// |
|
// CIMConstObject |
|
// |
|
//////////////////////////////////////////////////////////////////////////////// |
|
|
|
/** |
|
REVIEWERS: Add class defintion here |
*/ | */ |
class PEGASUS_COMMON_LINKAGE CIMObjectWithPath |
class PEGASUS_COMMON_LINKAGE CIMConstObject |
{ | { |
public: | public: |
| |
CIMObjectWithPath(); |
/** Constructs a new CIMConstObject with null values (default constructor). |
|
*/ |
|
CIMConstObject(); |
| |
CIMObjectWithPath(const CIMReference& reference, const CIMObject& object); |
/** Constructs a new CIMConstObject. |
|
@param x Specifies the name of the CIMConstObject instance to create. |
|
*/ |
|
CIMConstObject(const CIMConstObject& x); |
|
|
|
/** Constructs a new CIMConstObject from a CIMObject instance. |
|
@param x Specifies the name of the CIMObject instance to use to create |
|
the CIMConstObject instance. |
|
*/ |
|
CIMConstObject(const CIMObject& x); |
| |
CIMObjectWithPath(const CIMObjectWithPath& x); |
/** Constructs a CIMObject instance from a CIMClass instance. |
|
@param x Specifies the name of the CIMClass instance. |
|
*/ |
|
CIMConstObject(const CIMClass& x); |
| |
~CIMObjectWithPath(); |
/** Constructs a CIMObject instance from a CIMInstance instance. |
|
@param x Specifies the name of the CIMInstance instance. |
|
*/ |
|
CIMConstObject(const CIMInstance& x); |
| |
CIMObjectWithPath& operator=(const CIMObjectWithPath& x); |
/** Constructs a CIMObject instance from a CIMConstClass instance. |
|
@param x Specifies the name of the CIMConstClass instance. |
|
*/ |
|
CIMConstObject(const CIMConstClass& x); |
| |
void set(const CIMReference& reference, const CIMObject& object); |
/** Constructs a CIMObject instance from a CIMConstInstance instance. |
|
@param x Specifies the name of the CIMConstInstance instance. |
|
*/ |
|
CIMConstObject(const CIMConstInstance& x); |
| |
const CIMReference& getReference() const { return _reference; } |
/** REVIEWERS: Insert description here. |
|
@param x Specifies the name of the CIMConstObject instance. |
|
*/ |
|
CIMConstObject& operator=(const CIMConstObject& x); |
| |
const CIMObject& getObject() const { return _object; } |
/** CIMConstObject destructor. |
|
*/ |
|
~CIMConstObject(); |
| |
CIMReference& getReference() { return _reference; } |
/** REVIEWERS: Insert description here. |
|
*/ |
|
const CIMName& getClassName() const; |
| |
CIMObject& getObject() { return _object; } |
/** REVIEWERS: Insert description here. |
|
*/ |
|
const CIMObjectPath& getPath() const; |
| |
void toXml(Array<Sint8>& out) const; |
/** REVIEWERS: Insert description here. |
|
@param name Specifies the name of the CIMName instance. |
|
*/ |
|
Uint32 findQualifier(const CIMName& name) const; |
|
|
|
/** REVIEWERS: Insert description here. |
|
@param index Specifies the name of the Uint32 instance. |
|
*/ |
|
CIMConstQualifier getQualifier(Uint32 index) const; |
|
|
|
/** REVIEWERS: Insert description here. |
|
*/ |
|
Uint32 getQualifierCount() const; |
|
|
|
/** REVIEWERS: Insert description here. |
|
@param name Specifies the name of the CIMName instance. |
|
*/ |
|
Uint32 findProperty(const CIMName& name) const; |
|
|
|
/** REVIEWERS: Insert description here. |
|
@param index Specifies the name of the Uint32 instance. |
|
*/ |
|
CIMConstProperty getProperty(Uint32 index) const; |
|
|
|
/** REVIEWERS: Insert description here. |
|
*/ |
|
Uint32 getPropertyCount() const; |
|
|
|
/** REVIEWERS: Insert description here. |
|
*/ |
|
CIMObject clone() const; |
|
|
|
/** REVIEWERS: Insert description here. |
|
*/ |
|
Boolean identical(const CIMConstObject& x) const; |
|
|
|
/** REVIEWERS: Insert description here. |
|
*/ |
|
Boolean isUninitialized() const; |
|
|
|
/** Returns a string representing the value of the CIMObject. |
|
With the inclusion of CIMObject as a CIMValue, the intent |
|
of the toString() method is to produce a "human-readable" string |
|
consistent with other CIMValue types. The string will be a MOF |
|
representation of the object (ie. either CIMClass or CIMInstance) |
|
using the _rep's toMof() method. |
|
@return String representing the CIMObject value. |
|
*/ |
|
String toString () const; |
|
|
|
/** REVIEWERS: Insert description here. |
|
*/ |
|
Boolean isClass() const; |
|
|
|
/** REVIEWERS: Insert description here. |
|
*/ |
|
Boolean isInstance() const; |
| |
private: | private: |
| |
CIMReference _reference; |
CIMObjectRep* _rep; |
CIMObject _object; |
|
|
void _checkRep() const; |
|
|
|
friend class CIMObject; |
|
friend class CIMClass; |
|
friend class CIMConstClass; |
|
friend class CIMInstance; |
|
friend class CIMConstInstance; |
}; | }; |
| |
PEGASUS_NAMESPACE_END | PEGASUS_NAMESPACE_END |
| |
#endif /* Pegasus_CIMObject_h */ |
#endif /* Pegasus_Object_h */ |