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

Function applyRecursiveVisitor

src/behavior_tree.cpp:17–38  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

15namespace BT
16{
17void applyRecursiveVisitor(const TreeNode* node,
18 const std::function<void(const TreeNode*)>& visitor)
19{
20 if(node == nullptr)
21 {
22 throw LogicError("One of the children of a DecoratorNode or ControlNode is nullptr");
23 }
24
25 visitor(node);
26
27 if(auto control = dynamic_cast<const BT::ControlNode*>(node))
28 {
29 for(const auto& child : control->children())
30 {
31 applyRecursiveVisitor(static_cast<const TreeNode*>(child), visitor);
32 }
33 }
34 else if(auto decorator = dynamic_cast<const BT::DecoratorNode*>(node))
35 {
36 applyRecursiveVisitor(decorator->child(), visitor);
37 }
38}
39
40void applyRecursiveVisitor(TreeNode* node, const std::function<void(TreeNode*)>& visitor)
41{

Callers 6

haltTreeMethod · 0.85
applyVisitorMethod · 0.85
TESTFunction · 0.85

Calls 2

LogicErrorClass · 0.85
childMethod · 0.45

Tested by 1

TESTFunction · 0.68