Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Mirrors
SuperElastix
Commits
ca8c616b
Commit
ca8c616b
authored
Jan 23, 2018
by
Floris Berendsen
Browse files
DOC: added comments on dynamic_casts
parent
bff5fdec
Changes
2
Hide whitespace changes
Inline
Side-by-side
Modules/Blueprints/src/selxBlueprintImpl.cxx
View file @
ca8c616b
...
...
@@ -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
)
...
...
Modules/Core/include/selxInterfaceAcceptor.hxx
View file @
ca8c616b
...
...
@@ -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 "
);
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment