bt_file_logger_v2.h
Go to the documentation of this file.
1 #pragma once
2 #include <fstream>
3 #include <deque>
4 #include <array>
5 #include <filesystem>
7 
8 namespace BT
9 {
24 {
25 public:
33  FileLogger2(const Tree& tree, std::filesystem::path const& filepath);
34 
35  FileLogger2(const FileLogger2& other) = delete;
36  FileLogger2& operator=(const FileLogger2& other) = delete;
37 
38  FileLogger2(FileLogger2&& other) = default;
39  FileLogger2& operator=(FileLogger2&& other) = default;
40 
41  virtual ~FileLogger2() override;
42 
43  void callback(Duration timestamp, const TreeNode& node, NodeStatus prev_status,
44  NodeStatus status) override;
45 
46  struct Transition
47  {
48  // when serializing, we will remove the initial time and serialize only
49  // 6 bytes, instead of 8
50  uint64_t timestamp_usec;
51  // if you have more than 64.000 nodes, you are doing something wrong :)
52  uint16_t node_uid;
53  // enough bits to contain NodeStatus
54  uint8_t status;
55  };
56 
57  void flush() override;
58 
59 private:
60  struct PImpl;
61  std::unique_ptr<PImpl> _p;
62 
63  void writerLoop();
64 };
65 
66 } // namespace BT
BT
Definition: ex01_wrap_legacy.cpp:29
BT::FileLogger2::Transition::timestamp_usec
uint64_t timestamp_usec
Definition: bt_file_logger_v2.h:50
BT::TreeNode
Abstract base class for Behavior Tree Nodes.
Definition: tree_node.h:118
BT::Tree
Struct used to store a tree. If this object goes out of scope, the tree is destroyed.
Definition: bt_factory.h:91
BT::FileLogger2::Transition
Definition: bt_file_logger_v2.h:46
BT::StatusChangeLogger
Definition: abstract_logger.h:15
BT::Duration
std::chrono::high_resolution_clock::duration Duration
Definition: basic_types.h:628
BT::FileLogger2::Transition::node_uid
uint16_t node_uid
Definition: bt_file_logger_v2.h:52
BT::FileLogger2::~FileLogger2
virtual ~FileLogger2() override
Definition: bt_file_logger_v2.cpp:71
BT::FileLogger2::_p
std::unique_ptr< PImpl > _p
Definition: bt_file_logger_v2.h:60
BT::FileLogger2::flush
void flush() override
Definition: bt_file_logger_v2.cpp:93
BT::FileLogger2
The FileLogger2 is a logger that saves the tree as XML and all the transitions. Data is written to fi...
Definition: bt_file_logger_v2.h:23
BT::FileLogger2::FileLogger2
FileLogger2(const Tree &tree, std::filesystem::path const &filepath)
To correctly read this log with Groot2, you must use the suffix ".btlog". Constructor will throw othe...
Definition: bt_file_logger_v2.cpp:27
BT::FileLogger2::Transition::status
uint8_t status
Definition: bt_file_logger_v2.h:54
BT::FileLogger2::operator=
FileLogger2 & operator=(const FileLogger2 &other)=delete
BT::FileLogger2::writerLoop
void writerLoop()
Definition: bt_file_logger_v2.cpp:98
BT::NodeStatus
NodeStatus
Definition: basic_types.h:33
BT::FileLogger2::callback
void callback(Duration timestamp, const TreeNode &node, NodeStatus prev_status, NodeStatus status) override
Definition: bt_file_logger_v2.cpp:79
BT::FileLogger2::PImpl
Definition: bt_file_logger_v2.cpp:13
abstract_logger.h


behaviortree_cpp_v4
Author(s): Davide Faconti
autogenerated on Fri Dec 13 2024 03:19:16