The TreeObserver is used to collect statistics about which nodes are executed and their returned status. More...
#include <bt_observer.h>
Classes | |
struct | NodeStatistics |
Public Member Functions | |
virtual void | flush () override |
const NodeStatistics & | getStatistics (const std::string &path) const |
const NodeStatistics & | getStatistics (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) |
StatusChangeLogger & | operator= (const StatusChangeLogger &other)=delete |
StatusChangeLogger & | operator= (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 |
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.
BT::TreeObserver::TreeObserver | ( | const BT::Tree & | tree | ) |
Definition at line 7 of file bt_observer.cpp.
|
override |
Definition at line 46 of file bt_observer.cpp.
|
overrideprivatevirtual |
Implements BT::StatusChangeLogger.
Definition at line 49 of file bt_observer.cpp.
|
inlineoverridevirtual |
Implements BT::StatusChangeLogger.
Definition at line 23 of file bt_observer.h.
const TreeObserver::NodeStatistics & BT::TreeObserver::getStatistics | ( | const std::string & | path | ) | const |
Definition at line 80 of file bt_observer.cpp.
const TreeObserver::NodeStatistics & BT::TreeObserver::getStatistics | ( | uint16_t | uid | ) | const |
Definition at line 90 of file bt_observer.cpp.
const std::unordered_map< std::string, uint16_t > & BT::TreeObserver::pathToUID | ( | ) | const |
Definition at line 106 of file bt_observer.cpp.
void BT::TreeObserver::resetStatistics | ( | ) |
const std::unordered_map< uint16_t, TreeObserver::NodeStatistics > & BT::TreeObserver::statistics | ( | ) | const |
Definition at line 101 of file bt_observer.cpp.
const std::map< uint16_t, std::string > & BT::TreeObserver::uidToPath | ( | ) | const |
Definition at line 111 of file bt_observer.cpp.
|
private |
Definition at line 63 of file bt_observer.h.
|
private |
Definition at line 62 of file bt_observer.h.
|
private |
Definition at line 64 of file bt_observer.h.