Commit 3adf358b authored by Floris Berendsen's avatar Floris Berendsen
Browse files

ENH: CountAcceptingInterfaces

parent e24759e3
......@@ -77,9 +77,9 @@ protected:
virtual bool HasProvidingInterface( const char * ) = 0;
//experimental:
//virtual unsigned int CountAcceptingInterfaces(const InterfaceCriteriaType) = 0;
virtual unsigned int CountAcceptingInterfaces(const InterfaceCriteriaType) = 0;
//virtual unsigned int CountProvidingInterfaces(const InterfaceCriteriaType) = 0;
virtual unsigned int CountProvidingInterfaces(const InterfaceCriteriaType) = 0;
ComponentBase() {}
virtual ~ComponentBase() {}
......
......@@ -62,6 +62,9 @@ public:
/** Narrow selection criteria*/
void AddCriterion( const CriterionType & criterion );
void AddAcceptingInterfaceCriteria(const InterfaceCriteriaType & interfaceCriteria);
void AddProvidingInterfaceCriteria(const InterfaceCriteriaType & interfaceCriteria);
/** Check for multiple versus 1 or 0 components*/
bool HasMultipleComponents( void );
......
......@@ -137,9 +137,9 @@ protected:
//experimental
virtual interfaceStatus CanAcceptConnectionFrom(ComponentBase* other, const InterfaceCriteriaType interfaceCriteria) override;
//SuperElastixComponentType::AcceptingInterfacesTypeList::CountMeetsCriteria(InterfaceCriteriaType);
//virtual unsigned int CountAcceptingInterfaces(const ComponentBase::InterfaceCriteriaType);
//virtual unsigned int CountProvidingInterfaces(const ComponentBase::InterfaceCriteriaType);
//
virtual unsigned int CountAcceptingInterfaces(const ComponentBase::InterfaceCriteriaType interfaceCriteria){ return AcceptingInterfaces::CountMeetsCriteria(interfaceCriteria); };
virtual unsigned int CountProvidingInterfaces(const ComponentBase::InterfaceCriteriaType interfaceCriteria){ return ProvidingInterfaces::CountMeetsCriteria(interfaceCriteria); };
};
} // end namespace selx
......
......@@ -54,6 +54,22 @@ ComponentSelector::AddCriterion( const CriterionType & criterion )
} );
}
void
ComponentSelector::AddAcceptingInterfaceCriteria(const InterfaceCriteriaType & interfaceCriteria)
{
this->m_PossibleComponents.remove_if([&](ComponentBasePointer component){
return 0==component->CountAcceptingInterfaces(interfaceCriteria);
});
}
void
ComponentSelector::AddProvidingInterfaceCriteria(const InterfaceCriteriaType & interfaceCriteria)
{
this->m_PossibleComponents.remove_if([&](ComponentBasePointer component){
return 0 == component->CountProvidingInterfaces(interfaceCriteria);
});
}
//Require CompatibleInterfaces
unsigned int ComponentSelector::CountCompatibleInterfaces(ComponentBasePointer other)
{
......
......@@ -161,6 +161,13 @@ Overlord::ApplyConnectionConfiguration()
{
//TODO check direction upstream/downstream input/output source/target
Blueprint::ParameterMapType connectionProperties = this->m_Blueprint->GetConnection( name, outgoingName );
//TODO
ComponentBase::InterfaceCriteriaType interfaceCriteria;
std::for_each(connectionProperties.begin(), connectionProperties.end(), [interfaceCriteria](Blueprint::ParameterMapType::value_type kv) mutable { interfaceCriteria[kv.first] = kv.second[0]; });
this->m_ComponentSelectorContainer[name]->AddProvidingInterfaceCriteria(interfaceCriteria);
if( connectionProperties.count( "NameOfInterface" ) > 0 )
{
this->m_ComponentSelectorContainer[ name ]->AddCriterion( { keys::HasProvidingInterface, connectionProperties[ keys::NameOfInterface ] } );
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment