本文整理汇总了C++中DataElement::isKindOf方法的典型用法代码示例。如果您正苦于以下问题:C++ DataElement::isKindOf方法的具体用法?C++ DataElement::isKindOf怎么用?C++ DataElement::isKindOf使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataElement
的用法示例。
在下文中一共展示了DataElement::isKindOf方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
vector<string> ModelServicesImp::getElementNames(const string& filename, const string& type) const
{
vector<string> elementNames;
multimap<Key, DataElement*>::const_iterator iter;
for (iter = mElements.begin(); iter != mElements.end(); ++iter)
{
DataElement* pElement = iter->second;
if (pElement != NULL)
{
string currentFilename = pElement->getFilename();
string lowerCurrentFilename = StringUtilities::toLower(currentFilename);
string lowerElementFilename = StringUtilities::toLower(filename);
if (lowerCurrentFilename == lowerElementFilename)
{
if ((type.empty() == true) || (pElement->isKindOf(type) == true))
{
elementNames.push_back(pElement->getName());
}
}
}
}
return elementNames;
}
示例2: getTopMostElement
DataElement* LayerListImp::getTopMostElement(const string& elementType) const
{
if (elementType.empty() == true)
{
return NULL;
}
for (vector<Layer*>::const_reverse_iterator iter = mLayers.rbegin(); iter != mLayers.rend(); ++iter)
{
Layer* pLayer = *iter;
if ((pLayer != NULL) && (isLayerDisplayed(pLayer) == true))
{
DataElement* pElement = pLayer->getDataElement();
if ((pElement != NULL) && (pElement->isKindOf(elementType) == true))
{
return pElement;
}
}
}
return NULL;
}
示例3: VERIFYNR
void GetDataElement<T>::populateTreeWidgetItem(QTreeWidgetItem* pRoot)
{
VERIFYNR(pRoot != NULL);
QVariant value = pRoot->data(GetSessionItemBase<T>::NameColumn, GetSessionItemBase<T>::SessionItemRole);
void* pValue = value.value<void*>();
DataElement* const pRootElement = reinterpret_cast<DataElement*>(pValue);
const std::vector<DataElement*> elements = Service<ModelServices>()->getElements(pRootElement, std::string());
for (std::vector<DataElement*>::const_iterator iter = elements.begin(); iter != elements.end(); ++iter)
{
DataElement* pChildElement = *iter;
if (pChildElement == NULL)
{
// Disallow NULL elements since that would result in infinite recursion.
continue;
}
std::auto_ptr<QTreeWidgetItem> pChild(new QTreeWidgetItem);
std::string name = pChildElement->getDisplayName();
if (name.empty() == true)
{
name = pChildElement->getName();
}
pChild->setText(GetSessionItemBase<T>::NameColumn, QString::fromStdString(name));
pChild->setData(GetSessionItemBase<T>::NameColumn,
GetSessionItemBase<T>::SessionItemRole, QVariant::fromValue<void*>(pChildElement));
pChild->setText(GetSessionItemBase<T>::TypeColumn, QString::fromStdString(pChildElement->getType()));
populateTreeWidgetItem(pChild.get());
const bool isValid = pChildElement->isKindOf(TypeConverter::toString<T>());
pChild->setFlags(isValid ? Qt::ItemIsEnabled | Qt::ItemIsSelectable : Qt::NoItemFlags);
if (isValid == true || pChild->childCount() > 0)
{
pRoot->addChild(pChild.release());
}
}
}
示例4: getDataElement
DataElement* getDataElement(const char* pName, const char* pType, int create)
{
DataElement* pElement = NULL;
if (pName == NULL || (pType == NULL && create != 0))
{
setLastError(SIMPLE_BAD_PARAMS);
return NULL;
}
const std::string name(pName);
const std::string type(pType == NULL ? std::string() : pType);
SessionItem* pSessionItem = Service<SessionManager>()->getSessionItem(name);
if (pSessionItem != NULL)
{
pElement = dynamic_cast<DataElement*>(pSessionItem);
if (pElement == NULL || (!type.empty() && !pElement->isKindOf(type)))
{
pElement = NULL;
setLastError(SIMPLE_WRONG_TYPE);
return NULL;
}
}
else
{
std::vector<std::string> id = splitIdentifier(name);
DataElement* pParent = NULL;
Service<ModelServices> pModel;
for (size_t idx = 0; idx < id.size(); ++idx)
{
DataElement* pTmp = pModel->getElement(id[idx], (idx == id.size() - 1) ? type : std::string(), pParent);
if (pTmp == NULL)
{
std::vector<DataElement*> children =
pModel->getElements(pParent, (idx == id.size() - 1) ? type : std::string());
for (std::vector<DataElement*>::iterator child = children.begin(); child != children.end(); ++child)
{
if (*child != NULL && (*child)->getDisplayName() == id[idx])
{
pTmp = *child;
break;
}
}
}
if (pTmp == NULL && create != 0 && idx == id.size() - 1)
{
// Last component not found and creation has been requested
if (type == TypeConverter::toString<RasterElement>())
{
// Can't use this function to create a RasterElement
setLastError(SIMPLE_WRONG_TYPE);
return NULL;
}
pTmp = Service<ModelServices>()->createElement(id[idx], type, pParent);
}
if ((pParent = pTmp) == NULL)
{
break;
}
}
if ((pElement = pParent) == NULL)
{
setLastError(SIMPLE_NOT_FOUND);
return NULL;
}
}
setLastError(SIMPLE_NO_ERROR);
return pElement;
}