5252namespace moveit {
5353namespace task_constructor {
5454
55+ template <>
56+ const char * flowSymbol<START_IF_MASK>(InterfaceFlags f) {
57+ f = f & START_IF_MASK;
58+ if (f == READS_START)
59+ return " →" ;
60+ if (f == WRITES_PREV_END)
61+ return " ←" ;
62+ if (f == UNKNOWN)
63+ return " ?" ;
64+ return " ↔" ;
65+ }
66+
67+ template <>
68+ const char * flowSymbol<END_IF_MASK>(InterfaceFlags f) {
69+ f = f & END_IF_MASK;
70+ if (f == READS_END)
71+ return " ←" ;
72+ if (f == WRITES_NEXT_START)
73+ return " →" ;
74+ if (f == UNKNOWN)
75+ return " ?" ;
76+ return " ↔" ;
77+ }
78+
5579void InitStageException::push_back (const Stage& stage, const std::string& msg) {
5680 errors_.emplace_back (std::make_pair (&stage, msg));
5781}
@@ -103,9 +127,9 @@ void StagePrivate::pruneInterface(InterfaceFlags accepted) {
103127 // only one side needs to be specified but the value has to be compatible with this stage
104128 if (((accepted_start != UNKNOWN) && (accepted_start & required_start) != required_start) ||
105129 ((accepted_end != UNKNOWN) && (accepted_end & required_end) != required_end)) {
106- boost::format desc (" this' interface %1%/ %2% cannot match inferred interface %3%/ %4%" );
107- desc % flowSymbol (required_start) % flowSymbol (required_end);
108- desc % flowSymbol (accepted_start) % flowSymbol (accepted_end);
130+ boost::format desc (" interface %1% %2% does not match inferred interface %3% %4%" );
131+ desc % flowSymbol<START_IF_MASK> (required_start) % flowSymbol<END_IF_MASK> (required_end);
132+ desc % flowSymbol<START_IF_MASK> (accepted_start) % flowSymbol<END_IF_MASK> (accepted_end);
109133 throw InitStageException (*me (), desc.str ());
110134 }
111135}
@@ -115,9 +139,9 @@ void StagePrivate::validateConnectivity() const {
115139 InterfaceFlags required = requiredInterface ();
116140 InterfaceFlags actual = interfaceFlags ();
117141 if ((required & actual) != required) {
118- boost::format desc (" interface %1%/ %2% does not satisfy required interface %3%/ %4%" );
119- desc % flowSymbol (actual & START_IF_MASK ) % flowSymbol (actual & END_IF_MASK );
120- desc % flowSymbol (required & START_IF_MASK ) % flowSymbol (required & END_IF_MASK );
142+ boost::format desc (" interface %1% %2% does not satisfy required interface %3% %4%" );
143+ desc % flowSymbol<START_IF_MASK> (actual) % flowSymbol<END_IF_MASK> (actual);
144+ desc % flowSymbol<START_IF_MASK> (required) % flowSymbol<END_IF_MASK> (required);
121145 throw InitStageException (*me (), desc.str ());
122146 }
123147}
@@ -362,43 +386,6 @@ void Stage::reportPropertyError(const Property::error& e) {
362386 throw std::runtime_error (oss.str ());
363387}
364388
365- template <InterfaceFlag own, InterfaceFlag other>
366- const char * direction (const StagePrivate& stage) {
367- InterfaceFlags f = stage.interfaceFlags ();
368-
369- bool own_if = f & own;
370- bool other_if = f & other;
371- bool reverse = own & START_IF_MASK;
372- if (own_if && other_if)
373- return " <>" ;
374- if (!own_if && !other_if)
375- return " --" ;
376- if (other_if ^ reverse)
377- return " ->" ;
378- return " <-" ;
379- }
380-
381- const char * flowSymbol (InterfaceFlags f) {
382- if (f == UNKNOWN)
383- return " ?" ; // unknown interface
384-
385- // f should have either INPUT or OUTPUT flags set (not both)
386- assert (static_cast <bool >(f & START_IF_MASK) ^ static_cast <bool >(f & END_IF_MASK));
387-
388- if (f & START_IF_MASK) {
389- if (f == READS_START)
390- return " ↓" ;
391- if (f == WRITES_PREV_END)
392- return " ↑" ;
393- } else if (f & END_IF_MASK) {
394- if (f == READS_END)
395- return " ↑" ;
396- if (f == WRITES_NEXT_START)
397- return " ↓" ;
398- }
399- return " ⇅" ;
400- }
401-
402389std::ostream& operator <<(std::ostream& os, const StagePrivate& impl) {
403390 // starts
404391 for (const InterfaceConstPtr& i : { impl.prevEnds (), impl.starts () }) {
@@ -409,8 +396,9 @@ std::ostream& operator<<(std::ostream& os, const StagePrivate& impl) {
409396 os << " -" ;
410397 }
411398 // trajectories
412- os << std::setw (5 ) << direction<READS_START, WRITES_PREV_END>(impl) << std::setw (3 ) << impl.solutions_ .size ()
413- << std::setw (5 ) << direction<READS_END, WRITES_NEXT_START>(impl);
399+ os << " " << flowSymbol<START_IF_MASK>(impl.interfaceFlags () | impl.requiredInterface ()) << " " ;
400+ os << std::setw (3 ) << impl.solutions_ .size ();
401+ os << " " << flowSymbol<END_IF_MASK>(impl.interfaceFlags () | impl.requiredInterface ()) << " " ;
414402 // ends
415403 for (const InterfaceConstPtr& i : { impl.ends (), impl.nextStarts () }) {
416404 os << std::setw (3 );
@@ -436,11 +424,11 @@ void PropagatingEitherWayPrivate::initInterface(PropagatingEitherWay::Direction
436424 auto flow = [](PropagatingEitherWay::Direction dir) -> const char * {
437425 switch (dir) {
438426 case PropagatingEitherWay::AUTO:
439- return flowSymbol (InterfaceFlags{ READS_START, WRITES_PREV_END });
427+ return flowSymbol<START_IF_MASK> (InterfaceFlags{ READS_START, WRITES_PREV_END });
440428 case PropagatingEitherWay::FORWARD:
441- return flowSymbol (InterfaceFlags{ READS_START });
429+ return flowSymbol<START_IF_MASK> (InterfaceFlags{ READS_START });
442430 case PropagatingEitherWay::BACKWARD:
443- return flowSymbol (InterfaceFlags{ WRITES_PREV_END });
431+ return flowSymbol<START_IF_MASK> (InterfaceFlags{ WRITES_PREV_END });
444432 }
445433 };
446434
@@ -459,14 +447,14 @@ void PropagatingEitherWayPrivate::initInterface(PropagatingEitherWay::Direction
459447
460448void PropagatingEitherWayPrivate::pruneInterface (InterfaceFlags accepted) {
461449 if (accepted == UNKNOWN)
462- throw InitStageException (*me (), std::string ( " cannot prune to " ) + flowSymbol (UNKNOWN) );
450+ throw InitStageException (*me (), " cannot prune to unknown interface " );
463451 if ((accepted & START_IF_MASK) == READS_START || (accepted & END_IF_MASK) == WRITES_NEXT_START)
464452 initInterface (PropagatingEitherWay::FORWARD);
465453 else if ((accepted & START_IF_MASK) == WRITES_PREV_END || (accepted & END_IF_MASK) == READS_END)
466454 initInterface (PropagatingEitherWay::BACKWARD);
467455 else {
468456 boost::format desc (" propagator cannot act with interfaces start(%1%), end(%2%)" );
469- desc % flowSymbol (accepted & START_IF_MASK ) % flowSymbol (accepted & END_IF_MASK );
457+ desc % flowSymbol<START_IF_MASK> (accepted) % flowSymbol<END_IF_MASK> (accepted);
470458 throw InitStageException (*me (), desc.str ());
471459 }
472460}
0 commit comments