BehaviorTree
Core Library to create and execute Behavior Trees
Loading...
Searching...
No Matches
bt_parser.h
1/* Copyright (C) 2023-2025 Davide Faconti - All Rights Reserved
2*
3* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"),
4* to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
5* and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
7*
8* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
9* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
10* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
11*/
12
13#pragma once
14
15#include "behaviortree_cpp/blackboard.h"
16#include "behaviortree_cpp/bt_factory.h"
17
18#include <filesystem>
19
20namespace BT
21{
22/**
23 * @brief The BehaviorTreeParser is a class used to read the model
24 * of a BehaviorTree from file or text and instantiate the
25 * corresponding tree using the BehaviorTreeFactory.
26 */
27class Parser
28{
29public:
30 Parser() = default;
31
32 virtual ~Parser() = default;
33
34 Parser(const Parser& other) = delete;
35 Parser& operator=(const Parser& other) = delete;
36
37 Parser(Parser&& other) = default;
38 Parser& operator=(Parser&& other) = default;
39
40 virtual void loadFromFile(const std::filesystem::path& filename,
41 bool add_includes = true) = 0;
42
43 virtual void loadFromText(const std::string& xml_text, bool add_includes = true) = 0;
44
45 virtual std::vector<std::string> registeredBehaviorTrees() const = 0;
46
47 virtual Tree instantiateTree(const Blackboard::Ptr& root_blackboard,
48 std::string tree_name = {}) = 0;
49
50 virtual void clearInternalState(){};
51};
52
53} // namespace BT
The Blackboard is the mechanism used by BehaviorTrees to exchange typed data.
Definition: blackboard.h:35
The BehaviorTreeParser is a class used to read the model of a BehaviorTree from file or text and inst...
Definition: bt_parser.h:28
Struct used to store a tree. If this object goes out of scope, the tree is destroyed.
Definition: bt_factory.h:96
Definition: action_node.h:24