In file ../../src/Pegasus/Common/CIMObjectPath.h:

class PEGASUS_COMMON_LINKAGE CIMObjectPath

The CIMObjectPath class represents the value of a reference.

Documentation

The CIMObjectPath class represents the value of a reference. A reference is one of the property types that an association may contain. Consider the following MOF for example:

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

The value of the from and to properties are internally represented using the CIMObjectPath class.

A CIM reference is used to uniquely identify a CIM class or CIM instance object. CIMObjectPath objects contain the following parts:

  • 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& 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 keyBindings;
    keyBindings.append(CIMKeyBinding("first", "Patrick", CIMKeyBinding::STRING));
    keyBindings.append(CIMKeyBinding("last", "Rafter", CIMKeyBinding::STRING));
    

The key binding types that are supported are:

  • CIMKeyBinding::BOOLEAN
  • CIMKeyBinding::STRING
  • CIMKeyBinding::NUMERIC
  • CIMKeyBinding::REFERENCE

The CIM types are encoded as one of the key binding types in the following way

    boolean - BOOLEAN (the value must be "true" or "false")
    uint8 - NUMERIC
    sint8 - NUMERIC
    uint16 - NUMERIC
    sint16 - NUMERIC
    uint32 - NUMERIC
    sint32 - NUMERIC
    uint64 - NUMERIC
    sint64 - NUMERIC
    char16 - STRING
    string - STRING
    datetime - STRING
    reference - REFERENCE
    

Notice that real32 and real64 are missing. Properties of these types cannot be used as keys.

Also, properties of CIMTYPE_OBJECT cannot be used as keys.

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.


Inheritance:


Public Methods

[more] CIMObjectPath ()
Constructs a CIMObjectPath object with null values (default constructor).
[more] CIMObjectPath (const CIMObjectPath& x)
Copies the values of the specified CIMObjectPath instance to the CIMObjectPath object.
[more] CIMObjectPath (const String& objectName)
Initializes a CIMObjectPath object from a CIM object name.
[more] CIMObjectPath ( const String& host, const CIMNamespaceName& nameSpace, const CIMName& className, const Array<CIMKeyBinding>& keyBindings = Array<CIMKeyBinding>())
Constructs a CIMObjectPath from constituent elements.
[more] ~CIMObjectPath ()
Destroys CIMObjectPath object
[more]CIMObjectPath& operator= (const CIMObjectPath& x)
Assigns the values of the CIMObjectPath instance to the CIMObjectPath object.
[more]void clear ()
Clears out the internal fields of this object making it an empty (or uninitialized) reference.
[more]void set ( const String& host, const CIMNamespaceName& nameSpace, const CIMName& className, const Array<CIMKeyBinding>& keyBindings = Array<CIMKeyBinding>())
Sets this reference from constituent elements.
[more]void set (const String& objectName)
Set the reference from an object name.
[more]CIMObjectPath& operator= (const String& objectName)
Set the reference from an object name using an assignment operator.
[more]const String& getHost () const
Gets the hostname component of the CIMObjectPath.
[more]void setHost (const String& host)
Sets the hostname component of the CIMObjectPath object to the input parameter.
[more]const CIMNamespaceName& getNameSpace () const
Gets the namespace component of the CIMObjectPath as a CIMNamespaceName
[more]void setNameSpace (const CIMNamespaceName& nameSpace)
Sets the namespace component.
[more]const CIMName& getClassName () const
Gets the className component of the CIMObjectPath.
[more]void setClassName (const CIMName& className)
Sets the classname component of the CIMObjectPath object to the input parameter.
[more]const Array<CIMKeyBinding> & getKeyBindings () const
Returns an Array of keybindings from the CIMObjectPath representing all of the key/value pairs defined in the ObjectPath.
[more]void setKeyBindings (const Array<CIMKeyBinding>& keyBindings)
Sets the key/value pairs in the CIMObjectPath from an array of keybindings defined by the input parameter.
[more]String toString () const
Returns the object name represented by this reference.
[more]Boolean identical (const CIMObjectPath& x) const
Returns true if this reference is identical to the one given by the x argument.
[more]Uint32 makeHashCode () const
Generates hash code for the given reference.

o CIMObjectPath()
Constructs a CIMObjectPath object with null values (default constructor).

o CIMObjectPath(const CIMObjectPath& x)
Copies the values of the specified CIMObjectPath instance to the CIMObjectPath object.
Parameters:
x - Specifies the name of the CIMObjectPath instance.

