decorator_node.h
Go to the documentation of this file.
1 #ifndef DECORATORNODE_H
2 #define DECORATORNODE_H
3 
5 
6 namespace BT
7 {
8 class DecoratorNode : public TreeNode
9 {
10 protected:
12 
13 public:
14  DecoratorNode(const std::string& name, const NodeConfig& config);
15 
16  virtual ~DecoratorNode() override = default;
17 
18  void setChild(TreeNode* child);
19 
20  const TreeNode* child() const;
21 
22  TreeNode* child();
23 
25  virtual void halt() override;
26 
28  void haltChild();
29 
30  virtual NodeType type() const override
31  {
32  return NodeType::DECORATOR;
33  }
34 
35  NodeStatus executeTick() override;
36 
39  void resetChild();
40 };
41 
53 {
54 public:
55  using TickFunctor = std::function<NodeStatus(NodeStatus, TreeNode&)>;
56 
57  // You must provide the function to call when tick() is invoked
58  SimpleDecoratorNode(const std::string& name, TickFunctor tick_functor,
59  const NodeConfig& config);
60 
61  ~SimpleDecoratorNode() override = default;
62 
63 protected:
64  virtual NodeStatus tick() override;
65 
67 };
68 } // namespace BT
69 
70 #endif
BT
Definition: ex01_wrap_legacy.cpp:29
BT::NodeType
NodeType
Enumerates the possible types of nodes.
Definition: basic_types.h:20
BT::DecoratorNode::executeTick
NodeStatus executeTick() override
The method that should be used to invoke tick() and setStatus();.
Definition: decorator_node.cpp:77
BT::TreeNode::config
const NodeConfig & config() const
Definition: tree_node.cpp:345
BT::SimpleDecoratorNode::TickFunctor
std::function< NodeStatus(NodeStatus, TreeNode &)> TickFunctor
Definition: decorator_node.h:55
BT::SimpleDecoratorNode::tick
virtual NodeStatus tick() override
Method to be implemented by the user.
Definition: decorator_node.cpp:72
BT::SimpleDecoratorNode
The SimpleDecoratorNode provides an easy to use DecoratorNode. The user should simply provide a callb...
Definition: decorator_node.h:52
BT::DecoratorNode::type
virtual NodeType type() const override
Definition: decorator_node.h:30
BT::NodeType::DECORATOR
@ DECORATOR
BT::DecoratorNode::haltChild
void haltChild()
Same as resetChild()
Definition: decorator_node.cpp:48
BT::TreeNode
Abstract base class for Behavior Tree Nodes.
Definition: tree_node.h:118
BT::DecoratorNode
Definition: decorator_node.h:8
BT::DecoratorNode::~DecoratorNode
virtual ~DecoratorNode() override=default
BT::SimpleDecoratorNode::~SimpleDecoratorNode
~SimpleDecoratorNode() override=default
BT::SimpleDecoratorNode::SimpleDecoratorNode
SimpleDecoratorNode(const std::string &name, TickFunctor tick_functor, const NodeConfig &config)
Definition: decorator_node.cpp:66
BT::TreeNode::name
const std::string & name() const
Name of the instance, not the type.
Definition: tree_node.cpp:296
BT::TreeNode::DecoratorNode
friend class DecoratorNode
Definition: tree_node.h:368
BT::DecoratorNode::child
const TreeNode * child() const
Definition: decorator_node.cpp:38
BT::SimpleDecoratorNode::tick_functor_
TickFunctor tick_functor_
Definition: decorator_node.h:66
BT::DecoratorNode::halt
virtual void halt() override
The method used to interrupt the execution of this node.
Definition: decorator_node.cpp:32
BT::DecoratorNode::setChild
void setChild(TreeNode *child)
Definition: decorator_node.cpp:22
BT::NodeConfig
Definition: tree_node.h:73
BT::DecoratorNode::resetChild
void resetChild()
Definition: decorator_node.cpp:53
tree_node.h
BT::NodeStatus
NodeStatus
Definition: basic_types.h:33
BT::DecoratorNode::child_node_
TreeNode * child_node_
Definition: decorator_node.h:11


behaviortree_cpp_v4
Author(s): Davide Faconti
autogenerated on Fri Jun 28 2024 02:20:07