From 01433554aeda891ad7448603131c3dbc20c0c5bc Mon Sep 17 00:00:00 2001 From: Joseph Mirabel <jmirabel@laas.fr> Date: Thu, 24 Jul 2014 10:37:25 +0200 Subject: [PATCH] Unify GraphComponent::print --- include/hpp/manipulation/graph/graph.hh | 6 +++++- src/graph/edge.cc | 4 ++-- src/graph/graph.cc | 2 +- src/graph/node-selector.cc | 2 +- src/graph/node.cc | 2 +- 5 files changed, 10 insertions(+), 6 deletions(-) diff --git a/include/hpp/manipulation/graph/graph.hh b/include/hpp/manipulation/graph/graph.hh index 62eaed68..b971a10e 100644 --- a/include/hpp/manipulation/graph/graph.hh +++ b/include/hpp/manipulation/graph/graph.hh @@ -68,7 +68,11 @@ namespace hpp { } /// Print the object in a stream. - virtual std::ostream& print (std::ostream& os) const = 0; + virtual std::ostream& print (std::ostream& os) const + { + os << id () << " : " << name (); + return os; + } /// Set the constraints of the component. virtual void constraints (const ConstraintPtr_t& /* constraints */) diff --git a/src/graph/edge.cc b/src/graph/edge.cc index 1d4f40c2..007f0b04 100644 --- a/src/graph/edge.cc +++ b/src/graph/edge.cc @@ -44,8 +44,8 @@ namespace hpp { std::ostream& Edge::print (std::ostream& os) const { - os << " | | |__ " << name () << " --> " - << to_.lock ()->name (); + GraphComponent::print (os << " | | |__ ") + << " --> " << to_.lock ()->name () << std::endl; return os; } diff --git a/src/graph/graph.cc b/src/graph/graph.cc index 786a35c5..17681831 100644 --- a/src/graph/graph.cc +++ b/src/graph/graph.cc @@ -76,7 +76,7 @@ namespace hpp { std::ostream& Graph::print (std::ostream& os) const { - os << name () << std::endl; + GraphComponent::print (os) << std::endl; for (NodeSelectors_t::const_iterator it = nodeSelectors_.begin(); it != nodeSelectors_.end(); it++) os << *(*it); diff --git a/src/graph/node-selector.cc b/src/graph/node-selector.cc index dc647502..e8d7dc3d 100644 --- a/src/graph/node-selector.cc +++ b/src/graph/node-selector.cc @@ -69,7 +69,7 @@ namespace hpp { std::ostream& NodeSelector::print (std::ostream& os) const { - os << " |__ " << name() << std::endl; + GraphComponent::print (os << " |__ ") << std::endl; for (Nodes_t::const_iterator it = orderedStates_.begin(); orderedStates_.end() != it; it++) os << *(*it); diff --git a/src/graph/node.cc b/src/graph/node.cc index cbc44808..beaf139b 100644 --- a/src/graph/node.cc +++ b/src/graph/node.cc @@ -71,7 +71,7 @@ namespace hpp { std::ostream& Node::print (std::ostream& os) const { - os << " | |_ " << name() << std::endl; + GraphComponent::print (os << " | |__ ") << std::endl; for (Edges_t::const_iterator it = neighbors_.begin(); it != neighbors_.end(); it++) os << *(*it); -- GitLab