Commit 43f742f9 authored by Floris Berendsen's avatar Floris Berendsen
Browse files

ENH: added the base class method ConnectionsSatisfied with a default

implementation. SuperElastix/SuperElastix#32
parent 3948e358
......@@ -114,7 +114,7 @@ bool
Accepting< FirstInterface, RestInterfaces ... >::AreAllAccepted()
{
InterfaceAcceptor< FirstInterface > * acceptIF = (this);
if (acceptIF->isSet == false)
if (acceptIF->isSet() == false)
{
return false;
}
......
......@@ -66,6 +66,9 @@ public:
//virtual const std::map< std::string, std::string > TemplateProperties(); //TODO should be overridden
// Each component is checked if its required connections are made after all handshakes.
// SuperElastixComponent provides a default implementation which may be overridden by the component developer
virtual bool ConnectionsSatisfied() = 0 ;
const std::string m_Name;
};
} // end namespace selx
......
......@@ -43,9 +43,12 @@ public:
bool CanAcceptConnectionFrom( ComponentBase::ConstPointer );
bool isSet()
{
return m_isSet;
};
private:
bool isSet;
bool m_isSet;
};
} //end namespace selx
......
......@@ -35,7 +35,7 @@ InterfaceAcceptor< InterfaceT >::Connect( ComponentBase::Pointer providerCompone
}
// connect value interfaces
this->Set( providerInterface ); // due to the input argument being uniquely defined in the multiple inheritance tree, all versions of Set() are accessible at component level
this->isSet = true;
this->m_isSet = true;
return 1;
}
......
......@@ -45,6 +45,8 @@ public:
virtual int AcceptConnectionFrom( ComponentBase::Pointer );
virtual bool ConnectionsSatisfied() override;
protected:
virtual InterfaceStatus CanAcceptConnectionFrom( ComponentBase::ConstPointer, const InterfaceCriteriaType interfaceCriteria ) override;
......
......@@ -47,6 +47,16 @@ SuperElastixComponent< AcceptingInterfaces, ProvidingInterfaces >
{
return AcceptingInterfaces::CanAcceptConnectionFrom( other, interfaceCriteria );
}
template< typename AcceptingInterfaces, typename ProvidingInterfaces >
bool
SuperElastixComponent< AcceptingInterfaces, ProvidingInterfaces >
::ConnectionsSatisfied()
{
// Default implementation. Components that allow unused connections should override this function.
return AcceptingInterfaces::AreAllAccepted();
}
} // end namespace selx
#endif // #define selxSuperElastixComponent_hxx
......@@ -31,7 +31,7 @@ ComponentBase::ComponentBase( const std::string & name ) : m_Name( name )
{
}
//const std::map< std::string, std::string > ComponentBase::TemplateProperties()
// { return{}; }
} // end namespace selx
Markdown is supported
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