本文整理汇总了C++中XmlParser::getRoot方法的典型用法代码示例。如果您正苦于以下问题:C++ XmlParser::getRoot方法的具体用法?C++ XmlParser::getRoot怎么用?C++ XmlParser::getRoot使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XmlParser
的用法示例。
在下文中一共展示了XmlParser::getRoot方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: root
InstanceLoader::InstanceLoader(shared_ptr<AgentPlateform> agentPlateform,shared_ptr <Environment> environment, string filename, bool toRun)
{
_toRun = toRun;
if (filename != "")
{
_environment = environment;
_agentPlateform = agentPlateform;
_model = _environment->getModel();
XmlParser parser;
#if BOOST_FILESYSTEM_VERSION == 2
_basedir=fs::path(filename).branch_path().file_string();
#else
_basedir=fs::path(filename).branch_path().string();
#endif
//remplacer branch_path par parent_path dans nouvelle version boost
parser.parseFile(filename);
shared_ptr<XmlNode> root (parser.getRoot());
_parseInstances(root);
_addRelations();
}
_relations.clear();
cerr << " ##################FIN INSTANCES " << endl;
}
示例2: parseInstances
void InstanceLoader::parseInstances(shared_ptr<AgentPlateform> agentPlateform, shared_ptr <Environment> environment, string filename, bool toRun)
{
_toRun = toRun;
_environment = environment;
_agentPlateform = agentPlateform;
_model = _environment->getModel();
XmlParser parser;
#if BOOST_FILESYSTEM_VERSION == 2
_basedir=fs::path(filename).branch_path().file_string();
#else
_basedir=fs::path(filename).branch_path().string();
#endif
cerr << "[InstanceLoader Info] Parse filename: " << filename << endl;
parser.parseFile(filename);
shared_ptr<XmlNode> root (parser.getRoot());
_parseInstances(root);
_addRelations();
_relations.clear();
cerr << " ##################FIN INSTANCES " << endl;
cerr << "[InstanceLoader Info] End of parsing: " << filename << endl;
}
示例3: _readGeometryEntity
//.........这里部分代码省略.........
string name="shape";
if(child->hasProperty("name"))
{
name=child->getProperty("name");
}
shared_ptr<ShapeSpecification> specif(MascaretApplication::getInstance()->getVRComponentFactory()->createShape(name,distances,urls,movable,recursive));
entity->getProperty(name)->addValue(specif);
//entity->set_DEP_current(specif);
entity->setActiveShape(name);
}
else if (child->getName() == "Scale")
{
child->getPropertyReal("sx",scaleFactor.x);
child->getPropertyReal("sy",scaleFactor.y);
child->getPropertyReal("sz",scaleFactor.z);
}
else if (child->getName() == "Animation")
{
string name = child->getProperty("name");
bool running=false;
if (child->hasProperty("running"))
child->getPropertyBoolean("running",running);
string file = "";
if(!child->getProperty("url").empty())
{
#if BOOST_FILESYSTEM_VERSION == 2
file = fs::complete(child->getProperty("url"),_basedir).file_string();
#else
file = fs::complete(child->getProperty("url"),_basedir).string();
#endif
}
shared_ptr<AnimationSpecification> animation(MascaretApplication::getInstance()->getVRComponentFactory()->createAnimation(name, file));
entity->getProperty(name)->addValue(animation);
if (running) entity->playAnimation(name);
}
else if (child->getName() == "Sound")
{
string name = child->getProperty("name");
#if BOOST_FILESYSTEM_VERSION == 2
string file = fs::complete(child->getProperty("url"),_basedir).file_string();
#else
string file = fs::complete(child->getProperty("url"),_basedir).string();
#endif
double gain = 1.0;
double minDist = 1.0;
double maxDist = 100.0;
child->getPropertyReal("gain",gain);
child->getPropertyReal("minDistance",minDist);
child->getPropertyReal("maxDistance",maxDist);
shared_ptr<SoundSpecification> sound(MascaretApplication::getInstance()->getVRComponentFactory()->createSound(name, file, gain,minDist,maxDist));
entity->getProperty(name)->addValue(sound);
sound->attachTo(entity->getReferentialPoint());
}
else if (child->getName() == "Inline")
{
XmlParser parser;
#if BOOST_FILESYSTEM_VERSION == 2
if (parser.parseFile(fs::complete(child->getProperty("url"),_basedir).file_string() ))
#else
if (parser.parseFile(fs::complete(child->getProperty("url"),_basedir).string() ))
#endif
{
shared_ptr<XmlNode> root = parser.getRoot();
_readGeometryEntity(root, entity);
}
}
else if (child->getName() == "InternalOrientationAxe")
{
//TODO: Pourquoi non utilisé ?
Axe _front = AxeFromNodeProperty(child, "frontAxe");
Axe _left = AxeFromNodeProperty(child, "leftAxe");
Axe _above = AxeFromNodeProperty(child, "aboveAxe");
/*point->setFront(_front);
point->setLeft(_left);
point->setAbove(_above);*/
}
else if (child->getName() == "InternalOrientationVector")
{
//TODO:
}
else if (child->getName() == "State")
{
// TODO: Maybe it's not normal to found a State here ?
_initializeStateMachine(child, entity);
}
child = child->getNext();
}
/*
if (entity->getActiveShape())
{
entity->getActiveShape()->setScale(scaleFactor);
} */
}
示例4: _readEntity
//.........这里部分代码省略.........
}
distances.push_back(dist);
}
string name="shape";
if(child->hasProperty("name"))
{
name=child->getProperty("name");
}
shared_ptr<ShapeSpecification> specif(MascaretApplication::getInstance()->getVRComponentFactory()->createShape(name,distances,urls,movable,recursive));
entity->getProperty(name)->addValue(specif);
//entity->set_DEP_current(specif);
entity->setActiveShape(name);
}
else if (child->getName() == "Scale")
{
child->getPropertyReal("sx",scaleFactor.x);
child->getPropertyReal("sy",scaleFactor.y);
child->getPropertyReal("sz",scaleFactor.z);
}
else if (child->getName() == "Animation")
{
string name = child->getProperty("name");
#if BOOST_FILESYSTEM_VERSION == 2
string file = fs::complete(child->getProperty("url"),_basedir).file_string();
#else
string file = fs::complete(child->getProperty("url"),_basedir).string();
#endif
//shared_ptr<AnimationSpecification> animation(MascaretApplication::getInstance()->getVRComponentFactory()->createAnimation(name, file));
//entity->getProperty(name)->addValue(animation);
}
else if (child->getName() == "Sound")
{
string name = child->getProperty("name");
#if BOOST_FILESYSTEM_VERSION == 2
string file = fs::complete(child->getProperty("url"),_basedir).file_string();
#else
string file = fs::complete(child->getProperty("url"),_basedir).string();
#endif
double gain = 1.0;
double minDist = 1.0;
double maxDist = 100.0;
child->getPropertyReal("gain",gain);
child->getPropertyReal("minDistance",minDist);
child->getPropertyReal("maxDistance",maxDist);
shared_ptr<SoundSpecification> sound(MascaretApplication::getInstance()->getVRComponentFactory()->createSound(name, file, gain,minDist,maxDist));
entity->getProperty(name)->addValue(sound);
sound->attachTo(entity->getReferentialPoint());
}
else if (child->getName() == "Inline")
{
XmlParser parser;
#if BOOST_FILESYSTEM_VERSION == 2
if (parser.parseFile(fs::complete(child->getProperty("url"),_basedir).file_string() ))
#else
if (parser.parseFile(fs::complete(child->getProperty("url"),_basedir).string() ))
#endif
{
shared_ptr<XmlNode> root = parser.getRoot();
_readEntity(root, entity);
}
}
else if ( (child->getName()=="Attribute" ) || (child->getName()=="Relation") )
{
Relation r;
r.e=entity;
r.property=child->getProperty("name");
r.value=child->getProperty("value");
_relations.push_back(r);
}
else if (child->getName() == "InternalOrientationAxe")
{
//TODO: Pourquoi non utilisé ?
Axe _front = AxeFromNodeProperty(child, "frontAxe");
Axe _left = AxeFromNodeProperty(child, "leftAxe");
Axe _above = AxeFromNodeProperty(child, "aboveAxe");
}
else if (child->getName() == "InternalOrientationVector")
{
//TODO:
}
else if (child->getName() == "State")
{
_initializeStateMachine(child, entity);
cerr << "[InstanceLoader Info] STM " << child->getName() + " " + child->getProperty("machine") + " " + child->getProperty("state") << endl;
}
child = child->getNext();
}
if (entity->getActiveShape())
{
entity->getActiveShape()->setScale(scaleFactor);
}
}