CIMObjectPath Class Reference

#include <CIMObjectPath.h>

List of all members.

Public Member Functions

 CIMObjectPath ()
 CIMObjectPath (const CIMObjectPath &x)
 CIMObjectPath (const String &objectName)
 CIMObjectPath (const String &host, const CIMNamespaceName &nameSpace, const CIMName &className, const Array< CIMKeyBinding > &keyBindings=Array< CIMKeyBinding >())
 ~CIMObjectPath ()
CIMObjectPathoperator= (const CIMObjectPath &x)
void clear ()
void set (const String &host, const CIMNamespaceName &nameSpace, const CIMName &className, const Array< CIMKeyBinding > &keyBindings=Array< CIMKeyBinding >())
void set (const String &objectName)
CIMObjectPathoperator= (const String &objectName)
const StringgetHost () const
void setHost (const String &host)
const CIMNamespaceNamegetNameSpace () const
void setNameSpace (const CIMNamespaceName &nameSpace)
const CIMNamegetClassName () const
void setClassName (const CIMName &className)
const Array< CIMKeyBinding > & getKeyBindings () const
void setKeyBindings (const Array< CIMKeyBinding > &keyBindings)
String toString () const
Boolean identical (const CIMObjectPath &x) const
Uint32 makeHashCode () const

Detailed Description

The CIMObjectPath class represents the DMTF standard CIM object name or reference. A reference is a property type that is used in an association. Consider this MOF example:

    [Association]
    class MyAssociations
    {
        MyClass ref from;
        MyClass ref to;
    };
    

The value of the "from" and "to" properties are represented using a CIMObjectPath.

A CIM reference is used to uniquely identify a CIM class or CIM instance object. A CIMObjectPath consists of:

  • Host - name of host that contains the object
  • NameSpace - the namespace which contains the object
  • ClassName - name of objects class
  • KeyBindings key/value pairs which uniquely identify an instance

CIM references may also be expressed as simple strings (as opposed to being represented by the CIMObjectPath class). This string is known as the "Object Name". An object name has the following form:

    <namespace-path>:<model-path>
    

As for the model-path mentioned above, its form is defined by the CIM Standard (more is defined by the "XML Mapping Specification v2.0.0" specification) as follows:

    <Qualifyingclass>.<key-1>=<value-1>[,<key-n>=
    <value-n>]*
    

For example:

    TennisPlayer.first="Patrick",last="Rafter"
    

This presupposes the existence of a class called "TennisPlayer" that has key properties named "first" and "last". For example, here is what the MOF might look like:

    class TennisPlayer : Person
    {
        [key] string first;
        [key] string last;
    };
    

All keys must be present in the model path.

Now the namespace-type and model-path are combined in the following string object name.

atp:9999/root/cimv25:TennisPlayer.first="Patrick",last="Rafter"

Now suppose we wish to create a CIMObjectPath from this above string. There are two constructors provided: one which takes the above string and the other that takes the constituent elements. Here are the signature of the two constructors:

    CIMObjectPath(const String& objectName);
    CIMObjectPath(
        const String& host,
        const CIMNamespaceName& nameSpace,
        const CIMName& className,
        const Array<CIMKeyBinding>& keyBindings);
    

Following our example, the above object name may be used to initialize a CIMObjectPath like this:

        CIMObjectPath ref =
            "//atp:9999/root/cimv25:TennisPlayer.first="Patrick",last="Rafter;
        

A CIMObjectPath may also be initialized using the constituent elements of the object name (sometimes the object name is not available as a string: this is the case with CIM XML encodings). The arguments shown in that constructor above correspond elements of the object name in the following way:

  • host = "atp:9999"
  • nameSpace = "root/cimv25"
  • className = "TennisPlayer"
  • keyBindings = "first=\"Patrick\",last=\"Rafter\""

Note that the host and nameSpace argument may be empty since object names need not necessarily include a namespace path according to the standard.

