decorator_node.h
Go to the documentation of this file.
00001 #ifndef DECORATORNODE_H
00002 #define DECORATORNODE_H
00003 
00004 #include "behaviortree_cpp/tree_node.h"
00005 
00006 namespace BT
00007 {
00008 class DecoratorNode : public TreeNode
00009 {
00010   protected:
00011     TreeNode* child_node_;
00012 
00013   public:
00014     // Constructor
00015     DecoratorNode(const std::string& name, const NodeParameters& parameters);
00016 
00017     virtual ~DecoratorNode() override = default;
00018 
00019     // The method used to fill the child vector
00020     void setChild(TreeNode* child);
00021 
00022     const TreeNode* child() const;
00023     TreeNode* child();
00024 
00025     // The method used to interrupt the execution of the node
00026     virtual void halt() override;
00027 
00028     void haltChild();
00029 
00030     virtual NodeType type() const override
00031     {
00032         return NodeType::DECORATOR;
00033     }
00034 
00035     NodeStatus executeTick() override;
00036 };
00037 
00049 class SimpleDecoratorNode : public DecoratorNode
00050 {
00051   public:
00052     typedef std::function<NodeStatus(NodeStatus, TreeNode&)> TickFunctor;
00053 
00054     // Constructor: you must provide the function to call when tick() is invoked
00055     SimpleDecoratorNode(const std::string& name, TickFunctor tick_functor,
00056                         const NodeParameters& params = NodeParameters());
00057 
00058     ~SimpleDecoratorNode() override = default;
00059 
00060   protected:
00061     virtual NodeStatus tick() override;
00062 
00063     TickFunctor tick_functor_;
00064 };
00065 }
00066 
00067 #endif


behaviortree_cpp
Author(s): Michele Colledanchise, Davide Faconti
autogenerated on Sat Feb 2 2019 03:50:10