o CIMObjectPath(const String& objectName)
Initializes a CIMObjectPath object from a CIM object name.
Throws:
MalformedObjectNameException True if the name is not parsable; otherwise, false.
CIMObjectPath r1 = "MyClass.z=true,y=1234,x=\"Hello World\"";

Parameters:
objectName - String representing the object name.
Returns:
Returns the initialized CIMObjectPath

o CIMObjectPath( const String& host, const CIMNamespaceName& nameSpace, const CIMName& className, const Array<CIMKeyBinding>& keyBindings = Array<CIMKeyBinding>())
Constructs a CIMObjectPath from constituent elements.
Parameters:
host - Name of host (e.g., "nemesis-5988").
nameSpace - Namespace (e.g., "root/cimv2").
className - Name of a class (e.g., "MyClass").
keyBindings - An array of CIMKeyBinding objects.
Returns:
Returns the constructed CIMObjectPath

o ~CIMObjectPath()
Destroys CIMObjectPath object

oCIMObjectPath& operator=(const CIMObjectPath& x)
Assigns the values of the CIMObjectPath instance to the CIMObjectPath object.
Parameters:
x - Specifies the name of the CIMObjectPath instance.

ovoid clear()
Clears out the internal fields of this object making it an empty (or uninitialized) reference. The effect is the same as if the object was initialized with the default constructor.

ovoid set( const String& host, const CIMNamespaceName& nameSpace, const CIMName& className, const Array<CIMKeyBinding>& keyBindings = Array<CIMKeyBinding>())
Sets this reference from constituent elements. The effect is same as if the object was initialized using the constructor above that has the same arguments.
Throws:
MalformedObjectNameException True if host name is not specified correctly otherwise, false.
Parameters:
host - REVIEWERS: Insert description here.
nameSpace - REVIEWERS: Insert description here.
className - REVIEWERS: Insert description here.
keyBindings - REVIEWERS: Insert description here.

ovoid set(const String& objectName)
Set the reference from an object name.
Parameters:
objectName - Specifies the name of the String instance.

oCIMObjectPath& operator=(const String& objectName)
Set the reference from an object name using an assignment operator.
Parameters:
objectName - Specifies the name of the String instance.

oconst String& getHost() const
Gets the hostname component of the CIMObjectPath.
Returns:
String containing hostname.

ovoid setHost(const String& host)
Sets the hostname component of the CIMObjectPath object to the input parameter.
Parameters:
host - String parameter with the hostname
CIMObjectPath r1;
r1.setHost("fred:5988");
Note that Pegasus does not check whether or not the host names are valid.

oconst CIMNamespaceName& getNameSpace() const
Gets the namespace component of the CIMObjectPath as a CIMNamespaceName

ovoid setNameSpace(const CIMNamespaceName& nameSpace)
Sets the namespace component.
Parameters:
nameSpace - CIMNamespaceName representing the namespace.

oconst CIMName& getClassName() const
Gets the className component of the CIMObjectPath.
Returns:
CIMName containing the classname.

ovoid setClassName(const CIMName& className)
Sets the classname component of the CIMObjectPath object to the input parameter.
Parameters:
className - CIMName containing the className.

oconst Array<CIMKeyBinding> & getKeyBindings() const
Returns an Array of keybindings from the CIMObjectPath representing all of the key/value pairs defined in the ObjectPath.
Returns:
Array of CIMKeyBinding objects from the CIMObjectPath.

ovoid setKeyBindings(const Array<CIMKeyBinding>& keyBindings)
Sets the key/value pairs in the CIMObjectPath from an array of keybindings defined by the input parameter.
Parameters:
keyBindings - Array of keybindings to set into the CIMObjectPath object.

oString toString() const
Returns the object name represented by this reference. The returned string is formed from the hostname, namespace, classname and keybindings defined for this CIMObjectPath object. The form of the name is:

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

The building includes the escaping of special characters.

oBoolean identical(const CIMObjectPath& x) const
Returns true if this reference is identical to the one given by the x argument. Since CIMObjectPaths are normalized when they are created, any differences in the ordering of keybindings is accounted for as are the case insensitivity characteristics defined by the specification.
Parameters:
x - CIMObjectPath for comparison.
Returns:
True if the objects have identical components; otherwise, false.

oUint32 makeHashCode() const
Generates hash code for the given reference. Two identical references generate the same hash code (despite any subtle differences such as the case of the classname and key names as well as the order of the keys).


This class has no child classes.

Alphabetic index HTML hierarchy of classes or Java