📄 cimobjectpath.h
字号:
//%2004//////////////////////////////////////////////////////////////////////////// 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.//// Permission is hereby granted, free of charge, to any person obtaining a copy// of this software and associated documentation files (the "Software"), to// deal in the Software without restriction, including without limitation the// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or// sell copies of the Software, and to permit persons to whom the Software is// furnished to do so, subject to the following conditions:// // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN// ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED// "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT// LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN// ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.////==============================================================================////%/////////////////////////////////////////////////////////////////////////////#ifndef Pegasus_ObjectPath_h#define Pegasus_ObjectPath_h#include <Pegasus/Common/Config.h>#include <Pegasus/Common/Linkage.h>#include <Pegasus/Common/String.h>#include <Pegasus/Common/CIMName.h>#include <Pegasus/Common/Array.h>#include <Pegasus/Common/Exception.h>PEGASUS_NAMESPACE_BEGINclass CIMObjectPath;class CIMKeyBindingRep;class CIMObjectPathRep;class CIMValue;/** The CIMKeyBinding class associates a key name, value, and type. It is used by the CIMObjectPath class to represent key bindings. See the CIMObjectPath class to see how they are used.*/class PEGASUS_COMMON_LINKAGE CIMKeyBinding{public: enum Type { BOOLEAN, STRING, NUMERIC, REFERENCE }; /** Constructs a CIMKeyBinding object with null values (default constructor). */ CIMKeyBinding(); /** Copy constructor. @param x Specifies the name of the CIMKeyBinding instance. */ CIMKeyBinding(const CIMKeyBinding& x); /** Constructs a CIMKeyBinding with a name, value, and type. @param name CIMName for the key for this binding object. @param value String value for this key. @param type CIMKeyBinding::Type representing the type of this key. */ CIMKeyBinding(const CIMName& name, const String& value, Type type); /** Constructs a CIMKeyBinding with a name and CIMValue, mapping from CIMValue types to CIMKeyBinding types. @param name CIMName for the key for this binding object. @param value CIMValue from which to extract the value for this key. @exception TypeMismatchException True if the type of the value is not valid for a key property; otherwise, false. */ CIMKeyBinding(const CIMName& name, const CIMValue& value); /** CIMKeyBinding destructor */ ~CIMKeyBinding(); /** Assigns the values of the specified CIMKeyBinding instance to the CIMKeyBinding object. */ CIMKeyBinding& operator=(const CIMKeyBinding& x); /** REVIEWERS: Insert description here. */ const CIMName& getName() const; /** REVIEWERS: Insert description here. @param name Reviewers: Insert description here. */ void setName(const CIMName& name); /** REVIEWERS: Insert description here. */ const String& getValue() const; /** REVIEWERS: Insert description here. @param value Reviewers: Insert description here. */ void setValue(const String& value); /** REVIEWERS: Insert description here. */ Type getType() const; /** REVIEWERS: Insert description here. @param type Reviewers: Insert description here. */ void setType(Type type); /** REVIEWERS: Insert description here. @param value Reviewers: Insert description here. @return Reviewers: Insert description here. */ Boolean equal(CIMValue value);private: CIMKeyBindingRep* _rep; friend class CIMObjectPath;};PEGASUS_COMMON_LINKAGE Boolean operator==( const CIMKeyBinding& x, const CIMKeyBinding& y);#define PEGASUS_ARRAY_T CIMKeyBinding# include <Pegasus/Common/ArrayInter.h>#undef PEGASUS_ARRAY_Tclass XmlWriter;/** 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: <pre> [Association] class MyAssociations { MyClass ref from; MyClass ref to; }; </pre> 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: <ul> <li>Host - name of host that contains the object</li> <li>NameSpace - the namespace which contains the object</li> <li>ClassName - name of objects class</li> <li>KeyBindings key/value pairs which uniquely identify an instance</li> </ul> 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: <pre> <namespace-path>:<model-path> </pre> 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: <pre> <Qualifyingclass>.<key-1>=<value-1>[,<key-n>= <value-n>]* </pre> For example: <pre> TennisPlayer.first="Patrick",last="Rafter" </pre> 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: <pre> class TennisPlayer : Person { [key] string first; [key] string last; }; </pre> 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: <pre> CIMObjectPath(const String& objectName); CIMObjectPath( const String& host, const CIMNamespaceName& nameSpace, const CIMName& className, const Array<CIMKeyBinding>& keyBindings); </pre> Following our example, the above object name may be used to initialize a CIMObjectPath like this: <pre> CIMObjectPath ref = "//atp:9999/root/cimv25:TennisPlayer.first="Patrick",last="Rafter"; </pre> 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: <ul> <li>host = "atp:9999"</li> <li>nameSpace = "root/cimv25"</li> <li>className = "TennisPlayer"</li> <li>keyBindings = "first=\"Patrick\",last=\"Rafter\""</li> </ul> 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: <pre> Array<CIMKeyBinding> keyBindings; keyBindings.append(CIMKeyBinding("first", "Patrick", CIMKeyBinding::STRING)); keyBindings.append(CIMKeyBinding("last", "Rafter", CIMKeyBinding::STRING)); </pre> The key binding types that are supported are: <ul> <li>CIMKeyBinding::BOOLEAN</li> <li>CIMKeyBinding::STRING</li> <li>CIMKeyBinding::NUMERIC</li> <li>CIMKeyBinding::REFERENCE</li> </ul> The CIM types are encoded as one of the key binding types in the following way <pre> boolean - BOOLEAN (the value must be "true" or "false") uint8 - NUMERIC sint8 - NUMERIC uint16 - NUMERIC
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -