The WS-Management C++ samples in the SDK demonstrate how to work with the generated C++ classes. All of the samples except for the C++ RemoteControlUntyped sample use strong typing. The following snippet shows an example of strong typing use. The example enumerates objects that correspond to the physical memory in the platform using the Enumerate function in the CIM_PhysicalMemory generated class that inherits from a CimBase static function:
// Define the WS-Management client wrapper
CimOpenWsmanClient wsmanClient(host, TlsPort, tls, kerberos, user, password, proxy, proxyUsername, proxyPassword, localCertStore, certName, certOid);
// Enumerate all instances of CIM_PhysicalMemory
vector<tr1::shared_ptr<CIM_PhysicalMemory> > cimPhisicalMemoryVec = CIM_PhysicalMemory::Enumerate(wsmanClient);
// Display the values
vector<tr1::shared_ptr<CIM_PhysicalMemory> >::iterator phyMemIter;
for(phyMemIter = cimPhisicalMemoryVec.begin(); phyMemIter != cimPhisicalMemoryVec.end(); phyMemIter++ )
{
if((*phyMemIter)->CapacityExists())
{
cout << "Capacity: " << (*phyMemIter)->Capacity() << endl;
}
if((*phyMemIter)->FormFactorExists())
{
cout << "FormFactor: " << (*phyMemIter)->FormFactor() << endl;
}
if((*phyMemIter)->MemoryTypeExists())
{
cout << "Memory Type: ";
switch ((*phyMemIter)->MemoryType())
{
case 0:
cout << "Unknown" << endl;
break;
case 1:
cout << "Other" << endl;
break;
case 2:
cout << "DRAM" << endl;
break;
case 3:
cout << "Synchronous DRAM" << endl;
break;
default:
cout << "Value not recognized by the sample. Please update your
SDK software" << endl;
break;
}
}
if((*phyMemIter)->SpeedExists())
{
cout << "Speed: " << (*phyMemIter)->Speed() << endl;
}
if((*phyMemIter)->ManufacturerExists())
{
cout << "Manufacturer: " << (*phyMemIter)->Manufacturer().c_str() << endl;
}
if((*phyMemIter)->SerialNumberExists())
{
cout << "Serial Number: " << (*phyMemIter)->SerialNumber().c_str() << endl;
}
cout << "Tag: " << (*phyMemIter)->Tag().c_str() << endl;
if((*phyMemIter)->PartNumberExists())
{
cout << "Part Number: " << (*phyMemIter)->PartNumber().c_str() << endl;
}
}
Copyright © 2006-2022, Intel Corporation. All rights reserved. |