本文整理汇总了C++中DataItem::getComponent方法的典型用法代码示例。如果您正苦于以下问题:C++ DataItem::getComponent方法的具体用法?C++ DataItem::getComponent怎么用?C++ DataItem::getComponent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataItem
的用法示例。
在下文中一共展示了DataItem::getComponent方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
// Sort by: Device, Component, Category, DataItem
bool DataItem::operator<(DataItem &aOther)
{
Device *dev = mComponent->getDevice();
if (dev->getId() < aOther.getComponent()->getDevice()->getId())
return true;
else if (dev->getId() > aOther.getComponent()->getDevice()->getId())
return false;
else if (mComponent->getId() < aOther.getComponent()->getId())
return true;
else if (mComponent->getId() > aOther.getComponent()->getId())
return false;
else if (mCategory < aOther.mCategory)
return true;
else if (mCategory == aOther.mCategory)
return mId < aOther.mId;
else
return false;
}
示例2: printSample
string XmlPrinter::printSample(const unsigned int instanceId,
const unsigned int bufferSize,
const uint64_t nextSeq,
const uint64_t firstSeq,
const uint64_t lastSeq,
ComponentEventPtrArray& results
)
{
xmlTextWriterPtr writer;
xmlBufferPtr buf;
string ret;
try {
THROW_IF_XML2_NULL(buf = xmlBufferCreate());
THROW_IF_XML2_NULL(writer = xmlNewTextWriterMemory(buf, 0));
THROW_IF_XML2_ERROR(xmlTextWriterSetIndent(writer, 1));
THROW_IF_XML2_ERROR(xmlTextWriterSetIndentString(writer, BAD_CAST " "));
initXmlDoc(writer, eSTREAMS,
instanceId,
bufferSize,
0, 0,
nextSeq,
firstSeq,
lastSeq);
THROW_IF_XML2_ERROR(xmlTextWriterStartElement(writer, BAD_CAST "Streams"));
// Sort the vector by category.
if (results.size() > 1)
dlib::qsort_array<ComponentEventPtrArray,EventComparer>(results, 0, results.size() - 1, EventCompare);
Device *lastDevice = NULL;
Component *lastComponent = NULL;
int lastCategory = -1;
for (unsigned int i = 0; i < results.size(); i++)
{
ComponentEventPtr result = results[i];
DataItem *dataItem = result->getDataItem();
Component *component = dataItem->getComponent();
Device *device = component->getDevice();
if (device != lastDevice)
{
if (lastDevice != NULL)
THROW_IF_XML2_ERROR(xmlTextWriterEndElement(writer)); // DeviceStream
lastDevice = device;
if (lastComponent != NULL)
THROW_IF_XML2_ERROR(xmlTextWriterEndElement(writer)); // ComponentStream
lastComponent = NULL;
if (lastCategory != -1)
THROW_IF_XML2_ERROR(xmlTextWriterEndElement(writer)); // Category
lastCategory = -1;
addDeviceStream(writer, device);
}
if (component != lastComponent)
{
if (lastComponent != NULL)
THROW_IF_XML2_ERROR(xmlTextWriterEndElement(writer)); // ComponentStream
lastComponent = component;
if (lastCategory != -1)
THROW_IF_XML2_ERROR(xmlTextWriterEndElement(writer)); // Category
lastCategory = -1;
addComponentStream(writer, component);
}
if (lastCategory != dataItem->getCategory())
{
if (lastCategory != -1)
THROW_IF_XML2_ERROR(xmlTextWriterEndElement(writer)); // Category
lastCategory = dataItem->getCategory();
addCategory(writer, dataItem->getCategory());
}
addEvent(writer, result);
}
if (lastCategory != -1)
THROW_IF_XML2_ERROR(xmlTextWriterEndElement(writer)); // Category
if (lastDevice != NULL)
THROW_IF_XML2_ERROR(xmlTextWriterEndElement(writer)); // DeviceStream
if (lastComponent != NULL)
THROW_IF_XML2_ERROR(xmlTextWriterEndElement(writer)); // ComponentStream
THROW_IF_XML2_ERROR(xmlTextWriterEndElement(writer)); // Streams
THROW_IF_XML2_ERROR(xmlTextWriterEndElement(writer)); // MTConnectStreams
THROW_IF_XML2_ERROR(xmlTextWriterEndDocument(writer));
xmlFreeTextWriter(writer);
ret = (string) ((char*) buf->content);
xmlBufferFree(buf);
}
catch (string error) {
if (buf != NULL)
xmlBufferFree(buf);
if (writer != NULL)
xmlFreeTextWriter(writer);
sLogger << dlib::LERROR << "printProbe: " << error;
//.........这里部分代码省略.........