Commit ca8c616b authored by Floris Berendsen's avatar Floris Berendsen

DOC: added comments on dynamic_casts

parent bff5fdec
......@@ -388,6 +388,7 @@ BlueprintImpl
ComponentNamesType container;
std::vector< ComponentIndexType > indexContainer;
boost::topological_sort(this->m_Graph, std::back_inserter(indexContainer));
for (std::vector< ComponentIndexType >::reverse_iterator ii = indexContainer.rbegin(); ii != indexContainer.rend(); ++ii)
......
......@@ -44,16 +44,23 @@ InterfaceAcceptor< InterfaceT >::Connect( ComponentBase::Pointer providerCompone
// store the interface for access by the user defined component
this->m_AcceptedInterface = providerInterface;
// TODO: see if we can get rid of all (dynamic) casts below.
// TODO: see if we can get rid of all (dynamic) casts below. Perhaps a "static_cast in release mode"?
auto providerConnectionInfo = std::dynamic_pointer_cast<ConnectionInfo< InterfaceT >>( providerComponent);
if (!providerConnectionInfo) // by definition should not fail
if (!providerConnectionInfo)
{
// By definition should not fail, since providerComponent always is a base
// class pointer of an SuperElastixComponent object and
// SuperElastixComponents that are derived from InterfaceT (checked
// previously) also derive from ConnectionInfo< InterfaceT>
throw std::runtime_error( "std::dynamic_pointer_cast<ConnectionInfo< InterfaceT > should not fail by definition " );
}
ComponentBase* AcceptorBaseComponent = dynamic_cast<ComponentBase*>( this );
if (!AcceptorBaseComponent) // by definition should not fail
if (!AcceptorBaseComponent)
{
// By definition should not fail, since 'this', the AcceptorInterface, and
// ComponentBase are both base classes from the SuperElastixComponent
// object on which this functionality is called.
throw std::runtime_error("dynamic_cast<ComponentBase*> should not fail by definition ");
}
......
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