OWBI1::CIMInstance Class Reference

The CIMInstance class encapsulates all information pertinent to a CIMInstance. More...

#include <OWBI1_CIMInstance.hpp>

Inheritance diagram for OWBI1::CIMInstance:

Inheritance graph
[legend]
Collaboration diagram for OWBI1::CIMInstance:

Collaboration graph
[legend]
List of all members.

Public Types

typedef detail::CIMInstanceRepRef
CIMInstance::* 
safe_bool
enum  { SERIALIZATION_VERSION = 1 }
enum  EErrorCodes { E_INSTANCE_HAS_NO_SUCH_PROPERTY }

Public Member Functions

 CIMInstance ()
 Default ctor.
 CIMInstance (CIMNULL_t)
 This CIMInstance object will be NULL.
 CIMInstance (const CIMInstance &arg)
 Copy ctor.
 CIMInstance (const CIMName &name)
 Create an CIMInstance.
 CIMInstance (const char *name)
 Create an CIMInstance.
 CIMInstance (const detail::CIMInstanceRepRef &rep)
 ~CIMInstance ()
 Destroy this CIMInstance object.
virtual void setNull ()
 Set this to a null object.
CIMInstanceoperator= (const CIMInstance &arg)
 Assignment operator.
CIMName getClassName () const
CIMInstancesetKeys (const CIMPropertyArray &keys)
 Set the keys for this instance.
CIMInstancesetClassName (const CIMName &name)
 Sets the class name for this instance.
String getLanguage () const
void setLanguage (const String &language)
 Set the language this CIMClass is using.
CIMPropertyArray getProperties (Int32 valueDataType=CIMDataType::INVALID) const
 Get all the properties of a specific datatype from this instance.
CIMInstancesetProperties (const CIMPropertyArray &props)
 Set the properties associated with this instance.
CIMProperty getProperty (const CIMName &name, const CIMName &originClass) const
 Get the property identified by a given name and origin class.
CIMProperty getProperty (const CIMName &name) const
 Gets a property with the specified name.
CIMProperty getPropertyT (const CIMName &name) const
 Gets a property with the specified name.
CIMValue getPropertyValue (const CIMName &name) const
 Gets a property's value.
bool propertyHasValue (const CIMName &name) const
 Test whether a property exists and has a non-NULL value.
CIMPropertyArray getKeyValuePairs () const
CIMInstanceupdatePropertyValues (const CIMPropertyArray &props)
 Update the property values for this instance.
CIMInstanceupdatePropertyValue (const CIMProperty &prop)
 Update a single property value.
CIMInstanceupdatePropertyValue (const CIMName &name, const CIMValue &cv)
 Update a single property value.
CIMInstancesetProperty (const CIMName &name, const CIMValue &cv)
 Update the value of a property if it exists.
CIMInstancesetProperty (const CIMProperty &prop)
 Update a property in the property list if it exists.
CIMInstanceremoveProperty (const CIMName &propName)
 Remove a property from this CIMInstance.
CIMInstance clone (const CIMPropertyList &propertyList=CIMPropertyList()) const
 Create a new CIMInstance from this CIMInstance using the specified criteria.
CIMInstancesyncWithClass (const CIMClass &cc)
 Synchronize this instance with the given class.
CIMInstance createModifiedInstance (const CIMInstance &previousInstance, const CIMPropertyList &propertyList, const CIMClass &theClass) const
 Create an instance with the set of changes that will occur for a modifyInstance call.
virtual CIMName getName () const
virtual void setName (const CIMName &name)
 Sets the class name for this instance.
virtual void readObject (std::istream &istrm)
 Read this CIMInstance from an input stream.
virtual void writeObject (std::ostream &ostrm) const
 Write this CIMInstance to an output stream.
virtual String toMOF () const
virtual String toString () const
bool propertiesAreEqualTo (const CIMInstance &other) const
 This compares the properties of the instances, and returns true if they are equal.
 operator safe_bool () const
bool operator! () const
detail::CIMInstanceRepRef getRep () const

Protected Member Functions

void _buildKeys ()

Protected Attributes

detail::CIMInstanceRepRef m_rep

Friends

