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 
15  DecoratorNode(const std::string& name, const NodeConfiguration& config);
16 
17  virtual ~DecoratorNode() override = default;
18 
19  void setChild(TreeNode* child);
20 
21  const TreeNode* child() const;
22 
23  TreeNode* child();
24 
26  virtual void halt() override;
27 
29  void haltChild();
30 
31  virtual NodeType type() const override
32  {
33  return NodeType::DECORATOR;
34  }
35 
36  NodeStatus executeTick() override;
37 };
38 
51 {
52  public:
53  typedef std::function<NodeStatus(NodeStatus, TreeNode&)> TickFunctor;
54 
55  // You must provide the function to call when tick() is invoked
56  SimpleDecoratorNode(const std::string& name, TickFunctor tick_functor, const NodeConfiguration& config);
57 
58  ~SimpleDecoratorNode() override = default;
59 
60  protected:
61  virtual NodeStatus tick() override;
62 
63  TickFunctor tick_functor_;
64 };
65 }
66 
67 #endif
const TreeNode * child() const
const std::string & name() const
Name of the instance, not the type.
Definition: tree_node.cpp:73
const NodeConfiguration & config() const
Definition: tree_node.cpp:99
std::function< NodeStatus(NodeStatus, TreeNode &)> TickFunctor
DecoratorNode(const std::string &name, const NodeConfiguration &config)
virtual void halt() override
The method used to interrupt the execution of this node.
The SimpleDecoratorNode provides an easy to use DecoratorNode. The user should simply provide a callb...
TreeNode * child_node_
void haltChild()
Halt() the child node.
void setChild(TreeNode *child)
NodeStatus executeTick() override
The method that should be used to invoke tick() and setStatus();.
Abstract base class for Behavior Tree Nodes.
Definition: tree_node.h:53
virtual NodeType type() const override
virtual ~DecoratorNode() override=default
NodeStatus
Definition: basic_types.h:35
NodeType
Enumerates the possible types of nodes.
Definition: basic_types.h:22
virtual BT::NodeStatus tick()=0
Method to be implemented by the user.


behaviotree_cpp_v3
Author(s): Michele Colledanchise, Davide Faconti
autogenerated on Tue May 4 2021 02:56:24