mirror of
https://github.com/moveit/moveit_task_constructor.git
synced 2025-11-04 14:49:57 +08:00
operator<< for Interface + Priority
Co-authored by v4hn
This commit is contained in:
parent
7c6eb1c0f3
commit
9466517f72
@ -205,6 +205,9 @@ private:
|
||||
using base_type::remove_if;
|
||||
};
|
||||
|
||||
std::ostream& operator<<(std::ostream& os, const InterfaceState::Priority& prio);
|
||||
std::ostream& operator<<(std::ostream& os, const Interface& interface);
|
||||
|
||||
class CostTerm;
|
||||
class StagePrivate;
|
||||
class ContainerBasePrivate;
|
||||
|
||||
@ -81,10 +81,6 @@ bool InterfaceState::Priority::operator<(const InterfaceState::Priority& other)
|
||||
return depth() > other.depth(); // larger depth = smaller prio!
|
||||
}
|
||||
|
||||
std::ostream& operator<<(std::ostream& os, const InterfaceState::Priority& p) {
|
||||
return os << "[depth: " << p.depth() << ", cost: " << p.cost() << "]";
|
||||
}
|
||||
|
||||
Interface::Interface(const Interface::NotifyFunction& notify) : notify_(notify) {}
|
||||
|
||||
// Announce a new InterfaceState
|
||||
@ -138,6 +134,21 @@ void Interface::updatePriority(InterfaceState* state, const InterfaceState::Prio
|
||||
notify_(it, true); // notify callback
|
||||
}
|
||||
|
||||
std::ostream& operator<<(std::ostream& os, const Interface& interface) {
|
||||
if (interface.empty())
|
||||
os << "---";
|
||||
for (const auto& istate : interface)
|
||||
os << istate->priority() << " ";
|
||||
return os;
|
||||
}
|
||||
std::ostream& operator<<(std::ostream& os, const InterfaceState::Priority& prio) {
|
||||
static const char* red = "\033[31m";
|
||||
static const char* green = "\033[32m";
|
||||
static const char* color_reset = "\033[m";
|
||||
os << (prio.enabled() ? green : red) << prio.depth() << ":" << prio.cost() << color_reset;
|
||||
return os;
|
||||
}
|
||||
|
||||
void SolutionBase::setCreator(Stage* creator) {
|
||||
assert(creator_ == nullptr || creator_ == creator); // creator must only set once
|
||||
creator_ = creator;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user