OWBI1_OWBI1PROVIFC_API bool operator< (const CIMInstance &x, const CIMInstance &y)

Detailed Description

The CIMInstance class encapsulates all information pertinent to a CIMInstance.

CIMInstances are ref counted, copy on write objects. It is possible to have an CIMInstance object that is NULL. The method to check for this condition is as follows:

CIMInstance ci = ch.getInstance(...); if (!ci) { // Null instance } else { // Valid instance }

Providers generally follow these steps to create a CIMInstance object:

1. Obtain a CIMOMHandleIFC object hdl.

2. Use hdl to create a CIMClass object of the desired CIM class:

CIMClass cc = hdl.getClass(namespace, class_name);

3. Use CIMClass cc to create a CIMInstance of the desired CIM class:

CIMInstance inst = cc.newInstance();

4. Assign properties of inst as desired using setProperty().

Definition at line 81 of file OWBI1_CIMInstance.hpp.


Member Typedef Documentation

typedef detail::CIMInstanceRepRef CIMInstance::* OWBI1::CIMInstance::safe_bool
 

Definition at line 343 of file OWBI1_CIMInstance.hpp.


Member Enumeration Documentation

anonymous enum
 

Enumerator:
SERIALIZATION_VERSION 

Definition at line 84 of file OWBI1_CIMInstance.hpp.

enum OWBI1::CIMInstance::EErrorCodes
 

Enumerator:
E_INSTANCE_HAS_NO_SUCH_PROPERTY 

Reimplemented from OWBI1::CIMBase.

Definition at line 86 of file OWBI1_CIMInstance.hpp.


Constructor & Destructor Documentation

CIMInstance::CIMInstance  ) 
 

Default ctor.

Definition at line 56 of file OWBI1_CIMInstance.cpp.

CIMInstance::CIMInstance CIMNULL_t   )  [explicit]
 

This CIMInstance object will be NULL.

All subsequent operations on an instance of this type will fail.

Definition at line 61 of file OWBI1_CIMInstance.cpp.

CIMInstance::CIMInstance const CIMInstance arg  ) 
 

Copy ctor.

Parameters:
arg The CIMInstance that this object will be a copy of.

Definition at line 76 of file OWBI1_CIMInstance.cpp.

CIMInstance::CIMInstance const CIMName name  )  [explicit]
 

Create an CIMInstance.

Parameters:
name The class name of this CIMInstance.

Definition at line 71 of file OWBI1_CIMInstance.cpp.

CIMInstance::CIMInstance const char *  name  )  [explicit]
 

Create an CIMInstance.

Parameters:
name The class name of this CIMInstance as a NULL terminated string.

Definition at line 66 of file OWBI1_CIMInstance.cpp.

OWBI1::CIMInstance::CIMInstance const detail::CIMInstanceRepRef rep  )  [explicit]
 

CIMInstance::~CIMInstance  ) 
 

Destroy this CIMInstance object.

Definition at line 81 of file OWBI1_CIMInstance.cpp.


Member Function Documentation

void CIMInstance::_buildKeys  )  [protected]
 

Definition at line 214 of file OWBI1_CIMInstance.cpp.

References i.

CIMInstance CIMInstance::clone const CIMPropertyList propertyList = CIMPropertyList()  )  const
 

Create a new CIMInstance from this CIMInstance using the specified criteria.

Parameters:
propertyList An array of property names that specifies the only properties to be included in the returned instance.
Returns:
An CIMInstance object based on this one, filtered according to the specified criteria.

Definition at line 383 of file OWBI1_CIMInstance.cpp.

References OWBI1::Array< T >::append(), i, m_rep, and propertyList.

Referenced by OWBI1::BI1SimpleInstanceProviderIFC::getInstance().

CIMInstance CIMInstance::createModifiedInstance const CIMInstance previousInstance,
const CIMPropertyList propertyList,
const CIMClass theClass
const
 

Create an instance with the set of changes that will occur for a modifyInstance call.

This instance is the new instance. The previous instance is passed in. The instance that is returned is what the new instance will be after modifyInstance is applied.

