In file ..\..\src\Pegasus\Common\CIMReference.h:

class PEGASUS_COMMON_LINKAGE CIMReference

The CIMReference class represents the value of a reference.

Documentation

The CIMReference class represents the value of a reference. A reference is one of property types which 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 CIMReference class.

CIM references are used to uniquely identify a CIM class or CIM instance objects. CIMReference objects contain the following parts:

  • Host - name of host whose repository 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 CIMReference class). This string is known as the "Object Name". An object name has the following form:

    <namespace-path>:<model-path>
    

The namespace-path is implementation dependent and has the following form in Pegasus:

    //<hostname>>/<namespace>>
    

For example, suppose there is a host named "atp" with a CIM Server listening on port 9999 which has a CIM repository with a namespace called "root/cimv25". Then the namespace-path is given as:

    //atp:9999/root/cimv25
    

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 of course 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 CIMReference 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:

    CIMReference(const String& objectName);

CIMReference( const String& host, const String& nameSpace, const String& className, const KeyBindingArray& keyBindings);

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

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

A CIMReference 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 KeyBinding objects to a KeyBindingArray like this:

    KeyBindingArray keyBindings;
    keyBindings.append(KeyBinding("first", "Patrick", KeyBinding::STRING));
    keyBindings.append(KeyBinding("last", "Rafter", KeyBinding::STRING));
    

The only key values that are supported are:

  • KeyBinding::BOOLEAN
  • KeyBinding::STRING
  • KeyBinding::NUMERIC

This limitation is imposed by the "XML Mapping Specification v2.0.0" specification. The CIM types are encoded as one of these three 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 - NUMERIC
    string - STRING
    datetime - STRING
    

