本文整理汇总了C++中CIMObjectPath::identical方法的典型用法代码示例。如果您正苦于以下问题:C++ CIMObjectPath::identical方法的具体用法?C++ CIMObjectPath::identical怎么用?C++ CIMObjectPath::identical使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CIMObjectPath
的用法示例。
在下文中一共展示了CIMObjectPath::identical方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: _testHostedIndicationServiceInstance
void _testHostedIndicationServiceInstance(CIMClient &client)
{
cout << "Testing Association Class "
<< (const char *)PEGASUS_CLASSNAME_PG_HOSTEDINDICATIONSERVICE.
getString().getCString()
<< "...";
// Get PG_HostedIndicationService Instances
Array<CIMInstance> hostedInstances = client.enumerateInstances(
PEGASUS_NAMESPACENAME_INTEROP,
PEGASUS_CLASSNAME_PG_HOSTEDINDICATIONSERVICE);
PEGASUS_TEST_ASSERT(hostedInstances.size() == 1);
// Get PG_HostedIndicationService Instance names
Array<CIMObjectPath> hostedPaths = client.enumerateInstanceNames(
PEGASUS_NAMESPACENAME_INTEROP,
PEGASUS_CLASSNAME_PG_HOSTEDINDICATIONSERVICE);
PEGASUS_TEST_ASSERT(hostedPaths.size() == 1);
// Get CIM_IndicationService instance names
Array<CIMObjectPath> servicePaths = client.enumerateInstanceNames(
PEGASUS_NAMESPACENAME_INTEROP,
PEGASUS_CLASSNAME_CIM_INDICATIONSERVICE);
PEGASUS_TEST_ASSERT(servicePaths.size() == 1);
// Test the CIM_IndicationService value.
CIMValue capValue = hostedInstances[0].getProperty(
hostedInstances[0].findProperty("Dependent")).getValue();
CIMObjectPath testPath;
capValue.get(testPath);
testPath.setNameSpace(CIMNamespaceName());
PEGASUS_TEST_ASSERT(testPath.identical(servicePaths[0]));
cout << "Test Complete" << endl;
}
示例2: _getInstance
int _getInstance(const int argc, const char **argv)
{
if (argv[0] == 0)
{
_giUsage();
return 1;
}
// need to get class definition to find keys
// first arg is name of class
CIMClass cldef;
try
{
cldef = _c.getClass( _nameSpace, argv[0] );
}
catch(Exception& e)
{
cerr << /* "getInstance: " << */ e.getMessage() << endl;
return 1;
}
CIMObjectPath ref;
CIMInstance inst;
// If there are no more args, prompt user for keys
if (argv[1] == 0) ref = CIMObjectPath(String::EMPTY, // hostname left blank
_nameSpace,
argv[0],
_inputInstanceKeys(cldef));
// else if there's another arg and it's "list", enumInstNames and print
// a list from which user will select (return if none)
else if (String::equalNoCase("list",argv[1]))
{
ref = _selectInstance(argv[0]);
// An empty ObjectPath means nothing was selected
if (ref.identical(CIMObjectPath())) return 0;
}
// else there's another arg but it's invalid
else
{
_giUsage();
return 1;
}
// get the specified instance
try
{
inst = _c.getInstance(_nameSpace,ref);
}
catch(Exception& e)
{
cerr << /* "getInstance: " << */ e.getMessage() << endl;
return 1;
}
_displayInstance(inst);
return 0;
}
示例3: _testElementCapabilityInstance
void _testElementCapabilityInstance(CIMClient &client)
{
cout << "Testing Association Class "
<< (const char *)PEGASUS_CLASSNAME_CIM_INDICATIONSERVICECAPABILITIES.
getString().getCString()
<< "...";
// Get CIM_IndicationServiceCapabilities instance names
Array<CIMObjectPath> capPaths = client.enumerateInstanceNames(
PEGASUS_NAMESPACENAME_INTEROP,
PEGASUS_CLASSNAME_CIM_INDICATIONSERVICECAPABILITIES);
PEGASUS_TEST_ASSERT(capPaths.size() == 1);
// Get CIM_IndicationService instance names
Array<CIMObjectPath> servicePaths = client.enumerateInstanceNames(
PEGASUS_NAMESPACENAME_INTEROP,
PEGASUS_CLASSNAME_CIM_INDICATIONSERVICE);
PEGASUS_TEST_ASSERT(servicePaths.size() == 1);
// Get PG_ElementCapabilities instances
Array<CIMInstance> eleInstances = client.enumerateInstances(
PEGASUS_NAMESPACENAME_INTEROP,
PEGASUS_CLASSNAME_PG_ELEMENTCAPABILITIES);
PEGASUS_TEST_ASSERT(eleInstances.size() == 1);
// Test PG_ElementCapabilities instance.
CIMValue capValue = eleInstances[0].getProperty(
eleInstances[0].findProperty("Capabilities")).getValue();
CIMValue meValue = eleInstances[0].getProperty(
eleInstances[0].findProperty("ManagedElement")).getValue();
// Now test the instance names of CIM_IndicationService instance and
// CIM_IndicationServiceCapabilities instance.
CIMObjectPath testPath;
capValue.get(testPath);
testPath.setNameSpace(CIMNamespaceName());
PEGASUS_TEST_ASSERT(testPath.identical(capPaths[0]));
meValue.get(testPath);
testPath.setNameSpace(CIMNamespaceName());
PEGASUS_TEST_ASSERT(testPath.identical(servicePaths[0]));
cout << "Test Complete" << endl;
}
示例4: _getProperty
int _getProperty(const int argc, const char **argv)
{
// need to get class definition to find keys
// first arg is name of class
CIMClass cldef;
try
{
cldef = _c.getClass( PEGASUS_NAMESPACENAME_INTEROP, argv[0] );
}
catch(Exception& e)
{
cerr << /* "getProperty: " << */ e.getMessage() << endl;
return 1;
}
CIMObjectPath ref;
CIMInstance inst;
// If next arg is "ask", prompt user for keys
if (String::equalNoCase("ask",argv[1])) ref =
CIMObjectPath(String::EMPTY,
PEGASUS_NAMESPACENAME_INTEROP,
argv[0],
_inputInstanceKeys(cldef) );
// else if the next arg and is "list", enumInstNames and print
// a list from which user will select
else if (String::equalNoCase("list",argv[1]))
{
ref = _selectInstance( argv[0] );
if (ref.identical(CIMObjectPath())) return 0;
}
// else there's another arg but it's invalid
else
{
return 1;
}
CIMProperty pDef;
// if no more args, display property names and ask which
if (argc < 3)
{
int n;
for (n=0; n<cldef.getPropertyCount(); n++)
cerr << n+1 << ": " << cldef.getProperty(n).getName().getString() << endl;
cerr << "Property (1.." << cldef.getPropertyCount() << ")? ";
cin >> n;
pDef = cldef.getProperty(n-1);
}
示例5: test04
//
// Test identical() function with keys that are references
//
void test04()
{
//
// Create classes A and B referenced classes, C - Association
//
CIMClass classA (CIMName ("A"), CIMName ());
CIMProperty propertyX ("x", String ());
propertyX.addQualifier (CIMQualifier (CIMName ("Key"), true));
CIMProperty propertyY ("y", String ());
propertyY.addQualifier (CIMQualifier (CIMName ("Key"), true));
CIMProperty propertyZ ("z", String ());
propertyZ.addQualifier (CIMQualifier (CIMName ("Key"), true));
classA.addProperty (propertyX);
classA.addProperty (propertyY);
classA.addProperty (propertyZ);
CIMClass classB ("B");
CIMProperty propertyQ ("q", String ());
propertyQ.addQualifier (CIMQualifier (CIMName ("Key"), true));
CIMProperty propertyR ("r", String ());
propertyR.addQualifier (CIMQualifier (CIMName ("Key"), true));
CIMProperty propertyS ("s", String ());
propertyS.addQualifier (CIMQualifier (CIMName ("Key"), true));
classB.addProperty (propertyQ);
classB.addProperty (propertyR);
classB.addProperty (propertyS);
CIMClass classC ("C");
CIMProperty propertyA ("a", CIMValue ());
propertyA.addQualifier (CIMQualifier (CIMName ("Key"), true));
CIMProperty propertyB ("b", CIMValue ());
propertyB.addQualifier (CIMQualifier (CIMName ("Key"), true));
classC.addProperty (propertyA);
classC.addProperty (propertyB);
//
// Create instances of each classa
//
CIMInstance instanceA (CIMName ("A"));
instanceA.addProperty (CIMProperty (CIMName ("x"), String ("rose")));
instanceA.addProperty (CIMProperty (CIMName ("y"), String ("lavender")));
instanceA.addProperty (CIMProperty (CIMName ("z"), String ("rosemary")));
CIMObjectPath aPath = instanceA.buildPath (classA);
CIMObjectPath aPath2 ("A.y=\"lavender\",x=\"rose\",z=\"rosemary\"");
PEGASUS_TEST_ASSERT (aPath.identical (aPath2));
CIMInstance instanceB (CIMName ("B"));
instanceB.addProperty (CIMProperty (CIMName ("q"),
String ("pelargonium")));
instanceB.addProperty (CIMProperty (CIMName ("r"), String ("thyme")));
instanceB.addProperty (CIMProperty (CIMName ("s"), String ("sage")));
// Test to assure that the buildpath function works.
CIMObjectPath bPath = instanceB.buildPath (classB);
CIMObjectPath bPath2 ("B.s=\"sage\",q=\"pelargonium\",r=\"thyme\"");
PEGASUS_TEST_ASSERT (bPath.identical (bPath2));
// Build instance of C and build path from buildPath function.
CIMInstance instanceC (CIMName ("C"));
instanceC.addProperty (CIMProperty (CIMName ("a"), aPath, 0,
CIMName ("A")));
instanceC.addProperty (CIMProperty (CIMName ("b"), bPath, 0,
CIMName ("B")));
CIMObjectPath cPath = instanceC.buildPath (classC);
// Build CIMObjectPath from keybindings.
Array <CIMKeyBinding> keyBindings;
CIMKeyBinding aBinding ("a", "A.y=\"lavender\",x=\"rose\",z=\"rosemary\"",
CIMKeyBinding::REFERENCE);
CIMKeyBinding bBinding ("b", "B.s=\"sage\",q=\"pelargonium\",r=\"thyme\"",
CIMKeyBinding::REFERENCE);
keyBindings.append (aBinding);
keyBindings.append (bBinding);
CIMObjectPath cPath2 ("", CIMNamespaceName (),
cPath.getClassName (), keyBindings);
// Assert that the CIMObjectPaths for C from build path and direct
// from keybindings are equal.
PEGASUS_TEST_ASSERT (cPath.identical (cPath2));
// ATTN: KS 25 Feb 2003 P3 - Think we can extend these tests
// since this is creation of classes and
// instnaces for associations and referenced classes.
}
示例6:
Boolean operator==(const CIMObjectPath& x, const CIMObjectPath& y)
{
return x.identical(y);
}
示例7: originNamespace
//
// Local version of the references operation. It validates the input
// parameters, setting the origin and target property values if not set
// already, and then performs an enumeration on the association class. It then
// filters the results of that enumeration to see if one of the reference
// properties matches the objectName parameter passed into the method. If so,
// then it is added to the array of association instances to be returned.
//
Array<CIMInstance> InteropProvider::localReferences(
const OperationContext & context,
const CIMObjectPath & objectName,
const CIMName & assocClass,
String & originProperty,
String & targetProperty,
const CIMPropertyList & propertyList,
const CIMName & targetClass)
{
PEG_METHOD_ENTER(TRC_CONTROLPROVIDER,
"InteropProvider::localReferences()");
Array<CIMInstance> instances;
CIMName originClass = objectName.getClassName();
Array<CIMName> targetSubclasses;
CIMNamespaceName lastTargetNamespace;
CIMNamespaceName originNamespace(objectName.getNameSpace());
// Check that the association traversal request is valid
if (validAssocClassForObject(
context,
assocClass,
objectName,
originNamespace,
originProperty,
targetProperty))
{
// retrieve all of the association class instances
Array<CIMInstance> localInstances = localEnumerateInstances(context,
CIMObjectPath(hostName, originNamespace,
assocClass));
// Filter the association class instances based on the origin instance
// and other input parameters.
for(Uint32 i = 0, n = localInstances.size(); i < n; ++i)
{
CIMInstance & currentInstance = localInstances[i];
CIMObjectPath originPath = getRequiredValue<CIMObjectPath>(
currentInstance, originProperty);
originPath.setNameSpace(objectName.getNameSpace());
originPath.setHost(objectName.getHost());
// Only include instances where the origin instance is present in
// the association.
if(originPath.identical(objectName))
{
if(!targetClass.isNull())
{
// Have to check if the target reference is of the
// targetClass type. We first must determine all the
// possible subclasses of the targetClass in the target
// namespace.
CIMObjectPath targetPath = getRequiredValue<CIMObjectPath>(
currentInstance, targetProperty);
CIMNamespaceName targetNamespace(
targetPath.getNameSpace());
if(targetNamespace.isNull())
{
targetNamespace = originNamespace;
targetPath.setNameSpace(targetNamespace);
}
if(targetNamespace != lastTargetNamespace)
{
try
{
targetSubclasses = repository->enumerateClassNames(
targetNamespace, targetClass, true);
}
catch(...)
{
// If an exception was thrown during enumeration,
// then the base class didn't exist in the
// namespace, so the target instance retrieved
// must not match the targetClass parameter.
continue;
}
targetSubclasses.append(targetClass);
lastTargetNamespace = targetNamespace;
}
// Try to find the targetPath's class in the search space
CIMName targetPathClass = targetPath.getClassName();
for(Uint32 j = 0, m = targetSubclasses.size(); j < m; ++j)
{
if(targetPathClass == targetSubclasses[j])
{
instances.append(currentInstance);
break;
}
}
}
else
//.........这里部分代码省略.........
示例8: test03
// Build the instance of an association class and test the build path functions.
void test03()
{
const CIMNamespaceName NAMESPACE = CIMNamespaceName("/zzz");
CIMClass myPersonClass(CIMName("MY_PersonClass"));
myPersonClass
.addProperty(CIMProperty(CIMName("name"), String())
.addQualifier(CIMQualifier(CIMName("Key"), true)));
CIMClass myAssocClass(CIMName("MY_AssocClass"));
myAssocClass
.addQualifier(CIMQualifier(CIMName("association"), true))
.addProperty(CIMProperty(CIMName("parent"), CIMObjectPath(), 0,
CIMName("MY_PersonClass"))
.addQualifier(CIMQualifier(CIMName("key"), true)))
.addProperty(CIMProperty(CIMName("child"), CIMObjectPath(), 0,
CIMName("MY_PersonClass"))
.addQualifier(CIMQualifier(CIMName("key"), true)))
.addProperty(CIMProperty(CIMName("Age"), String()));
CIMInstance fatherInstance(CIMName("MY_PersonClass"));
fatherInstance
.addProperty(CIMProperty(CIMName("name"), String("father")));
CIMInstance daughterInstance(CIMName("My_PersonClass"));
daughterInstance
.addProperty(CIMProperty(CIMName("name"), String("daughter")));
CIMObjectPath fatherInstancePath =
fatherInstance.buildPath(CIMConstClass(myPersonClass));
CIMObjectPath daughterInstancePath =
daughterInstance.buildPath(CIMConstClass(myPersonClass));
CIMInstance assocInstance(CIMName("MY_AssocClass"));
assocInstance.addProperty(CIMProperty(CIMName("parent"),
CIMObjectPath(fatherInstancePath),0,CIMName("MY_PersonClass")));
assocInstance.addProperty(CIMProperty(CIMName("child"),
CIMObjectPath(daughterInstancePath),0, CIMName("MY_PersonClass")));
CIMObjectPath assocInstancePath =
assocInstance.buildPath(CIMConstClass(myAssocClass));
// Now do the asserts, etc.
// See if the pathing works on Associations and association instances
if (verbose)
{
XmlWriter::printClassElement(myPersonClass);
XmlWriter::printClassElement(myAssocClass);
XmlWriter::printInstanceElement(fatherInstance);
XmlWriter::printInstanceElement(daughterInstance);
XmlWriter::printInstanceElement(assocInstance);
}
if (verbose)
{
cout << "Paths " << endl;
cout << "FatherInstancePath = " << fatherInstancePath.toString() <<
endl;
cout << "DaughterInstancePath = " << daughterInstancePath.toString() <<
endl;
cout << "AssocInstancePath = " << assocInstancePath.toString() << endl;
}
String x ="MY_AssocClass.child=\"My_PersonClass.name=\\\"daughter\\\"\","
"parent=\"MY_PersonClass.name=\\\"father\\\"\"";
assert(x == assocInstancePath.toString());
CIMObjectPath px = x;
assert(px.identical(assocInstancePath));
}