Parameters:
previousInstance The instance before being modified.
propertyList "If the PropertyList input parameter is not NULL, the members of the array define one or more Property names. Only those properties specified in the PropertyList are modified as specified in the ModifiedInstance. Properties of the ModifiedInstance that are missing from the PropertyList are ignored. If the PropertyList input parameter is an empty array this signifies that no Properties are explicitly modified in the specified Instance. If the PropertyList input parameter is NULL this specifies that all Properties are updated in the specified Instance."
theClass The class of this instance.

Definition at line 477 of file OWBI1_CIMInstance.cpp.

References OWBI1::Array< T >::begin(), OWBI1::Array< T >::end(), getProperties(), OWBI1::CIMClass::getProperty(), getProperty(), OWBI1::CIMProperty::getQualifiers(), i, propertyList, removeProperty(), setProperties(), setProperty(), OWBI1::CIMProperty::setQualifiers(), and theClass.

CIMName CIMInstance::getClassName  )  const
 

Returns:
The name of the class for this instance.

Definition at line 107 of file OWBI1_CIMInstance.cpp.

CIMPropertyArray CIMInstance::getKeyValuePairs  )  const
 

Returns:
An CIMPropertyArray that contains all of the keys for this instance.

Definition at line 229 of file OWBI1_CIMInstance.cpp.

Referenced by OWBI1::CIMObjectPath::setKeys().

String CIMInstance::getLanguage  )  const
 

Returns:
the language this CIMClass is using

Definition at line 113 of file OWBI1_CIMInstance.cpp.

CIMName CIMInstance::getName  )  const [virtual]
 

Returns:
The name of the class for this instance.

Implements OWBI1::CIMElement.

Definition at line 404 of file OWBI1_CIMInstance.cpp.

CIMPropertyArray CIMInstance::getProperties Int32  valueDataType = CIMDataType::INVALID  )  const
 

Get all the properties of a specific datatype from this instance.

Parameters:
valueDataType All properties returned must have this datatype. If CIMDataType::INVALID is specified, all properties will be returned.
Returns:
The properties associated with this instance if valueDataType is CIMDataType::INVALID. Otherwise only properties that have a values that have a data type specified by the valueDataType parameter.

Definition at line 132 of file OWBI1_CIMInstance.cpp.

References OWBI1::detail::unwrapArray().

Referenced by createModifiedInstance(), and propertiesAreEqualTo().

CIMProperty CIMInstance::getProperty const CIMName name  )  const
 

Gets a property with the specified name.

Parameters:
name The name of the property to retrieve.
Returns:
The CIMProperty identified by the name on success. Otherwise a null CIMProperty object.

Definition at line 157 of file OWBI1_CIMInstance.cpp.

References i.

CIMProperty CIMInstance::getProperty const CIMName name,
const CIMName originClass
const
 

Get the property identified by a given name and origin class.

Parameters:
name The name of the property to retrieve.
originClass The name of the origin class of the property.
Returns:
The CIMProperty identified by the given parameters on success. Otherwise a null CIMProperty object.

Definition at line 150 of file OWBI1_CIMInstance.cpp.

References OWBI1::CIMName::getRep(), and name.

Referenced by createModifiedInstance().

CIMProperty CIMInstance::getPropertyT const CIMName name  )  const
 

Gets a property with the specified name.

Parameters:
name The name of the property to retrieve.
Returns:
The CIMProperty identified by the name on success.
Exceptions:
an NoSuchPropertyException (E_INSTANCE_HAS_NO_SUCH_PROPERTY) if the property is not found or NULL.

Definition at line 172 of file OWBI1_CIMInstance.cpp.

References OWBI1::String::c_str(), OWBI1_THROW_ERR, and OWBI1::CIMName::toString().

CIMValue CIMInstance::getPropertyValue const CIMName name  )  const
 

Gets a property's value.

Parameters:
name The name of the property value to retrieve.
Returns:
The CIMValue of the specified property. It will be NULL if the property doesn't exist or the property's value is NULL.

Definition at line 183 of file OWBI1_CIMInstance.cpp.

References OW_NAMESPACE::CIMNULL, OWBI1::CIMProperty::getValue(), and name.

CIMInstanceRepRef CIMInstance::getRep  )  const
 

Definition at line 711 of file OWBI1_CIMInstance.cpp.

Referenced by OWBI1::detail::convertCIMInstance().

CIMInstance::safe_bool CIMInstance::operator CIMInstance::safe_bool  )  const
 

Definition at line 699 of file OWBI1_CIMInstance.cpp.

References m_rep.

bool CIMInstance::operator!  )  const
 

Definition at line 705 of file OWBI1_CIMInstance.cpp.

CIMInstance & CIMInstance::operator= const CIMInstance arg  ) 
 

Assignment operator.

Parameters:
arg The CIMInstance to assign to this one.
Returns:
A reference to this object after the assignment is made.

Definition at line 91 of file OWBI1_CIMInstance.cpp.

References m_rep.

bool CIMInstance::propertiesAreEqualTo const CIMInstance other  )  const
 

This compares the properties of the instances, and returns true if they are equal.

It will sort the properties before comparing, so the order of the properties is irrelevant.

Parameters:
other The instance to compare
Returns:
true if the properties are the same

Definition at line 668 of file OWBI1_CIMInstance.cpp.

References getProperties(), and OWBI1::Array< T >::size().

bool CIMInstance::propertyHasValue const CIMName name  )  const
 

Test whether a property exists and has a non-NULL value.

Parameters:
name The name of the property to test.
Returns:
bool true if the property exists and has a non-NULL value.

Definition at line 194 of file OWBI1_CIMInstance.cpp.

References OWBI1::CIMProperty::getValue(), and name.

virtual void OWBI1::CIMInstance::readObject std::istream &  istrm  )  [virtual]
 

Read this CIMInstance from an input stream.

Parameters:
istrm The input stream to read this object from.

Implements OWBI1::SerializableIFC.

CIMInstance & CIMInstance::removeProperty const CIMName propName  ) 
 

Remove a property from this CIMInstance.

Parameters:
propName The name of the property to remove.
Returns:
a reference to *this

Definition at line 362 of file OWBI1_CIMInstance.cpp.

References i.

Referenced by createModifiedInstance().

CIMInstance & CIMInstance::setClassName const CIMName name  ) 
 

Sets the class name for this instance.

Parameters:
name The new class name for this instance.
Returns:
a reference to *this

Definition at line 125 of file OWBI1_CIMInstance.cpp.

References name.

Referenced by OWBI1::CIMClass::newInstance().

CIMInstance & CIMInstance::setKeys const CIMPropertyArray keys  ) 
 

Set the keys for this instance.

Returns:
a reference to *this

Definition at line 98 of file OWBI1_CIMInstance.cpp.

References OWBI1::detail::unwrapArray().

void CIMInstance::setLanguage const String language  ) 
 

Set the language this CIMClass is using.

Parameters:
language The new language for this CIMClass

Definition at line 119 of file OWBI1_CIMInstance.cpp.

References OWBI1::String::c_str().

void CIMInstance::setName const CIMName name  )  [virtual]
 

Sets the class name for this instance.

Parameters:
name The new class name for this instance.
Returns:
a reference to *this

Implements OWBI1::CIMElement.

Definition at line 518 of file OWBI1_CIMInstance.cpp.

References name.

void CIMInstance::setNull  )  [virtual]
 

Set this to a null object.

All subsequent operation will fail after this call is made.

Implements OWBI1::CIMBase.

Definition at line 86 of file OWBI1_CIMInstance.cpp.

CIMInstance & CIMInstance::setProperties const CIMPropertyArray props  ) 
 

Set the properties associated with this instance.

Note: this will clobber qualifiers associated with the properties which may already exist on the instance. You may want to instead consider updatePropertyValues(), which does not overwrite qualifiers.

Parameters:
props An CIMPropertyArray that contains the new properties for this instance.
Returns:
a reference to *this

Definition at line 141 of file OWBI1_CIMInstance.cpp.

References OWBI1::detail::unwrapArray().

Referenced by createModifiedInstance().

CIMInstance & CIMInstance::setProperty const CIMProperty prop  ) 
 

Update a property in the property list if it exists.

Otherwise add a new one. In most cases, updatePropertyValue() should be called instead of this function, because it won't add a new property. An instance is initialized will all it's properties by CIMClass::newInstance().

