Skip to content
GitLab
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
e24759e3
Commit
e24759e3
authored
Aug 29, 2016
by
Floris Berendsen
Browse files
ENH: added CanAcceptConnectionFrom
parent
33870b69
Changes
7
Hide whitespace changes
Inline
Side-by-side
Modules/Core/ComponentInterface/include/selxComponentBase.h
View file @
e24759e3
...
...
@@ -55,7 +55,7 @@ public:
typedef
std
::
map
<
std
::
string
,
std
::
string
>
InterfaceCriteriaType
;
enum
interfaceStatus
{
success
,
noaccepter
,
noprovider
};
enum
interfaceStatus
{
success
,
noaccepter
,
noprovider
,
multiple
};
virtual
interfaceStatus
AcceptConnectionFrom
(
const
char
*
,
ComponentBase
*
)
=
0
;
...
...
@@ -69,6 +69,7 @@ public:
virtual
bool
MeetsCriterion
(
const
CriterionType
&
criterion
)
=
0
;
virtual
interfaceStatus
CanAcceptConnectionFrom
(
ComponentBase
*
,
const
InterfaceCriteriaType
)
=
0
;
protected:
virtual
bool
HasAcceptingInterface
(
const
char
*
)
=
0
;
...
...
Modules/Core/ComponentInterface/include/selxComponentSelector.h
View file @
e24759e3
...
...
@@ -53,6 +53,7 @@ public:
typedef
ComponentBase
::
Pointer
ComponentBasePointer
;
typedef
ComponentBase
::
CriteriaType
CriteriaType
;
typedef
ComponentBase
::
CriterionType
CriterionType
;
typedef
ComponentBase
::
InterfaceCriteriaType
InterfaceCriteriaType
;
typedef
std
::
list
<
ComponentBasePointer
>
ComponentListType
;
typedef
ComponentListType
::
size_type
NumberOfComponentsType
;
...
...
@@ -64,6 +65,8 @@ public:
/** Check for multiple versus 1 or 0 components*/
bool
HasMultipleComponents
(
void
);
unsigned
int
CountCompatibleInterfaces
(
ComponentBasePointer
other
);
/** Return Component or Nullptr*/
ComponentBasePointer
GetComponent
(
void
);
...
...
Modules/Core/ComponentInterface/include/selxSuperElastixComponent.h
View file @
e24759e3
...
...
@@ -40,6 +40,8 @@ public:
// Connect tries to connect this accepting interface with all interfaces of the provider component.
int
Connect
(
ComponentBase
*
);
bool
CanAcceptConnectionFrom
(
ComponentBase
*
);
private:
bool
isSet
;
...
...
@@ -51,6 +53,7 @@ class Accepting
public:
static
unsigned
int
CountMeetsCriteria
(
const
ComponentBase
::
InterfaceCriteriaType
)
{
return
0
;
}
ComponentBase
::
interfaceStatus
ConnectFromImpl
(
const
char
*
,
ComponentBase
*
)
{
return
ComponentBase
::
interfaceStatus
::
noaccepter
;
}
//no interface called interfacename ;
ComponentBase
::
interfaceStatus
CanAcceptConnectionFrom
(
ComponentBase
*
other
,
const
ComponentBase
::
InterfaceCriteriaType
interfaceCriteria
)
{
return
ComponentBase
::
interfaceStatus
::
noaccepter
;
}
int
ConnectFromImpl
(
ComponentBase
*
)
{
return
0
;
}
//Empty RestInterfaces does 0 successful connects ;
protected:
...
...
@@ -64,7 +67,7 @@ class Accepting< FirstInterface, RestInterfaces ... > : public InterfaceAcceptor
public:
static
unsigned
int
CountMeetsCriteria
(
const
ComponentBase
::
InterfaceCriteriaType
);
ComponentBase
::
interfaceStatus
ConnectFromImpl
(
const
char
*
,
ComponentBase
*
);
ComponentBase
::
interfaceStatus
CanAcceptConnectionFrom
(
ComponentBase
*
other
,
const
ComponentBase
::
InterfaceCriteriaType
interfaceCriteria
);
int
ConnectFromImpl
(
ComponentBase
*
);
protected:
...
...
@@ -133,6 +136,7 @@ protected:
virtual
bool
HasProvidingInterface
(
const
char
*
);
//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);
...
...
Modules/Core/ComponentInterface/include/selxSuperElastixComponent.hxx
View file @
e24759e3
...
...
@@ -39,6 +39,13 @@ InterfaceAcceptor< InterfaceT >::Connect( ComponentBase * providerComponent )
return
1
;
}
template
<
class
InterfaceT
>
bool
InterfaceAcceptor
<
InterfaceT
>::
CanAcceptConnectionFrom
(
ComponentBase
*
providerComponent
)
{
InterfaceT
*
providerInterface
=
dynamic_cast
<
InterfaceT
*
>
(
providerComponent
);
return
bool
(
providerInterface
);
}
//////////////////////////////////////////////////////////////////////////
template
<
typename
AcceptingInterfaces
,
typename
ProvidingInterfaces
>
...
...
@@ -72,6 +79,13 @@ SuperElastixComponent< AcceptingInterfaces, ProvidingInterfaces >::HasProvidingI
return
ProvidingInterfaces
::
HasInterface
(
interfacename
);
}
template
<
typename
AcceptingInterfaces
,
typename
ProvidingInterfaces
>
ComponentBase
::
interfaceStatus
SuperElastixComponent
<
AcceptingInterfaces
,
ProvidingInterfaces
>
::
CanAcceptConnectionFrom
(
ComponentBase
*
other
,
const
InterfaceCriteriaType
interfaceCriteria
)
{
return
AcceptingInterfaces
::
CanAcceptConnectionFrom
(
other
,
interfaceCriteria
);
}
//////////////////////////////////////////////////////////////////////////
template
<
typename
FirstInterface
,
typename
...
RestInterfaces
>
...
...
@@ -127,6 +141,86 @@ Accepting< FirstInterface, RestInterfaces ... >::HasInterface( const char * inte
return
Accepting
<
RestInterfaces
...
>::
HasInterface
(
interfacename
);
}
template
<
typename
FirstInterface
,
typename
...
RestInterfaces
>
ComponentBase
::
interfaceStatus
Accepting
<
FirstInterface
,
RestInterfaces
...
>::
CanAcceptConnectionFrom
(
ComponentBase
*
other
,
const
ComponentBase
::
InterfaceCriteriaType
interfaceCriteria
)
{
ComponentBase
::
interfaceStatus
restInterfacesStatus
=
Accepting
<
RestInterfaces
...
>::
CanAcceptConnectionFrom
(
other
,
interfaceCriteria
);
// if multiple interfaces were a succes we do not have to check any further interfaces.
if
(
restInterfacesStatus
==
ComponentBase
::
interfaceStatus
::
multiple
)
{
return
ComponentBase
::
interfaceStatus
::
multiple
;
}
// if a previous interface was a success, we can have either succes or multiple (successes)
else
if
(
restInterfacesStatus
==
ComponentBase
::
interfaceStatus
::
success
)
{
unsigned
int
interfaceMeetsCriteria
=
Count
<
FirstInterface
>::
MeetsCriteria
(
interfaceCriteria
);
if
(
interfaceMeetsCriteria
==
0
)
// ComponentBase::interfaceStatus::noacceptor;
{
return
ComponentBase
::
interfaceStatus
::
success
;
}
else
{
InterfaceAcceptor
<
FirstInterface
>
*
acceptIF
=
(
this
);
if
(
acceptIF
->
CanAcceptConnectionFrom
(
other
))
{
return
ComponentBase
::
interfaceStatus
::
multiple
;
}
else
// ComponentBase::interfaceStatus::noprovider
{
return
ComponentBase
::
interfaceStatus
::
success
;
}
}
}
// if a previous interface was noprovider, we can have either succes or noprovider (we know that there was at least 1 acceptor)
else
if
(
restInterfacesStatus
==
ComponentBase
::
interfaceStatus
::
noprovider
)
{
unsigned
int
interfaceMeetsCriteria
=
Count
<
FirstInterface
>::
MeetsCriteria
(
interfaceCriteria
);
if
(
interfaceMeetsCriteria
==
0
)
// ComponentBase::interfaceStatus::noacceptor;
{
return
ComponentBase
::
interfaceStatus
::
noprovider
;
}
else
{
InterfaceAcceptor
<
FirstInterface
>
*
acceptIF
=
(
this
);
if
(
acceptIF
->
CanAcceptConnectionFrom
(
other
))
{
return
ComponentBase
::
interfaceStatus
::
success
;
}
else
// ComponentBase::interfaceStatus::noprovider
{
return
ComponentBase
::
interfaceStatus
::
noprovider
;
}
}
}
// if a previous interface was noacceptor, we can have noaccepter, succes or noprovider
else
if
(
restInterfacesStatus
==
ComponentBase
::
interfaceStatus
::
noaccepter
)
{
unsigned
int
interfaceMeetsCriteria
=
Count
<
FirstInterface
>::
MeetsCriteria
(
interfaceCriteria
);
if
(
interfaceMeetsCriteria
==
0
)
// ComponentBase::interfaceStatus::noacceptor;
{
return
ComponentBase
::
interfaceStatus
::
noaccepter
;
}
else
{
InterfaceAcceptor
<
FirstInterface
>
*
acceptIF
=
(
this
);
if
(
acceptIF
->
CanAcceptConnectionFrom
(
other
))
{
return
ComponentBase
::
interfaceStatus
::
success
;
}
else
// ComponentBase::interfaceStatus::noprovider
{
return
ComponentBase
::
interfaceStatus
::
noprovider
;
}
}
}
}
template
<
typename
FirstInterface
,
typename
...
RestInterfaces
>
bool
...
...
@@ -177,7 +271,6 @@ unsigned int Count<FirstInterface, RestInterfaces ...>::MeetsCriteria(const Comp
return
1
+
Count
<
RestInterfaces
...
>::
MeetsCriteria
(
interfaceCriteria
);
};
}
// end namespace selx
#endif // #define selxSuperElastixComponent_hxx
Modules/Core/ComponentInterface/src/selxComponentBase.cxx
View file @
e24759e3
...
...
@@ -58,4 +58,5 @@ ComponentBase::MeetsCriterionBase( const CriterionType & criterion )
// else pass criterion to derived Component
return
this
->
MeetsCriterion
(
criterion
);
}
}
// end namespace selx
Modules/Core/ComponentInterface/src/selxComponentSelector.cxx
View file @
e24759e3
...
...
@@ -54,6 +54,13 @@ ComponentSelector::AddCriterion( const CriterionType & criterion )
}
);
}
//Require CompatibleInterfaces
unsigned
int
ComponentSelector
::
CountCompatibleInterfaces
(
ComponentBasePointer
other
)
{
this
->
m_PossibleComponents
.
remove_if
([
&
](
ComponentBasePointer
component
){
return
!
component
->
CanAcceptConnectionFrom
(
other
);
});
}
ComponentSelector
::
ComponentBasePointer
ComponentSelector
::
GetComponent
()
...
...
Modules/Core/ComponentInterface/src/selxOverlord.cxx
View file @
e24759e3
...
...
@@ -26,10 +26,6 @@
namespace
selx
{
//todo remove
auto
&&
properties1
=
Properties
<
itkImageFixedInterface
<
3
,
float
>>::
Get
();
auto
&&
properties2
=
Properties
<
itkGaussianExponentialDiffeomorphicTransformParametersAdaptorsContainerInterface
<
double
,
2
>>::
Get
();
Overlord
::
Overlord
()
:
m_isConfigured
(
false
)
{
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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