The key bindings must be built up by appending CIMKeyBinding objects to an Array of CIMKeyBindings like this:

    Array<CIMKeyBinding> keyBindings;
    keyBindings.append(
        CIMKeyBinding("first", "Patrick", CIMKeyBinding::STRING));
    keyBindings.append(CIMKeyBinding("last", "Rafter", CIMKeyBinding::STRING));
    

Notice that the keys in the object name may appear in any order. That is the following object names refer to the same object:

    TennisPlayer.first="Patrick",last="Rafter"
    TennisPlayer.last="Rafter",first="Patrick"
    

And since CIM is not case sensitive, the following refer to the same object:

    TennisPlayer.first="Patrick",last="Rafter"
    tennisplayer.FIRST="Patrick",Last="Rafter"
    

Therefore, the CIMObjectPaths::operator==() would return true for the last two examples.

The CIM standard leaves it an open question whether model paths may have spaces around delimiters (like '.', '=', and ','). We assume they cannot. So the following is an invalid model path:

    TennisPlayer . first = "Patrick", last="Rafter"
    

We require that the '.', '=', and ',' have no spaces around them.

For reasons of efficiency, the key bindings are internally sorted during initialization. This allows the key bindings to be compared more easily. This means that when the string is converted back to string (by calling toString()) that the keys may have been rearranged.

There are two forms an object name can take:

    <namespace-path>:<model-path>
    <model-path>
    

In other words, the namespace-path is optional. Here is an example of each:

atp:9999/root/cimv25:TennisPlayer.first="Patrick",last="Rafter"
    TennisPlayer.first="Patrick",last="Rafter"
    

If it begins with "//" then we assume the namespace-path is present and process it that way.

It should also be noted that an object name may refer to an instance or a class. Here is an example of each:

    TennisPlayer.first="Patrick",last="Rafter"
    TennisPlayer
    

In the second case--when it refers to a class--the key bindings are omitted.


Constructor & Destructor Documentation

CIMObjectPath::CIMObjectPath (  ) 

Constructs a CIMObjectPath object with null values.

CIMObjectPath::CIMObjectPath ( const CIMObjectPath x  ) 

Constructs a CIMObjectPath object from the value of a specified CIMObjectPath object.

Parameters:
x The CIMObjectPath object from which to construct a new CIMObjectPath object.
CIMObjectPath::CIMObjectPath ( const String objectName  ) 

Constructs a CIMObjectPath from a CIM object name in String form.

Example:

            CIMObjectPath r1 = "MyClass.z=true,y=1234,x=\"Hello World\"";
        
Parameters:
objectName A String representation of the object name.
Exceptions:
MalformedObjectNameException If the String does not contain a properly formed object name.
CIMObjectPath::CIMObjectPath ( const String host,
const CIMNamespaceName nameSpace,
const CIMName className,
const Array< CIMKeyBinding > &  keyBindings = ArrayCIMKeyBinding >() 
)

Constructs a CIMObjectPath object with the specified attributes.

Parameters:
host A String containing the host name (e.g., "nemesis:5988"). An empty String indicates that the object path does not contain a host name attribute.
nameSpace A CIMNamespaceName specifying the namespace name. A null name indicates that the object path does not contain a namespace attribute.
className A CIMName specifying the class name.
keyBindings An Array of CIMKeyBinding objects specifying the key bindings.
Exceptions:
MalformedObjectNameException If the host name String contains an improperly formed host name.
CIMObjectPath::~CIMObjectPath (  ) 

Destructs the CIMObjectPath object.


Member Function Documentation

void CIMObjectPath::clear (  ) 

Resets the attributes of the object path to null values. The result is equivalent to using the default constructor.

const CIMName& CIMObjectPath::getClassName (  )  const

Gets the class name for the object path.

Returns:
A CIMName containing the class name.
const String& CIMObjectPath::getHost (  )  const

Gets the host name for the object path.

