Classes | Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
BT::BehaviorTreeFactory Class Reference

#include <bt_factory.h>

Classes

struct  has_static_method_requiredParams
 
struct  has_static_method_requiredParams< T, typename std::enable_if< std::is_same< decltype(T::requiredNodeParameters()), const NodeParameters & >::value >::type >
 

Public Member Functions

 BehaviorTreeFactory ()
 
const std::map< std::string, NodeBuilder > & builders () const
 All the builders. Made available mostly for debug purposes. More...
 
const std::set< std::string > & builtinNodes () const
 
std::unique_ptr< TreeNodeinstantiateTreeNode (const std::string &ID, const std::string &name, const NodeParameters &params, const Blackboard::Ptr &blackboard) const
 instantiateTreeNode creates a TreeNode More...
 
const std::vector< TreeNodeManifest > & manifests () const
 Manifests of all the registered TreeNodes. More...
 
void registerBuilder (const TreeNodeManifest &manifest, NodeBuilder builder)
 
void registerFromPlugin (const std::string file_path)
 registerFromPlugin load a shared library and execute the function BT_REGISTER_NODES (see macro). More...
 
template<typename T >
void registerNodeType (const std::string &ID)
 
void registerSimpleAction (const std::string &ID, const SimpleActionNode::TickFunctor &tick_functor)
 Register a SimpleActionNode. More...
 
void registerSimpleCondition (const std::string &ID, const SimpleConditionNode::TickFunctor &tick_functor)
 Register a SimpleConditionNode. More...
 
void registerSimpleDecorator (const std::string &ID, const SimpleDecoratorNode::TickFunctor &tick_functor)
 Register a SimpleDecoratorNode. More...
 
bool unregisterBuilder (const std::string &ID)
 

Private Types

template<typename T >
using has_default_constructor = typename std::is_constructible< T, const std::string & >
 
template<typename T >
using has_params_constructor = typename std::is_constructible< T, const std::string &, const NodeParameters & >
 

Private Member Functions

template<typename T >
NodeBuilder getBuilderImpl (typename std::enable_if< !has_params_constructor< T >::value >::type *=nullptr)
 
template<typename T >
NodeBuilder getBuilderImpl (typename std::enable_if< has_default_constructor< T >::value &&has_params_constructor< T >::value >::type *=nullptr)
 
template<typename T >
NodeBuilder getBuilderImpl (typename std::enable_if<!has_default_constructor< T >::value &&has_params_constructor< T >::value >::type *=nullptr)
 
template<typename T >
NodeParameters getRequiredParamsImpl (typename std::enable_if< has_static_method_requiredParams< T >::value >::type *=nullptr)
 
template<typename T >
NodeParameters getRequiredParamsImpl (typename std::enable_if< !has_static_method_requiredParams< T >::value >::type *=nullptr)
 
template<typename T >
void registerNodeTypeImpl (const std::string &ID)
 
void sortTreeNodeManifests ()
 

Private Attributes

std::map< std::string, NodeBuilderbuilders_
 
std::set< std::string > builtin_IDs_
 
std::vector< TreeNodeManifestmanifests_
 

Detailed Description

Definition at line 45 of file bt_factory.h.

Member Typedef Documentation

template<typename T >
using BT::BehaviorTreeFactory::has_default_constructor = typename std::is_constructible<T, const std::string&>
private

Definition at line 151 of file bt_factory.h.

template<typename T >
using BT::BehaviorTreeFactory::has_params_constructor = typename std::is_constructible<T, const std::string&, const NodeParameters&>
private

Definition at line 154 of file bt_factory.h.

Constructor & Destructor Documentation

BT::BehaviorTreeFactory::BehaviorTreeFactory ( )

Definition at line 18 of file bt_factory.cpp.

Member Function Documentation

const std::map< std::string, NodeBuilder > & BT::BehaviorTreeFactory::builders ( ) const

All the builders. Made available mostly for debug purposes.

Definition at line 148 of file bt_factory.cpp.

const std::set< std::string > & BT::BehaviorTreeFactory::builtinNodes ( ) const

Definition at line 158 of file bt_factory.cpp.

template<typename T >
NodeBuilder BT::BehaviorTreeFactory::getBuilderImpl ( typename std::enable_if< !has_params_constructor< T >::value >::type *  = nullptr)
inlineprivate

Definition at line 174 of file bt_factory.h.

