From 6ab8d83b6b42270006009e7d83f605ef4b89e560 Mon Sep 17 00:00:00 2001 From: Floris Berendsen <floris.berendsen@gmail.com> Date: Tue, 22 Dec 2015 12:55:43 +0100 Subject: [PATCH] ENH: Overlord::ConnectComponents() --- .../ComponentInterface/include/Overlord.h | 2 +- .../Core/ComponentInterface/src/Overlord.cxx | 32 ++++++++++++++++++- 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/Modules/Core/ComponentInterface/include/Overlord.h b/Modules/Core/ComponentInterface/include/Overlord.h index 6c14dc28..b720df97 100644 --- a/Modules/Core/ComponentInterface/include/Overlord.h +++ b/Modules/Core/ComponentInterface/include/Overlord.h @@ -45,7 +45,7 @@ namespace selx void ApplyNodeConfiguration(); void ApplyConnectionConfiguration(); bool UpdateSelectors(); - + bool ConnectComponents(); Blueprint::Pointer m_Blueprint; ComponentSelectorContainerType m_ComponentSelectorContainer; }; diff --git a/Modules/Core/ComponentInterface/src/Overlord.cxx b/Modules/Core/ComponentInterface/src/Overlord.cxx index 79daef79..a463c5f7 100644 --- a/Modules/Core/ComponentInterface/src/Overlord.cxx +++ b/Modules/Core/ComponentInterface/src/Overlord.cxx @@ -38,6 +38,7 @@ namespace selx bool Overlord::Configure() { + bool isSuccess(false); bool allUniqueComponents; this->ApplyNodeConfiguration(); allUniqueComponents = this->UpdateSelectors(); @@ -46,7 +47,13 @@ namespace selx this->ApplyConnectionConfiguration(); allUniqueComponents = this->UpdateSelectors(); std::cout << "By adding Connection Criteria unique components could " << (allUniqueComponents ? "" : "not ") << "be selected" << std::endl; - return allUniqueComponents; + + if (allUniqueComponents) + { + isSuccess = this->ConnectComponents(); + } + + return isSuccess; } void Overlord::ApplyNodeConfiguration() { @@ -113,5 +120,28 @@ namespace selx return; } + bool Overlord::ConnectComponents() + { + + //TODO: redesign loops, see ApplyConnectionConfiguration() + Blueprint::ComponentIndexType index; + for (index = 0; index < this->m_ComponentSelectorContainer.size(); ++index) + { + Blueprint::OutputIteratorPairType ouputItPair = this->m_Blueprint->GetOutputIterator(index); + Blueprint::OutputIteratorPairType::first_type ouputIt; + Blueprint::OutputIteratorPairType::second_type ouputItEnd = ouputItPair.second; + for (ouputIt = ouputItPair.first; ouputIt != ouputItEnd; ++ouputIt) + { + //TODO check direction upstream/downstream input/output source/target + //TODO GetComponent returns NULL if possible components !=1 we can check for that, but Overlord::UpdateSelectors() does something similar. + ComponentBase::Pointer sourceComponent = this->m_ComponentSelectorContainer[ouputIt->m_source]->GetComponent(); + ComponentBase::Pointer targetComponent = this->m_ComponentSelectorContainer[ouputIt->m_target]->GetComponent(); + targetComponent->ConnectFrom(sourceComponent); + } + } + //TODO should we communicate by exceptions instead of returning booleans? + return true; + } + } // end namespace selx -- GitLab