templatize: pullInterface(dir) -> pullInterface<dir>()

Also remove unused pushInterface(dir)
This commit is contained in:
Robert Haschke 2021-11-21 10:27:57 +01:00
parent a31e52dd53
commit fdd5ff880b
3 changed files with 16 additions and 15 deletions

View File

@ -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 <Interface::Direction dir>
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<Interface::FORWARD>() {
return starts_;
}
template <>
inline InterfacePtr StagePrivate::pullInterface<Interface::BACKWARD>() {
return ends_;
}
template <>
inline void StagePrivate::send<Interface::FORWARD>(const InterfaceState& start, InterfaceState&& end,
const SolutionBasePtr& solution) {

View File

@ -715,7 +715,7 @@ void ParallelContainerBasePrivate::validateConnectivity() const {
template <Interface::Direction dir>
void ParallelContainerBasePrivate::onNewExternalState(Interface::iterator external, bool updated) {
for (const Stage::pointer& stage : children())
copyState<dir>(external, stage->pimpl()->pullInterface(dir), updated);
copyState<dir>(external, stage->pimpl()->pullInterface<dir>(), updated);
}
ParallelContainerBase::ParallelContainerBase(ParallelContainerBasePrivate* impl) : ContainerBase(impl) {}

View File

@ -713,9 +713,9 @@ ConnectingPrivate::StatePair ConnectingPrivate::make_pair<Interface::FORWARD>(In
template <Interface::Direction dir>
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<dir>());
if (updated) {
if (pullInterface(opposite<dir>())->notifyEnabled()) // suppress recursive loop
if (pullInterface<opposite<dir>()>()->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<dir>();
bool have_enabled_opposites = false;
for (Interface::iterator oit = other_interface->begin(), oend = other_interface->end(); oit != oend; ++oit) {
if (!static_cast<Connecting*>(me_)->compatible(*it, *oit))