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

Method createTreeFromText

src/bt_factory.cpp:418–441  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

416}
417
418Tree BehaviorTreeFactory::createTreeFromText(const std::string& text,
419 Blackboard::Ptr blackboard)
420{
421 // Determine the main tree from the XML before loading into the shared parser.
422 tinyxml2::XMLDocument doc;
423 doc.Parse(text.c_str(), text.size());
424 std::string main_tree_ID;
425 if(const auto* root = doc.RootElement())
426 {
427 main_tree_ID = detectMainTreeId(root);
428 }
429
430 const std::string resolved_ID = loadXmlAndResolveTreeId(
431 _p->parser.get(), main_tree_ID, [&] { _p->parser->loadFromText(text); });
432
433 // Set the polymorphic cast registry on the blackboard (Issue #943)
434 blackboard->setPolymorphicCastRegistry(_p->polymorphic_registry);
435
436 Tree tree = resolved_ID.empty() ? _p->parser->instantiateTree(blackboard) :
437 _p->parser->instantiateTree(blackboard, resolved_ID);
438 tree.manifests = this->manifests();
439 tree.remapManifestPointers();
440 return tree;
441}
442
443Tree BehaviorTreeFactory::createTreeFromFile(const std::filesystem::path& file_path,
444 Blackboard::Ptr blackboard)

Callers 15

TESTFunction · 0.80
TESTFunction · 0.80
TEST_FFunction · 0.80
TESTFunction · 0.80
TESTFunction · 0.80
TESTFunction · 0.80
TESTFunction · 0.80
createSimpleTreeMethod · 0.80
TEST_FFunction · 0.80
TESTFunction · 0.80
TESTFunction · 0.80
TEST_FFunction · 0.80

Calls 10

detectMainTreeIdFunction · 0.85
loadXmlAndResolveTreeIdFunction · 0.85
ParseMethod · 0.80
loadFromTextMethod · 0.80
instantiateTreeMethod · 0.80
remapManifestPointersMethod · 0.80
sizeMethod · 0.45
getMethod · 0.45
emptyMethod · 0.45

Tested by 15

TESTFunction · 0.64
TESTFunction · 0.64
TEST_FFunction · 0.64
TESTFunction · 0.64
TESTFunction · 0.64
TESTFunction · 0.64
TESTFunction · 0.64
createSimpleTreeMethod · 0.64
TEST_FFunction · 0.64
TESTFunction · 0.64
TESTFunction · 0.64
TEST_FFunction · 0.64