Returns:
A String containing the host name.
const Array<CIMKeyBinding>& CIMObjectPath::getKeyBindings (  )  const

Gets the key bindings for the object path.

Returns:
An Array of CIMKeyBinding objects containing the key bindings.
const CIMNamespaceName& CIMObjectPath::getNameSpace (  )  const

Gets the namespace name for the object path.

Returns:
A CIMNamespaceName containing the namespace name.
Boolean CIMObjectPath::identical ( const CIMObjectPath x  )  const

Compares the CIMObjectPath with a specified CIMObjectPath. Comparisons of CIM names are case-insensitive, per the CIM specification.

Parameters:
x The CIMObjectPath to be compared.
Returns:
True if this object is identical to the one specified, false otherwise.
Uint32 CIMObjectPath::makeHashCode (  )  const

Generates a hash code for the object path. Identical references generate the same hash code (despite insignificant differences such as the case of names and the order of the key bindings).

CIMObjectPath& CIMObjectPath::operator= ( const String objectName  ) 

Sets the CIMObjectPath from a CIM object name in String form.

Parameters:
objectName A String representation of the object name.
Exceptions:
MalformedObjectNameException If the String does not contain a properly formed object name.
CIMObjectPath& CIMObjectPath::operator= ( const CIMObjectPath x  ) 

Assigns the value of the specified CIMObjectPath object to this object.

Parameters:
x The CIMObjectPath object from which to assign this CIMObjectPath object.
Returns:
A reference to this CIMObjectPath object.
void CIMObjectPath::set ( const String objectName  ) 

Sets the CIMObjectPath from a CIM object name in String form.

Parameters:
objectName A String representation of the object name.
Exceptions:
MalformedObjectNameException If the String does not contain a properly formed object name.
void CIMObjectPath::set ( const String host,
const CIMNamespaceName nameSpace,
const CIMName className,
const Array< CIMKeyBinding > &  keyBindings = ArrayCIMKeyBinding >() 
)

Sets the CIMObjectPath with the specified attributes.

Parameters:
host A String containing the host name (e.g., "nemesis:5988"). An empty String indicates that the object path does not contain a host name attribute.
nameSpace A CIMNamespaceName specifying the namespace name. A null name indicates that the object path does not contain a namespace attribute.
className A CIMName specifying the class name.
keyBindings An Array of CIMKeyBinding objects specifying the key bindings.
Exceptions:
MalformedObjectNameException If the host name String contains an improperly formed host name.
void CIMObjectPath::setClassName ( const CIMName className  ) 

Sets the class name for the object path.

Parameters:
className A CIMName containing the class name.
void CIMObjectPath::setHost ( const String host  ) 

Sets the host name for the object path.

Example:

        CIMObjectPath r1;
        r1.setHost("fred:5988");
        
Parameters:
host A String containing the host name.
Exceptions:
MalformedObjectNameException If the host name String contains an improperly formed host name.
void CIMObjectPath::setKeyBindings ( const Array< CIMKeyBinding > &  keyBindings  ) 

Sets the key bindings for the object path.

Parameters:
keyBindings An Array of CIMKeyBinding objects containing the key bindings.
void CIMObjectPath::setNameSpace ( const CIMNamespaceName nameSpace  ) 

Sets the namespace name for the object path.

Parameters:
nameSpace A CIMNamespaceName containing the namespace name.
String CIMObjectPath::toString (  )  const

Generates a String form of the object path. The format is:

            "//" + hostname + "/" + namespace + ":" + classname +"." +
            (keyname) + "=" (keyvalue) +"," ...
        

Special characters are escaped in the resulting String.

Returns:
A String form of the object path.
Exceptions:
UninitializedObjectException If the class name attribute of the object path is null.

The documentation for this class was generated from the following file:
  • /var/tmp/axbld-24884/rpm/BUILD/pegasus/src/Pegasus/Common/CIMObjectPath.h