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 ...@@ -114,7 +114,7 @@ bool
Accepting< FirstInterface, RestInterfaces ... >::AreAllAccepted() Accepting< FirstInterface, RestInterfaces ... >::AreAllAccepted()
{ {
InterfaceAcceptor< FirstInterface > * acceptIF = (this); InterfaceAcceptor< FirstInterface > * acceptIF = (this);
if (acceptIF->isSet == false) if (acceptIF->isSet() == false)
{ {
return false; return false;
} }
......
...@@ -66,6 +66,9 @@ public: ...@@ -66,6 +66,9 @@ public:
//virtual const std::map< std::string, std::string > TemplateProperties(); //TODO should be overridden //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; const std::string m_Name;
}; };
} // end namespace selx } // end namespace selx
......
...@@ -43,9 +43,12 @@ public: ...@@ -43,9 +43,12 @@ public:
bool CanAcceptConnectionFrom( ComponentBase::ConstPointer ); bool CanAcceptConnectionFrom( ComponentBase::ConstPointer );
bool isSet()
{
return m_isSet;
};
private: private:
bool m_isSet;
bool isSet;
}; };
} //end namespace selx } //end namespace selx
......
...@@ -35,7 +35,7 @@ InterfaceAcceptor< InterfaceT >::Connect( ComponentBase::Pointer providerCompone ...@@ -35,7 +35,7 @@ InterfaceAcceptor< InterfaceT >::Connect( ComponentBase::Pointer providerCompone
} }
// connect value interfaces // 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->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; return 1;
} }
......
...@@ -45,6 +45,8 @@ public: ...@@ -45,6 +45,8 @@ public:
virtual int AcceptConnectionFrom( ComponentBase::Pointer ); virtual int AcceptConnectionFrom( ComponentBase::Pointer );
virtual bool ConnectionsSatisfied() override;
protected: protected:
virtual InterfaceStatus CanAcceptConnectionFrom( ComponentBase::ConstPointer, const InterfaceCriteriaType interfaceCriteria ) override; virtual InterfaceStatus CanAcceptConnectionFrom( ComponentBase::ConstPointer, const InterfaceCriteriaType interfaceCriteria ) override;
......
...@@ -47,6 +47,16 @@ SuperElastixComponent< AcceptingInterfaces, ProvidingInterfaces > ...@@ -47,6 +47,16 @@ SuperElastixComponent< AcceptingInterfaces, ProvidingInterfaces >
{ {
return AcceptingInterfaces::CanAcceptConnectionFrom( other, interfaceCriteria ); 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 } // end namespace selx
#endif // #define selxSuperElastixComponent_hxx #endif // #define selxSuperElastixComponent_hxx
...@@ -31,7 +31,7 @@ ComponentBase::ComponentBase( const std::string & name ) : m_Name( name ) ...@@ -31,7 +31,7 @@ ComponentBase::ComponentBase( const std::string & name ) : m_Name( name )
{ {
} }
//const std::map< std::string, std::string > ComponentBase::TemplateProperties() //const std::map< std::string, std::string > ComponentBase::TemplateProperties()
// { return{}; } // { return{}; }
} // end namespace selx } // end namespace selx
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