10 if (!
ref_count.compare_exchange_strong(expected,
true))
12 throw LogicError(
"Only one instance of StdCoutLogger shall be created");
25 constexpr
const char* whitespaces =
" ";
26 constexpr
const size_t ws_count = 25;
28 double since_epoch = duration<double>(timestamp).
count();
29 printf(
"[%.3f]: %s%s %s -> %s",
30 since_epoch, node.
name().c_str(),
31 &whitespaces[std::min(ws_count, node.
name().size())],
32 toStr(prev_status,
true).c_str(),
33 toStr(status,
true).c_str() );
34 std::cout << std::endl;
39 std::cout << std::flush;
const std::string & name() const
Name of the instance, not the type.
std::string toStr(T value)
static std::atomic< bool > ref_count
Abstract base class for Behavior Tree Nodes.
StdCoutLogger(const BT::Tree &tree)
static volatile int count
~StdCoutLogger() override
virtual void flush() override
Struct used to store a tree. If this object goes out of scope, the tree is destroyed.
std::chrono::high_resolution_clock::duration Duration
virtual void callback(Duration timestamp, const TreeNode &node, NodeStatus prev_status, NodeStatus status) override