* @brief The BehaviorTreeFactory is used to create instances of a * TreeNode at run-time. * * Some node types are "builtin", whilst other are used defined and need * to be registered using a unique ID. */
| 232 | * to be registered using a unique ID. |
| 233 | */ |
| 234 | class BehaviorTreeFactory |
| 235 | { |
| 236 | public: |
| 237 | BehaviorTreeFactory(); |
| 238 | ~BehaviorTreeFactory(); |
| 239 | |
| 240 | BehaviorTreeFactory(const BehaviorTreeFactory& other) = delete; |
| 241 | BehaviorTreeFactory& operator=(const BehaviorTreeFactory& other) = delete; |
| 242 | |
| 243 | BehaviorTreeFactory(BehaviorTreeFactory&& other) noexcept; |
| 244 | BehaviorTreeFactory& operator=(BehaviorTreeFactory&& other) noexcept; |
| 245 | |
| 246 | /// Remove a registered ID. |
| 247 | bool unregisterBuilder(const std::string& ID); |
| 248 | |
| 249 | /** The most generic way to register a NodeBuilder. |
| 250 | * |
| 251 | * Throws if you try to register twice a builder with the same |
| 252 | * registration_ID. |
| 253 | */ |
| 254 | void registerBuilder(const TreeNodeManifest& manifest, const NodeBuilder& builder); |
| 255 | |
| 256 | template <typename T> |
| 257 | void registerBuilder(const std::string& ID, const NodeBuilder& builder) |
| 258 | { |
| 259 | auto manifest = CreateManifest<T>(ID); |
| 260 | registerBuilder(manifest, builder); |
| 261 | } |
| 262 | |
| 263 | /** |
| 264 | * @brief registerSimpleAction help you register nodes of type SimpleActionNode. |
| 265 | * |
| 266 | * @param ID registration ID |
| 267 | * @param tick_functor the callback to be invoked in the tick() method. |
| 268 | * @param ports if your SimpleNode requires ports, provide the list here. |
| 269 | * |
| 270 | * */ |
| 271 | void registerSimpleAction(const std::string& ID, |
| 272 | const SimpleActionNode::TickFunctor& tick_functor, |
| 273 | PortsList ports = {}); |
| 274 | /** |
| 275 | * @brief registerSimpleCondition help you register nodes of type SimpleConditionNode. |
| 276 | * |
| 277 | * @param ID registration ID |
| 278 | * @param tick_functor the callback to be invoked in the tick() method. |
| 279 | * @param ports if your SimpleNode requires ports, provide the list here. |
| 280 | * |
| 281 | * */ |
| 282 | void registerSimpleCondition(const std::string& ID, |
| 283 | const SimpleConditionNode::TickFunctor& tick_functor, |
| 284 | PortsList ports = {}); |
| 285 | /** |
| 286 | * @brief registerSimpleDecorator help you register nodes of type SimpleDecoratorNode. |
| 287 | * |
| 288 | * @param ID registration ID |
| 289 | * @param tick_functor the callback to be invoked in the tick() method. |
| 290 | * @param ports if your SimpleNode requires ports, provide the list here. |
| 291 | * |