From fdd5ff880b643a091f51ebafa09118382d91ebfd Mon Sep 17 00:00:00 2001 From: Robert Haschke Date: Sun, 21 Nov 2021 10:27:57 +0100 Subject: [PATCH] templatize: pullInterface(dir) -> pullInterface() Also remove unused pushInterface(dir) --- .../include/moveit/task_constructor/stage_p.h | 23 ++++++++++--------- core/src/container.cpp | 2 +- core/src/stage.cpp | 6 ++--- 3 files changed, 16 insertions(+), 15 deletions(-) diff --git a/core/include/moveit/task_constructor/stage_p.h b/core/include/moveit/task_constructor/stage_p.h index 1bdeb5ad..7e82f4c2 100644 --- a/core/include/moveit/task_constructor/stage_p.h +++ b/core/include/moveit/task_constructor/stage_p.h @@ -100,17 +100,9 @@ public: inline InterfaceConstPtr prevEnds() const { return prev_ends_.lock(); } inline InterfaceConstPtr nextStarts() const { return next_starts_.lock(); } - /// direction-based access to pull/push interfaces - inline InterfacePtr& pullInterface(Interface::Direction dir) { return dir == Interface::FORWARD ? starts_ : ends_; } - inline InterfacePtr pushInterface(Interface::Direction dir) { - return dir == Interface::FORWARD ? next_starts_.lock() : prev_ends_.lock(); - } - inline InterfaceConstPtr pullInterface(Interface::Direction dir) const { - return dir == Interface::FORWARD ? starts_ : ends_; - } - inline InterfaceConstPtr pushInterface(Interface::Direction dir) const { - return dir == Interface::FORWARD ? next_starts_.lock() : prev_ends_.lock(); - } + /// direction-based access to pull interface + template + inline InterfacePtr pullInterface(); /// set parent of stage /// enforce only one parent exists @@ -204,6 +196,15 @@ private: PIMPL_FUNCTIONS(Stage) std::ostream& operator<<(std::ostream& os, const StagePrivate& stage); +template <> +inline InterfacePtr StagePrivate::pullInterface() { + return starts_; +} +template <> +inline InterfacePtr StagePrivate::pullInterface() { + return ends_; +} + template <> inline void StagePrivate::send(const InterfaceState& start, InterfaceState&& end, const SolutionBasePtr& solution) { diff --git a/core/src/container.cpp b/core/src/container.cpp index 601244ba..429c59e9 100644 --- a/core/src/container.cpp +++ b/core/src/container.cpp @@ -715,7 +715,7 @@ void ParallelContainerBasePrivate::validateConnectivity() const { template void ParallelContainerBasePrivate::onNewExternalState(Interface::iterator external, bool updated) { for (const Stage::pointer& stage : children()) - copyState(external, stage->pimpl()->pullInterface(dir), updated); + copyState(external, stage->pimpl()->pullInterface(), updated); } ParallelContainerBase::ParallelContainerBase(ParallelContainerBasePrivate* impl) : ContainerBase(impl) {} diff --git a/core/src/stage.cpp b/core/src/stage.cpp index b63daf57..6a856cad 100644 --- a/core/src/stage.cpp +++ b/core/src/stage.cpp @@ -713,9 +713,9 @@ ConnectingPrivate::StatePair ConnectingPrivate::make_pair(In template void ConnectingPrivate::newState(Interface::iterator it, bool updated) { auto parent_pimpl = parent()->pimpl(); - Interface::DisableNotify disable_source_interface(*pullInterface(dir)); + Interface::DisableNotify disable_source_interface(*pullInterface()); if (updated) { - if (pullInterface(opposite())->notifyEnabled()) // suppress recursive loop + if (pullInterface()>()->notifyEnabled()) // suppress recursive loop { // If status has changed, propagate the update to the opposite side auto status = it->priority().status(); @@ -747,7 +747,7 @@ void ConnectingPrivate::newState(Interface::iterator it, bool updated) { pending.sort(); } else { // new state: insert all pairs with other interface assert(it->priority().enabled()); // new solutions are feasible, aren't they? - InterfacePtr other_interface = pullInterface(dir); + InterfacePtr other_interface = pullInterface(); bool have_enabled_opposites = false; for (Interface::iterator oit = other_interface->begin(), oend = other_interface->end(); oit != oend; ++oit) { if (!static_cast(me_)->compatible(*it, *oit))