本文整理汇总了C++中BaseObject::findData方法的典型用法代码示例。如果您正苦于以下问题:C++ BaseObject::findData方法的具体用法?C++ BaseObject::findData怎么用?C++ BaseObject::findData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BaseObject
的用法示例。
在下文中一共展示了BaseObject::findData方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: checkAttributes
void checkAttributes()
{
std::stringstream scene ;
scene << "<?xml version='1.0'?>"
"<Node name='Root' gravity='0 -9.81 0' time='0' animate='0' > \n"
" <OglLabel name='label1'/> \n"
"</Node> \n" ;
Node::SPtr root = SceneLoaderXML::loadFromMemory ("testscene",
scene.str().c_str(),
scene.str().size()) ;
ASSERT_NE(root.get(), nullptr) ;
root->init(ExecParams::defaultInstance()) ;
BaseObject* lm = root->getObject("label1") ;
ASSERT_NE(lm, nullptr) ;
/// List of the supported attributes the user expect to find
/// This list needs to be updated if you add an attribute.
vector<string> attrnames = {
"prefix", "label", "suffix", "x", "y", "fontsize", "color",
"selectContrastingColor", "updateLabelEveryNbSteps",
"visible"};
for(auto& attrname : attrnames)
EXPECT_NE( lm->findData(attrname), nullptr ) << "Missing attribute with name '" << attrname << "'." ;
}
示例2: deriveTypeFromParentValue
BaseData* deriveTypeFromParentValue(Base* obj, const std::string& value)
{
BaseObject* o = dynamic_cast<BaseObject*>(obj);
if (!o)
return nullptr;
// if data is a link
if (value.length() > 0 && value[0] == '@')
{
std::string componentPath = value.substr(1, value.find('.') - 1);
std::string parentDataName = value.substr(value.find('.') + 1);
if (!o->getContext())
{
msg_warning("SofaPython") << "No context created. Cannot find data link to derive input type.";
return nullptr;
}
BaseObject* component;
component = o->getContext()->get<BaseObject>(componentPath);
if (!component)
msg_warning("SofaPython") << "No object with path " << componentPath << " in scene graph.";
BaseData* parentData = component->findData(parentDataName);
return parentData->getNewInstance();
}
return nullptr;
}
示例3: setSrc
void BaseObject::setSrc(const std::string &valueString, const BaseObject *loader, std::vector< std::string > *attributeList)
{
BaseObject* obj = this;
std::multimap < std::string, BaseData*> dataLoaderMap(loader->m_aliasData);
std::multimap < std::string, BaseData*>::iterator it_map;
//for (unsigned int j = 0; j<loader->m_fieldVec.size(); ++j)
//{
// dataLoaderMap.insert (std::pair<std::string, BaseData*> (loader->m_fieldVec[j].first, loader->m_fieldVec[j].second));
//}
if (attributeList != 0)
{
for (unsigned int j = 0; j<attributeList->size(); ++j)
{
it_map = dataLoaderMap.find ((*attributeList)[j]);
if (it_map != dataLoaderMap.end())
dataLoaderMap.erase (it_map);
}
}
// -- Temporary patch, using exceptions. TODO: use a flag to set Data not to be automatically linked. --
//{
it_map = dataLoaderMap.find ("type");
if (it_map != dataLoaderMap.end())
dataLoaderMap.erase (it_map);
it_map = dataLoaderMap.find ("filename");
if (it_map != dataLoaderMap.end())
dataLoaderMap.erase (it_map);
//}
for (it_map = dataLoaderMap.begin(); it_map != dataLoaderMap.end(); ++it_map)
{
BaseData* data = obj->findData( (*it_map).first );
if (data != NULL)
{
if (!(*it_map).second->isAutoLink())
{
sout << "Disabling autolink for Data " << data->getName() << sendl;
}
else
{
//serr << "Autolinking Data " << data->getName() << sendl;
std::string linkPath = valueString+"."+(*it_map).first;
data->setParent( (*it_map).second, linkPath);
}
}
}
}