template<typename T >
NodeBuilder BT::BehaviorTreeFactory::getBuilderImpl ( typename std::enable_if< has_default_constructor< T >::value &&has_params_constructor< T >::value >::type *  = nullptr)
inlineprivate

Definition at line 183 of file bt_factory.h.

template<typename T >
NodeBuilder BT::BehaviorTreeFactory::getBuilderImpl ( typename std::enable_if<!has_default_constructor< T >::value &&has_params_constructor< T >::value >::type *  = nullptr)
inlineprivate

Definition at line 197 of file bt_factory.h.

template<typename T >
NodeParameters BT::BehaviorTreeFactory::getRequiredParamsImpl ( typename std::enable_if< has_static_method_requiredParams< T >::value >::type *  = nullptr)
inlineprivate

Definition at line 206 of file bt_factory.h.

template<typename T >
NodeParameters BT::BehaviorTreeFactory::getRequiredParamsImpl ( typename std::enable_if< !has_static_method_requiredParams< T >::value >::type *  = nullptr)
inlineprivate

Definition at line 212 of file bt_factory.h.

std::unique_ptr< TreeNode > BT::BehaviorTreeFactory::instantiateTreeNode ( const std::string &  ID,
const std::string &  name,
const NodeParameters params,
const Blackboard::Ptr blackboard 
) const

instantiateTreeNode creates a TreeNode

Parameters
IDunique ID used to register the node type
namename of this particular instance
paramsparameters (usually read from the XML definition)
Returns
new node.

Definition at line 125 of file bt_factory.cpp.

const std::vector< TreeNodeManifest > & BT::BehaviorTreeFactory::manifests ( ) const

Manifests of all the registered TreeNodes.

Definition at line 153 of file bt_factory.cpp.

void BT::BehaviorTreeFactory::registerBuilder ( const TreeNodeManifest manifest,
NodeBuilder  builder 
)

More generic way to register your own builder. Most of the time you should use registerSimple???? or registerNodeType<> instead.

Definition at line 61 of file bt_factory.cpp.

void BT::BehaviorTreeFactory::registerFromPlugin ( const std::string  file_path)

registerFromPlugin load a shared library and execute the function BT_REGISTER_NODES (see macro).

This method may throw.

Parameters
file_pathpath of the file

Definition at line 107 of file bt_factory.cpp.

template<typename T >
void BT::BehaviorTreeFactory::registerNodeType ( const std::string &  ID)
inline

registerNodeType is the method to use to register your custom TreeNode.

It accepts only classed derived from either ActionNodeBase, DecoratorNode, ControlNode or ConditionNode.

REMINDER: If you want your derived class to

Definition at line 98 of file bt_factory.h.

template<typename T >
void BT::BehaviorTreeFactory::registerNodeTypeImpl ( const std::string &  ID)
inlineprivate

Definition at line 165 of file bt_factory.h.

void BT::BehaviorTreeFactory::registerSimpleAction ( const std::string &  ID,
const SimpleActionNode::TickFunctor tick_functor 
)

Register a SimpleActionNode.

Definition at line 85 of file bt_factory.cpp.

void BT::BehaviorTreeFactory::registerSimpleCondition ( const std::string &  ID,
const SimpleConditionNode::TickFunctor tick_functor 
)

Register a SimpleConditionNode.

Definition at line 74 of file bt_factory.cpp.

void BT::BehaviorTreeFactory::registerSimpleDecorator ( const std::string &  ID,
const SimpleDecoratorNode::TickFunctor tick_functor 
)

Register a SimpleDecoratorNode.

Definition at line 96 of file bt_factory.cpp.

void BT::BehaviorTreeFactory::sortTreeNodeManifests ( )
private

Definition at line 163 of file bt_factory.cpp.

bool BT::BehaviorTreeFactory::unregisterBuilder ( const std::string &  ID)

Definition at line 50 of file bt_factory.cpp.

Member Data Documentation

std::map<std::string, NodeBuilder> BT::BehaviorTreeFactory::builders_
private

Definition at line 143 of file bt_factory.h.

std::set<std::string> BT::BehaviorTreeFactory::builtin_IDs_
private

Definition at line 145 of file bt_factory.h.

std::vector<TreeNodeManifest> BT::BehaviorTreeFactory::manifests_
private

Definition at line 144 of file bt_factory.h.


The documentation for this class was generated from the following files:


behaviortree_cpp
Author(s): Michele Colledanchise, Davide Faconti
autogenerated on Sat Feb 2 2019 04:01:55