MCPcopy Create free account
hub / github.com/BehaviorTree/BehaviorTree.CPP / createTreeFromFile

Method createTreeFromFile

src/bt_factory.cpp:443–466  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

441}
442
443Tree BehaviorTreeFactory::createTreeFromFile(const std::filesystem::path& file_path,
444 Blackboard::Ptr blackboard)
445{
446 // Determine the main tree from the XML before loading into the shared parser.
447 tinyxml2::XMLDocument doc;
448 doc.LoadFile(file_path.string().c_str());
449 std::string main_tree_ID;
450 if(const auto* root = doc.RootElement())
451 {
452 main_tree_ID = detectMainTreeId(root);
453 }
454
455 const std::string resolved_ID = loadXmlAndResolveTreeId(
456 _p->parser.get(), main_tree_ID, [&] { _p->parser->loadFromFile(file_path); });
457
458 // Set the polymorphic cast registry on the blackboard (Issue #943)
459 blackboard->setPolymorphicCastRegistry(_p->polymorphic_registry);
460
461 Tree tree = resolved_ID.empty() ? _p->parser->instantiateTree(blackboard) :
462 _p->parser->instantiateTree(blackboard, resolved_ID);
463 tree.manifests = this->manifests();
464 tree.remapManifestPointers();
465 return tree;
466}
467
468Tree BehaviorTreeFactory::createTree(const std::string& tree_name,
469 Blackboard::Ptr blackboard)

Callers 1

TESTFunction · 0.80

Calls 10

detectMainTreeIdFunction · 0.85
loadXmlAndResolveTreeIdFunction · 0.85
LoadFileMethod · 0.80
loadFromFileMethod · 0.80
instantiateTreeMethod · 0.80
remapManifestPointersMethod · 0.80
stringMethod · 0.45
getMethod · 0.45
emptyMethod · 0.45

Tested by 1

TESTFunction · 0.64