diff --git a/core/include/moveit/task_constructor/container_p.h b/core/include/moveit/task_constructor/container_p.h index 3b58d0da..34f67eb4 100644 --- a/core/include/moveit/task_constructor/container_p.h +++ b/core/include/moveit/task_constructor/container_p.h @@ -227,10 +227,13 @@ public: protected: void validateInterfaces(const StagePrivate& child, InterfaceFlags& external, bool first = false) const; -private: /// callback for new externally received states template - void onNewExternalState(Interface::iterator external, bool updated); + void propagateStateToChildren(Interface::iterator external, bool updated); + +private: + // override for custom behavior on received interface states + virtual void initializeExternalInterfaces(InterfaceFlags expected); }; PIMPL_FUNCTIONS(ParallelContainerBase) diff --git a/core/src/container.cpp b/core/src/container.cpp index 3136dc01..34d04bd4 100644 --- a/core/src/container.cpp +++ b/core/src/container.cpp @@ -678,17 +678,21 @@ void ParallelContainerBasePrivate::resolveInterface(InterfaceFlags expected) { if (exceptions) throw exceptions; + initializeExternalInterfaces(expected); + + required_interface_ = expected; +} + +void ParallelContainerBasePrivate::initializeExternalInterfaces(InterfaceFlags expected) { // States received by the container need to be copied to all children's pull interfaces. if (expected & READS_START) starts().reset(new Interface([this](Interface::iterator external, bool updated) { - this->onNewExternalState(external, updated); + this->propagateStateToChildren(external, updated); })); if (expected & READS_END) ends().reset(new Interface([this](Interface::iterator external, bool updated) { - this->onNewExternalState(external, updated); + this->propagateStateToChildren(external, updated); })); - - required_interface_ = expected; } void ParallelContainerBasePrivate::validateInterfaces(const StagePrivate& child, InterfaceFlags& external, @@ -723,7 +727,7 @@ void ParallelContainerBasePrivate::validateConnectivity() const { } template -void ParallelContainerBasePrivate::onNewExternalState(Interface::iterator external, bool updated) { +void ParallelContainerBasePrivate::propagateStateToChildren(Interface::iterator external, bool updated) { for (const Stage::pointer& stage : children()) copyState(external, stage->pimpl()->pullInterface(dir), updated); }