Parameters:
prop The property to add or update.
Returns:
a reference to *this

Definition at line 327 of file OWBI1_CIMInstance.cpp.

References OWBI1::CIMProperty::getName(), i, and OWBI1::CIMProperty::isKey().

CIMInstance & CIMInstance::setProperty const CIMName name,
const CIMValue cv
 

Update the value of a property if it exists.

Otherwise add a new one. In most cases, updatePropertyValue() should be called instead of this function, because it won't add a new property. An instance is initialized will all it's properties by CIMClass::newInstance().

Parameters:
name The name of the property to add or update.
cv The CIMValue that contains the new value for the property.
Returns:
a reference to *this

Definition at line 288 of file OWBI1_CIMInstance.cpp.

References i, and name.

Referenced by createModifiedInstance().

CIMInstance & CIMInstance::syncWithClass const CIMClass cc  ) 
 

Synchronize this instance with the given class.

This will ensure that all properties found on the class exist on this instance. It will also optionally move all qualifiers from the class to the instance.

Parameters:
cc The class to synchronize this instance with.
Returns:
a reference to *this

Definition at line 410 of file OWBI1_CIMInstance.cpp.

References OWBI1::CIMClass::getAllProperties(), OWBI1::CIMClass::getProperty(), i, OWBI1::Array< T >::remove(), OWBI1::Array< T >::size(), and theClass.

Referenced by OWBI1::CIMClass::newInstance().

String CIMInstance::toMOF  )  const [virtual]
 

Returns:
The MOF representation of this CIMInstance as an String.

Implements OWBI1::CIMBase.

Definition at line 567 of file OWBI1_CIMInstance.cpp.

References i.

String CIMInstance::toString  )  const [virtual]
 

Returns:
The string representation of the CIMInstance object.

Implements OWBI1::CIMElement.

Definition at line 633 of file OWBI1_CIMInstance.cpp.

References i, and OWBI1::StringBuffer::toString().

CIMInstance & CIMInstance::updatePropertyValue const CIMName name,
const CIMValue cv
 

Update a single property value.

Does not add prop is it doesn't exist.

Parameters:
name The name of the property to update.
cv The new value for the property.
Returns:
a reference to *this

Definition at line 281 of file OWBI1_CIMInstance.cpp.

References name.

CIMInstance & CIMInstance::updatePropertyValue const CIMProperty prop  ) 
 

Update a single property value.

Does not add prop is it doesn't exist.

Parameters:
prop The CIMProperty to update in this instance. This CIMProperty with contain the new value.
Returns:
a reference to *this

Definition at line 246 of file OWBI1_CIMInstance.cpp.

References OWBI1::CIMProperty::getName(), OWBI1::CIMProperty::getValue(), i, OWBI1::CIMProperty::isKey(), and name.

CIMInstance & CIMInstance::updatePropertyValues const CIMPropertyArray props  ) 
 

Update the property values for this instance.

Does not add properties if they don't exist.

Parameters:
props An CIMPropertyArray that contains the properties to update this instance's properties with.
Returns:
a reference to *this

Definition at line 235 of file OWBI1_CIMInstance.cpp.

References i, and OWBI1::Array< T >::size().

void CIMInstance::writeObject std::ostream &  ostrm  )  const [virtual]
 

Write this CIMInstance to an output stream.

Parameters:
ostrm The output stream to write this object to.

Implements OWBI1::SerializableIFC.

Definition at line 556 of file OWBI1_CIMInstance.cpp.

References OWBI1_CIMINSTANCESIG_V, and OW_NAMESPACE::writeArray().


Friends And Related Function Documentation

OWBI1_OWBI1PROVIFC_API bool operator< const CIMInstance x,
const CIMInstance y
[friend]
 

Definition at line 663 of file OWBI1_CIMInstance.cpp.


Member Data Documentation

detail::CIMInstanceRepRef OWBI1::CIMInstance::m_rep [protected]
 

Definition at line 356 of file OWBI1_CIMInstance.hpp.

Referenced by clone(), operator safe_bool(), OWBI1::operator<(), and operator=().


The documentation for this class was generated from the following files:
Generated on Thu Feb 9 09:18:06 2006 for openwbem by  doxygen 1.4.6