Notice that real32 and real64 are missing. Properties of these types 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 CIMReferences::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] CIMReference ()
Default constructor.
[more] CIMReference (const CIMReference& x)
Copy constructor.
[more] CIMReference (const String& objectName)
Initializes a CIMReference object from a CIM object name.
[more] CIMReference (const char* objectName)
Initializes this object from a CIM object name (char* version).
[more]static KeyBindingArray getKeyBindingArray ()
Workaround to MSVC++ bug.
[more] CIMReference ( const String& host, const String& nameSpace, const String& className, const KeyBindingArray& keyBindings = getKeyBindingArray())
Constructs a CIMReference from constituent elements.
[more] ~CIMReference ()
Destructor
[more]CIMReference& operator= (const CIMReference& x)
Assignment operator
[more]void clear ()
Clears out the internal fields of this object making it an empty (or unitialized reference).
[more]void set ( const String& host, const String& nameSpace, const String& className, const KeyBindingArray& keyBindings = getKeyBindingArray())
Sets this reference from constituent elements.
[more]void set (const String& objectName)
Set the reference from an object name .
[more]CIMReference& operator= (const String& objectName)
Same as set() above except that it is an assignment operator
[more]CIMReference& operator= (const char* objectName)
Same as set() above except that it is an assignment operator
[more]const String& getHost () const
getHost - returns the hostname component of the CIMReference
[more]void setHost (const String& host)
setHost Sets the hostname component of the CIMReference object to the input parameter
[more]const String& getNameSpace () const
getNameSpace - returns the namespace component of the CIMReference as a String
[more]void setNameSpace (const String& nameSpace)
Sets the namespace component.
[more]const String& getClassName () const
Accessor.
[more]void setClassName (const String& className)
Sets the classname component of the CIMReference object to the input parameter.
[more]const Array<KeyBinding> & getKeyBindings () const
getKeyBindings - Returns an Array of keybindings from the CIMReference representing all of the key/value pairs defined in the Reference.
[more]void setKeyBindings (const Array<KeyBinding>& keyBindings)
setkeyBindings - Sets the key/value pairs in the CIMReference from an array of keybindings defined by the input parameter
[more]String toString () const
Returns the object name represented by this reference.
[more]String toStringCanonical () const
Stringizes object into canonical form (in which all keys are sorted into ascending order and classnames and keynames are shifted to lower case
[more]Boolean identical (const CIMReference& x) const
Returns true if this reference is identical to the one given by the x argument.
[more]void toXml (Array<Sint8>& out, Boolean putValueWrapper = true) const
Encodes this CIMreference object as XML.
[more]void toMof (Array<Sint8>& out, Boolean putValueWrapper = true) const
Encodes this CIMreference object as MOF.
[more]void print (PEGASUS_STD(ostream)& os = PEGASUS_STD(cout)) const
Prints the XML encoding of this object
[more]Uint32 makeHashCode () const
Generates hash code for the given reference.
[more]Boolean isInstanceName () const
Check whether this reference refers to an instance (if it does, the class must have key bindings)
[more]Boolean isClassName () const
Check whether this reference refers to an class (if not it is an instance)

o CIMReference()
Default constructor.

o CIMReference(const CIMReference& x)
Copy constructor.

o CIMReference(const String& objectName)
Initializes a CIMReference object from a CIM object name.
Throws:
Throws "IllformedObjectName" exception if the name not parsable.
CIMReference r1 = "MyClass.z=true,y=1234,x=\"Hello World\"";

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

o CIMReference(const char* objectName)
Initializes this object from a CIM object name (char* version).
Throws:
Throws "IllformedObjectName" if objectName parameter not parsable as a CIMReference.
Parameters:
objectName - char* representing the objectName
Returns:

ostatic KeyBindingArray getKeyBindingArray()
Workaround to MSVC++ bug.

o CIMReference( const String& host, const String& nameSpace, const String& className, const KeyBindingArray& keyBindings = getKeyBindingArray())
Constructs a CIMReference 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 KeyBinding objects.
Returns:
Returns the constructed CIMReference

o ~CIMReference()
Destructor

oCIMReference& operator=(const CIMReference& x)
Assignment operator

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

ovoid set( const String& host, const String& nameSpace, const String& className, const KeyBindingArray& keyBindings = getKeyBindingArray())
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.

ovoid set(const String& objectName)
Set the reference from an object name .

oCIMReference& operator=(const String& objectName)
Same as set() above except that it is an assignment operator

oCIMReference& operator=(const char* objectName)
Same as set() above except that it is an assignment operator

oconst String& getHost() const
getHost - returns the hostname component of the CIMReference
Returns:
String contianing hostname.

ovoid setHost(const String& host)
setHost Sets the hostname component of the CIMReference object to the input parameter
Parameters:
host - String parameter with the hostname
CIMReference r1;
r1.sethost("fred-5988");
Note that Pegasus does no checking on valid host names.

oconst String& getNameSpace() const
getNameSpace - returns the namespace component of the CIMReference as a String

ovoid setNameSpace(const String& nameSpace)
Sets the namespace component.
Throws:
Throws IllegalName if form of the namespace is illegal. Pegasus does a limited check on name
Parameters:
- String representing the Namespace. The functions tests for a legal name.

oconst String& getClassName() const
Accessor.

ovoid setClassName(const String& className)
Sets the classname component of the CIMReference object to the input parameter.
Throws:
Throws IllegalName if form of className is illegal. A CIM name must match the following regular expression:
[A-Z-a-z_][A-Za-z_0-9]*

Parameters:
className - String containing the className.

oconst Array<KeyBinding> & getKeyBindings() const
getKeyBindings - Returns an Array of keybindings from the CIMReference representing all of the key/value pairs defined in the Reference.
Returns:
Array of KeyBinding objects from the CIMReference. ATTN

ovoid setKeyBindings(const Array<KeyBinding>& keyBindings)
setkeyBindings - Sets the key/value pairs in the CIMReference from an array of keybindings defined by the input parameter
Parameters:
keyBindings - Array of keybindings to set into the CIMRefernece 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 CIMReference object. the form of the name is:

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

The building includes the escaping of special characters. ATTN: The form of the above string definition needs cleaning.

oString toStringCanonical() const
Stringizes object into canonical form (in which all keys are sorted into ascending order and classnames and keynames are shifted to lower case

oBoolean identical(const CIMReference& x) const
Returns true if this reference is identical to the one given by the x argument. Since CIMReferences 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:
- CIMReference for comparison
Returns:
True if the objects are have identical components

ovoid toXml(Array<Sint8>& out, Boolean putValueWrapper = true) const
Encodes this CIMreference object as XML.
Parameters:
out - argument in which to place results

ovoid toMof(Array<Sint8>& out, Boolean putValueWrapper = true) const
Encodes this CIMreference object as MOF.
Parameters:
out - argument in which to place results

ovoid print(PEGASUS_STD(ostream)& os = PEGASUS_STD(cout)) const
Prints the XML encoding of this object

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).

oBoolean isInstanceName() const
Check whether this reference refers to an instance (if it does, the class must have key bindings)

oBoolean isClassName() const
Check whether this reference refers to an class (if not it is an instance)


This class has no child classes.
Friends:
class XmlWriter

Alphabetic index HTML hierarchy of classes or Java