本文整理汇总了C++中CIMInstance::setClassName方法的典型用法代码示例。如果您正苦于以下问题:C++ CIMInstance::setClassName方法的具体用法?C++ CIMInstance::setClassName怎么用?C++ CIMInstance::setClassName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CIMInstance
的用法示例。
在下文中一共展示了CIMInstance::setClassName方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: logger
Int32
LifecycleIndicationPoller::poll(const ProviderEnvironmentIFCRef &env)
{
LoggerRef logger(env->getLogger(COMPONENT_NAME));
// do enumInstances to populate m_prevInsts
if (!m_initializedInstances)
{
InstanceArrayBuilder iab(m_prevInsts);
env->getCIMOMHandle()->enumInstances(m_ns, m_classname.toString(), iab, E_SHALLOW, E_NOT_LOCAL_ONLY, E_INCLUDE_QUALIFIERS, E_INCLUDE_CLASS_ORIGIN, 0);
m_initializedInstances = true;
return 1; // have poll called again in 1 second.
}
OW_LOG_DEBUG(logger, Format("LifecycleIndicationPoller::poll creation %1 modification %2 deletion %3", m_pollCreation, m_pollModification, m_pollDeletion));
if (!willPoll())
{
// nothing to do, so return 0 to stop polling.
OW_LOG_DEBUG(logger, "LifecycleIndicationPoller::poll nothing to do, returning 0");
return 0;
}
// do enumInstances of the class
CIMInstanceArray curInstances;
InstanceArrayBuilder iab(curInstances);
CIMOMHandleIFCRef hdl = env->getCIMOMHandle();
try
{
hdl->enumInstances(m_ns, m_classname.toString(), iab, E_SHALLOW, E_NOT_LOCAL_ONLY, E_INCLUDE_QUALIFIERS, E_INCLUDE_CLASS_ORIGIN, 0);
}
catch (const CIMException& e)
{
OW_LOG_ERROR(logger, Format("LifecycleIndicationPoller::poll caught exception: %1", e));
return 0;
}
OW_LOG_DEBUG(logger, Format("LifecycleIndicationPoller::poll got %1 instances", curInstances.size()));
// Compare the new instances with the previous instances
// and send any indications that may be necessary.
typedef SortedVectorSet<CIMInstance, sortByInstancePath> instSet_t;
instSet_t prevSet(m_prevInsts.begin(), m_prevInsts.end());
instSet_t curSet(curInstances.begin(), curInstances.end());
typedef instSet_t::const_iterator iter_t;
iter_t pi = prevSet.begin();
iter_t ci = curSet.begin();
while (pi != prevSet.end() && ci != curSet.end())
{
if (sortByInstancePath()(*pi, *ci))
{
// *pi has been deleted
if (m_pollDeletion)
{
CIMInstance expInst;
expInst.setClassName("CIM_InstDeletion");
expInst.setProperty("SourceInstance", CIMValue(*pi));
expInst.setProperty("IndicationTime", CIMValue(CIMDateTime(DateTime::getCurrent())));
hdl->exportIndication(expInst, m_ns);
}
++pi;
}
else if (sortByInstancePath()(*ci, *pi))
{
// *ci is new
if (m_pollCreation)
{
CIMInstance expInst;
expInst.setClassName("CIM_InstCreation");
expInst.setProperty("SourceInstance", CIMValue(*ci));
expInst.setProperty("IndicationTime", CIMValue(CIMDateTime(DateTime::getCurrent())));
hdl->exportIndication(expInst, m_ns);
}
++ci;
}
else // *pi == *ci
{
if (m_pollModification)
{
if (!pi->propertiesAreEqualTo(*ci))
{
CIMInstance expInst;
expInst.setClassName("CIM_InstModification");
expInst.setProperty("PreviousInstance", CIMValue(*pi));
expInst.setProperty("SourceInstance", CIMValue(*ci));
expInst.setProperty("IndicationTime", CIMValue(CIMDateTime(DateTime::getCurrent())));
hdl->exportIndication(expInst, m_ns);
}
}
++pi;
++ci;
}
}
while (pi != prevSet.end())
{
// *pi has been deleted
if (m_pollDeletion)
{
CIMInstance expInst;
expInst.setClassName("CIM_InstDeletion");
expInst.setProperty("SourceInstance", CIMValue(*pi));
expInst.setProperty("IndicationTime", CIMValue(CIMDateTime(DateTime::getCurrent())));
hdl->exportIndication(expInst, m_ns);
//.........这里部分代码省略.........
示例2: runTests
//.........这里部分代码省略.........
{
CIMClass cc2(baseClass);
cc2.setSuperClass("invalid");
hdl->createClass("root/testsuite", cc2);
TEST_ASSERT(0);
}
catch (const CIMException& e)
{
TEST_ASSERT(e.getErrNo() == CIMException::INVALID_SUPERCLASS);
}
// CreateInstance
// CIM_ERR_INVALID_NAMESPACE
try
{
CIMInstance ci = baseClass.newInstance();
ci.setProperty(theKeyProp);
hdl->createInstance("badNamespace", ci);
TEST_ASSERT(0);
}
catch (const CIMException& e)
{
TEST_ASSERT(e.getErrNo() == CIMException::INVALID_NAMESPACE);
}
// CIM_ERR_INVALID_PARAMETER
// CIM_ERR_INVALID_CLASS
try
{
CIMInstance ci = baseClass.newInstance();
ci.setClassName("nonexistentClass");
ci.setProperty(theKeyProp);
hdl->createInstance("root/testsuite", ci);
TEST_ASSERT(0);
}
catch (const CIMException& e)
{
TEST_ASSERT(e.getErrNo() == CIMException::INVALID_CLASS);
}
// CIM_ERR_ALREADY_EXISTS
try
{
CIMInstance ci = baseClass.newInstance();
ci.setProperty(theKeyProp);
hdl->createInstance("root/testsuite", ci);
TEST_ASSERT(0);
}
catch (const CIMException& e)
{
TEST_ASSERT(e.getErrNo() == CIMException::ALREADY_EXISTS);
}
// ModifyClass
// CIM_ERR_INVALID_NAMESPACE
try
{
hdl->modifyClass("badNamespace", cc);
TEST_ASSERT(0);
}
catch (const CIMException& e)