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

The TreeObserver is used to collect statistics about which nodes are executed and their returned status. More...

#include <bt_observer.h>

Inheritance diagram for BT::TreeObserver:
Inheritance graph
[legend]

Classes

struct  NodeStatistics
 

Public Member Functions

virtual void flush () override
 
const NodeStatisticsgetStatistics (const std::string &path) const
 
const NodeStatisticsgetStatistics (uint16_t uid) const
 
const std::unordered_map< std::string, uint16_t > & pathToUID () const
 
void resetStatistics ()
 
const std::unordered_map< uint16_t, NodeStatistics > & statistics () const
 
 TreeObserver (const BT::Tree &tree)
 
const std::map< uint16_t, std::string > & uidToPath () const
 
 ~TreeObserver () override
 
- Public Member Functions inherited from BT::StatusChangeLogger
bool enabled () const
 
void enableTransitionToIdle (bool enable)
 
StatusChangeLoggeroperator= (const StatusChangeLogger &other)=delete
 
StatusChangeLoggeroperator= (StatusChangeLogger &&other)=default
 
void setEnabled (bool enabled)
 
void setTimestampType (TimestampType type)
 
bool showsTransitionToIdle () const
 
 StatusChangeLogger (const StatusChangeLogger &other)=delete
 
 StatusChangeLogger (StatusChangeLogger &&other)=default
 
 StatusChangeLogger (TreeNode *root_node)
 
virtual ~StatusChangeLogger ()=default
 

Private Member Functions

virtual void callback (Duration timestamp, const TreeNode &node, NodeStatus prev_status, NodeStatus status) override
 

Private Attributes

std::unordered_map< std::string, uint16_t > _path_to_uid
 
std::unordered_map< uint16_t, NodeStatistics_statistics
 
std::map< uint16_t, std::string > _uid_to_path
 

Detailed Description

The TreeObserver is used to collect statistics about which nodes are executed and their returned status.

It is particularly useful to create unit tests, since if allow to determine if a certain transition happened as expected, in a non intrusive way.

Definition at line 17 of file bt_observer.h.

Constructor & Destructor Documentation

◆ TreeObserver()

BT::TreeObserver::TreeObserver ( const BT::Tree tree)

Definition at line 7 of file bt_observer.cpp.

◆ ~TreeObserver()

BT::TreeObserver::~TreeObserver ( )
override

Definition at line 46 of file bt_observer.cpp.

Member Function Documentation

◆ callback()

void BT::TreeObserver::callback ( Duration  timestamp,
const TreeNode node,
NodeStatus  prev_status,
NodeStatus  status 
)
overrideprivatevirtual

Implements BT::StatusChangeLogger.

Definition at line 49 of file bt_observer.cpp.

◆ flush()

virtual void BT::TreeObserver::flush ( )
inlineoverridevirtual

Implements BT::StatusChangeLogger.

Definition at line 23 of file bt_observer.h.

◆ getStatistics() [1/2]

const TreeObserver::NodeStatistics & BT::TreeObserver::getStatistics ( const std::string &  path) const

Definition at line 80 of file bt_observer.cpp.

◆ getStatistics() [2/2]

const TreeObserver::NodeStatistics & BT::TreeObserver::getStatistics ( uint16_t  uid) const

Definition at line 90 of file bt_observer.cpp.

◆ pathToUID()

const std::unordered_map< std::string, uint16_t > & BT::TreeObserver::pathToUID ( ) const

Definition at line 106 of file bt_observer.cpp.

◆ resetStatistics()

void BT::TreeObserver::resetStatistics ( )

◆ statistics()

const std::unordered_map< uint16_t, TreeObserver::NodeStatistics > & BT::TreeObserver::statistics ( ) const

Definition at line 101 of file bt_observer.cpp.

◆ uidToPath()

const std::map< uint16_t, std::string > & BT::TreeObserver::uidToPath ( ) const

Definition at line 111 of file bt_observer.cpp.

Member Data Documentation

◆ _path_to_uid

std::unordered_map<std::string, uint16_t> BT::TreeObserver::_path_to_uid
private

Definition at line 63 of file bt_observer.h.

◆ _statistics

std::unordered_map<uint16_t, NodeStatistics> BT::TreeObserver::_statistics
private

Definition at line 62 of file bt_observer.h.

◆ _uid_to_path

std::map<uint16_t, std::string> BT::TreeObserver::_uid_to_path
private

Definition at line 64 of file bt_observer.h.


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


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