本文整理汇总了C++中CIMProperty::getType方法的典型用法代码示例。如果您正苦于以下问题:C++ CIMProperty::getType方法的具体用法?C++ CIMProperty::getType怎么用?C++ CIMProperty::getType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CIMProperty
的用法示例。
在下文中一共展示了CIMProperty::getType方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Run
void UNIX_ApplicationSystemDirectoryFixture::Run()
{
CIMName className("UNIX_ApplicationSystemDirectory");
CIMNamespaceName nameSpace("root/cimv2");
UNIX_ApplicationSystemDirectory _p;
UNIX_ApplicationSystemDirectoryProvider _provider;
Uint32 propertyCount;
CIMOMHandle omHandle;
_provider.initialize(omHandle);
_p.initialize();
for(int pIndex = 0; _p.load(pIndex); pIndex++)
{
CIMInstance instance = _provider.constructInstance(className,
nameSpace,
_p);
CIMObjectPath path = instance.getPath();
cout << path.toString() << endl;
propertyCount = instance.getPropertyCount();
for(Uint32 i = 0; i < propertyCount; i++)
{
CIMProperty propertyItem = instance.getProperty(i);
if (propertyItem.getType() == CIMTYPE_REFERENCE) {
CIMValue subValue = propertyItem.getValue();
CIMInstance subInstance;
subValue.get(subInstance);
CIMObjectPath subPath = subInstance.getPath();
cout << " Name: " << propertyItem.getName().getString() << ": " << subPath.toString() << endl;
Uint32 subPropertyCount = subInstance.getPropertyCount();
for(Uint32 j = 0; j < subPropertyCount; j++)
{
CIMProperty subPropertyItem = subInstance.getProperty(j);
cout << " Name: " << subPropertyItem.getName().getString() << " - Value: " << subPropertyItem.getValue().toString() << endl;
}
}
else {
cout << " Name: " << propertyItem.getName().getString() << " - Value: " << propertyItem.getValue().toString() << endl;
}
}
cout << "------------------------------------" << endl;
cout << endl;
}
_p.finalize();
}
示例2: _getClass
int _getClass(const int argc, const char **argv)
{
CIMClass cldef;
try
{
cldef = _c.getClass( PEGASUS_NAMESPACENAME_INTEROP, argv[0] );
}
catch (Exception& e)
{
cerr << /* "getClass: " << */ e.getMessage() << endl;
return 1;
}
// Display the class definition
// without qualifiers, for the moment
// First the class name and superclass
cout << "class " << cldef.getClassName().getString() << " : "
<< cldef.getSuperClassName().getString() << endl;
cout << "{" << endl;
// Now the properties
// No qualifiers except [key], but specify type, array
for (int i=0; i<cldef.getPropertyCount(); i++)
{
CIMProperty p = cldef.getProperty(i);
cout << " ";
// output key, if required
if (_isKey(p)) cout << "[ Key ] ";
// prepare to output type, but
// first, if type is "reference", find target class
if (p.getType() == CIMTYPE_REFERENCE)
cout << p.getReferenceClassName().getString() << " REF ";
// output type
else cout << cimTypeToString(p.getType()) << " ";
// output name
cout << p.getName().getString();
// output array, if required
if (p.isArray()) cout << "[]";
// final eol
cout << ";" << endl;
}
// need to do methods
for (int i=0; i<cldef.getMethodCount(); i++)
{
CIMMethod m = cldef.getMethod(i);
// output type
cout << " " << cimTypeToString(m.getType()) << " ";
// output name
cout << m.getName().getString() << "(";
// output parameters
// new line if there are any parameters
for (int j=0; j<m.getParameterCount(); j++)
{
CIMParameter p = m.getParameter(j);
// output IN/OUT qualifiers on a fresh line
cout << endl << " [ ";
// loop through qualifiers looking for IN, OUT
for (int k=0; k<p.getQualifierCount(); k++)
{
// when one found, output its value
CIMQualifier q = p.getQualifier(k);
if (q.getName().equal("in") ||
q.getName().equal("out"))
{
cout << q.getName().getString() << " ";
}
}
// Now the type
cout << "] " << cimTypeToString(p.getType()) << " ";
// finally the name
cout << p.getName().getString();
// array brackets
if (p.isArray()) cout << "[]";
// closing , on parameter if not last
if (j != m.getParameterCount()-1) cout << ",";
}
// after last param, indent before closing paren
// close paren
cout << ")";
// if (m.isArray()) cout << "[]";
// finish output
cout << ";" << endl;
}
// final brace and done
cout << "};" << endl;
return 0;
}
示例3: testGetInstanceElement
// Tests PROPERTY as an embedded object.
static void testGetInstanceElement(const char* testDataFile)
{
//--------------------------------------------------------------------------
// Read in instance
//--------------------------------------------------------------------------
CIMInstance cimInstance;
Buffer text;
FileSystem::loadFileToMemory(text, testDataFile);
XmlParser parser((char*)text.getData());
XmlReader::getInstanceElement(parser, cimInstance);
PEGASUS_TEST_ASSERT(
cimInstance.getClassName() == CIMName("CIM_InstCreation"));
Uint32 idx;
CIMProperty cimProperty;
CIMValue cimValue;
CIMType cimType;
PEGASUS_TEST_ASSERT(cimInstance.getPropertyCount() == 3);
idx = cimInstance.findProperty(CIMName("IndicationIdentifier"));
PEGASUS_TEST_ASSERT(idx != PEG_NOT_FOUND);
cimProperty = cimInstance.getProperty(idx);
cimValue = cimProperty.getValue();
cimType = cimProperty.getType();
PEGASUS_TEST_ASSERT(strcmp(cimTypeToString(cimType), "string") == 0);
String myString;
cimValue.get(myString);
PEGASUS_TEST_ASSERT(strcmp(myString.getCString(), "0") == 0);
idx = cimInstance.findProperty(CIMName("IndicationTime"));
PEGASUS_TEST_ASSERT(idx != PEG_NOT_FOUND);
cimProperty = cimInstance.getProperty(idx);
cimValue = cimProperty.getValue();
cimType = cimProperty.getType();
PEGASUS_TEST_ASSERT(strcmp(cimTypeToString(cimType), "datetime") == 0);
CIMDateTime myDateTime;
cimValue.get(myDateTime);
PEGASUS_TEST_ASSERT(myDateTime.equal(
CIMDateTime("20050227225624.524000-300")));
idx = cimInstance.findProperty(CIMName("SourceInstance"));
PEGASUS_TEST_ASSERT(idx != PEG_NOT_FOUND);
cimProperty = cimInstance.getProperty(idx);
cimValue = cimProperty.getValue();
cimType = cimProperty.getType();
PEGASUS_TEST_ASSERT(strcmp(cimTypeToString(cimType), "object") == 0);
CIMObject cimObject;
cimValue.get(cimObject);
PEGASUS_TEST_ASSERT(
cimObject.getClassName() ==
CIMName("Sample_LifecycleIndicationProviderClass"));
PEGASUS_TEST_ASSERT(cimObject.getPropertyCount() == 2);
idx = cimObject.findProperty(CIMName("uniqueId"));
PEGASUS_TEST_ASSERT(idx != PEG_NOT_FOUND);
cimProperty = cimObject.getProperty(idx);
cimValue = cimProperty.getValue();
cimType = cimProperty.getType();
PEGASUS_TEST_ASSERT(strcmp(cimTypeToString(cimType), "uint32") == 0);
Uint32 myUint32;
cimValue.get(myUint32);
PEGASUS_TEST_ASSERT(myUint32 == 1);
idx = cimObject.findProperty(CIMName("lastOp"));
PEGASUS_TEST_ASSERT(idx != PEG_NOT_FOUND);
cimProperty = cimObject.getProperty(idx);
cimValue = cimProperty.getValue();
cimType = cimProperty.getType();
PEGASUS_TEST_ASSERT(strcmp(cimTypeToString(cimType), "string") == 0);
cimValue.get(myString);
PEGASUS_TEST_ASSERT(strcmp(myString.getCString(), "createInstance") == 0);
}
示例4: parser
// Tests PROPERTY.ARRAY as an embedded object with array type.
static void testGetInstanceElement2(const char* testDataFile)
{
CIMInstance cimInstance;
Buffer text;
FileSystem::loadFileToMemory(text, testDataFile);
XmlParser parser((char*)text.getData());
XmlReader::getInstanceElement(parser, cimInstance);
PEGASUS_TEST_ASSERT(cimInstance.getClassName() ==
CIMName("CIM_InstCreation"));
Uint32 idx;
CIMProperty cimProperty;
CIMValue cimValue;
CIMType cimType;
PEGASUS_TEST_ASSERT(cimInstance.getPropertyCount() == 3);
idx = cimInstance.findProperty(CIMName("IndicationIdentifier"));
PEGASUS_TEST_ASSERT(idx != PEG_NOT_FOUND);
cimProperty = cimInstance.getProperty(idx);
cimValue = cimProperty.getValue();
cimType = cimProperty.getType();
PEGASUS_TEST_ASSERT(strcmp(cimTypeToString(cimType), "string") == 0);
String myString;
cimValue.get(myString);
PEGASUS_TEST_ASSERT(strcmp(myString.getCString(), "0") == 0);
idx = cimInstance.findProperty(CIMName("IndicationTime"));
PEGASUS_TEST_ASSERT(idx != PEG_NOT_FOUND);
cimProperty = cimInstance.getProperty(idx);
cimValue = cimProperty.getValue();
cimType = cimProperty.getType();
PEGASUS_TEST_ASSERT(strcmp(cimTypeToString(cimType), "datetime") == 0);
CIMDateTime myDateTime;
cimValue.get(myDateTime);
PEGASUS_TEST_ASSERT(myDateTime.equal(
CIMDateTime("20050227225624.524000-300")));
idx = cimInstance.findProperty(CIMName("SourceInstance"));
PEGASUS_TEST_ASSERT(idx != PEG_NOT_FOUND);
cimProperty = cimInstance.getProperty(idx);
cimValue = cimProperty.getValue();
cimType = cimProperty.getType();
PEGASUS_TEST_ASSERT(strcmp(cimTypeToString(cimType), "object") == 0);
Array<CIMObject> cimObject;
cimValue.get(cimObject);
PEGASUS_TEST_ASSERT(cimObject.size() == 2);
for (idx = 0; idx < cimObject.size(); idx++)
{
CIMInstance cimInstanceElement(cimObject[idx]);
PEGASUS_TEST_ASSERT(cimInstanceElement.getPropertyCount() == 2);
Uint32 propIdx = cimInstanceElement.findProperty(CIMName("uniqueId"));
if (propIdx != PEG_NOT_FOUND)
{
CIMProperty nestedProperty =
cimInstanceElement.getProperty(propIdx);
cimValue = nestedProperty.getValue();
Uint32 uniqueId;
cimValue.get(uniqueId);
propIdx = cimInstanceElement.findProperty(CIMName("lastOp"));
nestedProperty = cimInstanceElement.getProperty(propIdx);
cimValue = nestedProperty.getValue();
String checkStringValue;
cimValue.get(checkStringValue);
if (uniqueId == 1)
{
PEGASUS_TEST_ASSERT(strcmp(
checkStringValue.getCString(), "createInstance") == 0);
}
else if (uniqueId == 2)
{
PEGASUS_TEST_ASSERT(strcmp(
checkStringValue.getCString(), "deleteInstance") == 0);
}
else
{
PEGASUS_TEST_ASSERT(false);
}
}
}
}
示例5: testInstanceClass
//.........这里部分代码省略.........
CIMObjectPath currentReferenceName =
referenceNamesResults[j];
Boolean found = false;
for(unsigned int k = 0; k < numResults; ++k)
{
if(currentReferenceName ==
referencesResults[k].getPath())
{
found = true;
break;
}
}
if(!found)
{
failure = true;
break;
}
}
// Check that that results for the associatorNames call is
// consistent with the associators call and the references
// call.
for(j = 0; j < numResults; ++j)
{
CIMObjectPath currentAssociatorName =
associatorNamesResults[j];
Boolean found = false;
unsigned int k = 0;
for(k = 0; k < numResults; ++k)
{
if(currentAssociatorName ==
associatorsResults[k].getPath())
{
found = true;
break;
}
}
if(!found)
{
failure = true;
break;
}
found = false;
for(k = 0; k < numResults; ++k)
{
CIMObject referenceInstance = referencesResults[k];
for(unsigned int x = 0,
m = referenceInstance.getPropertyCount();
x < m; ++x)
{
CIMProperty currentProp =
referenceInstance.getProperty(x);
if(currentProp.getType() == CIMTYPE_REFERENCE)
{
CIMObjectPath currentRef;
currentProp.getValue().get(currentRef);
currentRef.setHost(
currentAssociatorName.getHost());
if(currentRef == currentAssociatorName)
{
found = true;
break;
}
}
}
if(found)
break;
}
if(!found)
{
failure = true;
break;
}
}
}
if(failure)
{
exitFailure(
String("Association Operations returned inconsistent ") +
String("results for instance ") +
currentPath.toString());
}
}
catch(CIMException & e)
{
exitFailure(String("Caught exception while performing ") +
String("association operations on instance ") +
currentPath.toString() + String(": ") + e.getMessage());
}
}
cout << "Test Complete" << endl;
}
示例6: _getProperty
int _getProperty(const int argc, const char **argv)
{
if (argc < 2)
{
_gpUsage();
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 << /* "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,
_nameSpace,
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
{
_gpUsage();
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++)
{
pDef=cldef.getProperty(n);
cout << n+1 << ": ";
cout << cimTypeToString(pDef.getType()) << " ";
cout << pDef.getName().getString();
if (pDef.isArray()) cout << "[]";
cout << endl;
}
cout << "Property (1.." << cldef.getPropertyCount() << ")? " << flush;
cin >> n;
pDef = cldef.getProperty(n-1);
}