@@ -861,25 +861,8 @@ void Fallbacks::init(const moveit::core::RobotModelConstPtr& robot_model) {
861861 pimpl ()->reset ();
862862}
863863
864- bool Fallbacks::canCompute () const {
865- auto impl = const_cast <FallbacksPrivate*>(pimpl ());
866-
867- while (impl->current_ != impl->children ().end () && // not completely exhausted
868- !(*impl->current_ )->pimpl ()->canCompute ()) // but current child cannot compute
869- return impl->nextJob (); // advance to next job
870-
871- // return value: current child is well defined and thus can compute?
872- return impl->current_ != impl->children ().end ();
873- }
874-
875- void Fallbacks::compute () {
876- (*pimpl ()->current_ )->pimpl ()->runCompute ();
877- }
878-
879864void Fallbacks::onNewSolution (const SolutionBase& s) {
880- pimpl ()->job_has_solutions_ = true ;
881- // printChildrenInterfaces(*this->pimpl(), true, *s.creator());
882- liftSolution (s);
865+ pimpl ()->onNewSolution (s);
883866}
884867
885868inline void Fallbacks::replaceImpl () {
@@ -909,17 +892,17 @@ FallbacksPrivate::FallbacksPrivate(FallbacksPrivate&& other)
909892 this ->ParallelContainerBasePrivate ::operator =(std::move (other));
910893}
911894
912- void FallbacksPrivate::reset () {
913- current_ = children ().begin ();
914- job_has_solutions_ = false ;
915- }
916-
917895void FallbacksPrivate::initializeExternalInterfaces () {
918896 // Here we know the final interface of the container (and all its children)
919897 // Thus replace, this pimpl() with a new interface-specific one:
920898 static_cast <Fallbacks*>(me ())->replaceImpl ();
921899}
922900
901+ void FallbacksPrivate::onNewSolution (const SolutionBase& s) {
902+ // printChildrenInterfaces(*this, true, *s.creator());
903+ static_cast <Fallbacks*>(me ())->liftSolution (s);
904+ }
905+
923906void FallbacksPrivate::onNewFailure (const Stage& child, const InterfaceState* /* from*/ , const InterfaceState* /* to*/ ) {
924907 // This override is deliberately empty.
925908 // The method prunes solution paths when a child failed to find a valid solution for it,
@@ -929,20 +912,37 @@ void FallbacksPrivate::onNewFailure(const Stage& child, const InterfaceState* /*
929912 (void )child;
930913}
931914
932- void FallbacksPrivate::nextChild () {
915+ void FallbacksPrivateCommon::reset () {
916+ current_ = children ().begin ();
917+ }
918+
919+ bool FallbacksPrivateCommon::canCompute () const {
920+ while (current_ != children ().end () && // not completely exhausted
921+ !(*current_)->pimpl ()->canCompute ()) // but current child cannot compute
922+ return const_cast <FallbacksPrivateCommon*>(this )->nextJob (); // advance to next job
923+
924+ // return value: current child is well defined and thus can compute?
925+ return current_ != children ().end ();
926+ }
927+
928+ void FallbacksPrivateCommon::compute () {
929+ (*current_)->pimpl ()->runCompute ();
930+ }
931+
932+ inline void FallbacksPrivateCommon::nextChild () {
933933 if (std::next (current_) != children ().end ())
934934 ROS_DEBUG_STREAM_NAMED (" Fallbacks" , " Child '" << (*current_)->name () << " ' failed, trying next one." );
935935 ++current_; // advance to next child
936936}
937937
938938FallbacksPrivateGenerator::FallbacksPrivateGenerator (FallbacksPrivate&& old)
939- : FallbacksPrivate (std::move(old)) { reset (); }
939+ : FallbacksPrivateCommon (std::move(old)) { FallbacksPrivateCommon:: reset (); }
940940
941941bool FallbacksPrivateGenerator::nextJob () {
942942 assert (current_ != children ().end () && !(*current_)->pimpl ()->canCompute ());
943943
944944 // don't advance to next child when we already produced solutions
945- if (job_has_solutions_ ) {
945+ if (!solutions_. empty () ) {
946946 current_ = children ().end (); // indicate that we are exhausted
947947 return false ;
948948 }
@@ -956,7 +956,7 @@ bool FallbacksPrivateGenerator::nextJob() {
956956
957957
958958FallbacksPrivatePropagator::FallbacksPrivatePropagator (FallbacksPrivate&& old)
959- : FallbacksPrivate (std::move(old)) {
959+ : FallbacksPrivateCommon (std::move(old)) {
960960 switch (requiredInterface ()) {
961961 case PROPAGATE_FORWARDS:
962962 dir_ = Interface::FORWARD;
@@ -973,8 +973,14 @@ FallbacksPrivatePropagator::FallbacksPrivatePropagator(FallbacksPrivate&& old)
973973}
974974
975975void FallbacksPrivatePropagator::reset () {
976- FallbacksPrivate ::reset ();
976+ FallbacksPrivateCommon ::reset ();
977977 job_ = pullInterface (dir_)->end (); // indicate fresh start
978+ job_has_solutions_ = false ;
979+ }
980+
981+ void FallbacksPrivatePropagator::onNewSolution (const SolutionBase& s) {
982+ job_has_solutions_ = true ;
983+ FallbacksPrivateCommon::onNewSolution (s);
978984}
979985
980986bool FallbacksPrivatePropagator::nextJob () {
0 commit comments