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
942a2001
Commit
942a2001
authored
Aug 25, 2016
by
Floris Berendsen
Browse files
WIP: end of the day
parent
38fd0b1b
Changes
3
Hide whitespace changes
Inline
Side-by-side
Modules/Core/ComponentInterface/include/selxComponentBase.h
View file @
942a2001
...
@@ -53,6 +53,8 @@ public:
...
@@ -53,6 +53,8 @@ public:
typedef
std
::
map
<
ParameterKeyType
,
ParameterValueType
>
CriteriaType
;
typedef
std
::
map
<
ParameterKeyType
,
ParameterValueType
>
CriteriaType
;
typedef
std
::
pair
<
ParameterKeyType
,
ParameterValueType
>
CriterionType
;
typedef
std
::
pair
<
ParameterKeyType
,
ParameterValueType
>
CriterionType
;
typedef
std
::
map
<
std
::
string
,
std
::
string
>
InterfaceCriteriaType
;
enum
interfaceStatus
{
success
,
noaccepter
,
noprovider
};
enum
interfaceStatus
{
success
,
noaccepter
,
noprovider
};
virtual
interfaceStatus
AcceptConnectionFrom
(
const
char
*
,
ComponentBase
*
)
=
0
;
virtual
interfaceStatus
AcceptConnectionFrom
(
const
char
*
,
ComponentBase
*
)
=
0
;
...
@@ -73,6 +75,11 @@ protected:
...
@@ -73,6 +75,11 @@ protected:
virtual
bool
HasProvidingInterface
(
const
char
*
)
=
0
;
virtual
bool
HasProvidingInterface
(
const
char
*
)
=
0
;
//experimental:
virtual
unsigned
int
CountAcceptingInterfaces
(
const
InterfaceCriteriaType
)
=
0
;
virtual
unsigned
int
CountProvidingInterfaces
(
const
InterfaceCriteriaType
)
=
0
;
ComponentBase
()
{}
ComponentBase
()
{}
virtual
~
ComponentBase
()
{}
virtual
~
ComponentBase
()
{}
};
};
...
...
Modules/Core/ComponentInterface/include/selxSuperElastixComponent.h
View file @
942a2001
...
@@ -93,6 +93,20 @@ protected:
...
@@ -93,6 +93,20 @@ protected:
//{
//{
//};
//};
// helper class for SuperElastixComponent::CountAcceptingInterfaces and SuperElastixComponent::CountProvidingInterfaces to loop over a set of interfaces
template
<
typename
...
RestInterfaces
>
struct
CountInterfaces
{
static
unsigned
int
Count
(
const
ComponentBase
::
InterfaceCriteriaType
)
{
return
0
};
};
template
<
typename
FirstInterface
,
typename
...
RestInterfaces
>
struct
CountInterfaces
<
FirstInterface
,
RestInterfaces
...
>
{
static
unsigned
int
Count
(
const
ComponentBase
::
InterfaceCriteriaType
);
};
template
<
typename
AcceptingInterfaces
,
typename
ProvidingInterfaces
>
template
<
typename
AcceptingInterfaces
,
typename
ProvidingInterfaces
>
class
SuperElastixComponent
:
public
AcceptingInterfaces
,
public
ProvidingInterfaces
,
public
ComponentBase
class
SuperElastixComponent
:
public
AcceptingInterfaces
,
public
ProvidingInterfaces
,
public
ComponentBase
{
{
...
@@ -107,6 +121,11 @@ protected:
...
@@ -107,6 +121,11 @@ protected:
virtual
bool
HasAcceptingInterface
(
const
char
*
);
virtual
bool
HasAcceptingInterface
(
const
char
*
);
virtual
bool
HasProvidingInterface
(
const
char
*
);
virtual
bool
HasProvidingInterface
(
const
char
*
);
//experimental
virtual
unsigned
int
CountAcceptingInterfaces
(
const
ComponentBase
::
InterfaceCriteriaType
);
virtual
unsigned
int
CountProvidingInterfaces
(
const
ComponentBase
::
InterfaceCriteriaType
);
};
};
}
// end namespace selx
}
// end namespace selx
...
...
Modules/Core/ComponentInterface/include/selxSuperElastixComponent.hxx
View file @
942a2001
...
@@ -72,6 +72,23 @@ SuperElastixComponent< AcceptingInterfaces, ProvidingInterfaces >::HasProvidingI
...
@@ -72,6 +72,23 @@ SuperElastixComponent< AcceptingInterfaces, ProvidingInterfaces >::HasProvidingI
return
ProvidingInterfaces
::
HasInterface
(
interfacename
);
return
ProvidingInterfaces
::
HasInterface
(
interfacename
);
}
}
template
<
typename
AcceptingInterfaces
,
typename
ProvidingInterfaces
>
unsigned
int
SuperElastixComponent
<
AcceptingInterfaces
,
ProvidingInterfaces
>::
CountAcceptingInterfaces
(
const
ComponentBase
::
InterfaceCriteriaType
interfaceCriteria
)
{
//return AcceptingInterfaces::HasInterface(interfacename);
return
CountInterfaces
<
AcceptingInterfaces
>::
Count
(
interfaceCriteria
);
}
template
<
typename
AcceptingInterfaces
,
typename
ProvidingInterfaces
>
unsigned
int
SuperElastixComponent
<
AcceptingInterfaces
,
ProvidingInterfaces
>::
CountProvidingInterfaces
(
const
ComponentBase
::
InterfaceCriteriaType
interfaceCriteria
)
{
//return ProvidingInterfaces::HasInterface(interfacename);
return
CountInterfaces
<
ProvidingInterfaces
>::
Count
(
interfaceCriteria
);
}
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
template
<
typename
FirstInterface
,
typename
...
RestInterfaces
>
template
<
typename
FirstInterface
,
typename
...
RestInterfaces
>
...
@@ -118,7 +135,9 @@ bool
...
@@ -118,7 +135,9 @@ bool
Accepting
<
FirstInterface
,
RestInterfaces
...
>::
HasInterface
(
const
char
*
interfacename
)
Accepting
<
FirstInterface
,
RestInterfaces
...
>::
HasInterface
(
const
char
*
interfacename
)
{
{
//TODO: check on interface template arguments as well
//TODO: check on interface template arguments as well
if
(
InterfaceName
<
InterfaceAcceptor
<
FirstInterface
>>::
Get
()
==
std
::
string
(
interfacename
)
)
auto
interfaceProperies
=
Properties
<
FirstInterface
>::
Get
();
if
(
interfaceProperies
[
"Name"
]
==
std
::
string
(
interfacename
))
{
{
return
true
;
return
true
;
}
}
...
@@ -131,12 +150,34 @@ bool
...
@@ -131,12 +150,34 @@ bool
Providing
<
FirstInterface
,
RestInterfaces
...
>::
HasInterface
(
const
char
*
interfacename
)
Providing
<
FirstInterface
,
RestInterfaces
...
>::
HasInterface
(
const
char
*
interfacename
)
{
{
//TODO: check on interface template arguments as well
//TODO: check on interface template arguments as well
if
(
InterfaceName
<
FirstInterface
>::
Get
()
==
std
::
string
(
interfacename
)
)
auto
interfaceProperies
=
Properties
<
FirstInterface
>::
Get
();
if
(
interfaceProperies
[
"Name"
]
==
std
::
string
(
interfacename
))
{
{
return
true
;
return
true
;
}
}
return
Providing
<
RestInterfaces
...
>::
HasInterface
(
interfacename
);
return
Providing
<
RestInterfaces
...
>::
HasInterface
(
interfacename
);
}
}
template
<
typename
FirstInterface
,
typename
...
RestInterfaces
>
unsigned
int
CountInterfaces
<
FirstInterface
,
RestInterfaces
...
>::
Count
(
const
ComponentBase
::
InterfaceCriteriaType
interfaceCriteria
)
{
auto
interfaceProperies
=
Properties
<
FirstInterface
>::
Get
();
for
(
const
auto
keyAndValue
:
interfaceCriteria
)
{
auto
&&
key
=
keyAndValue
.
first
;
auto
&&
value
=
keyAndValue
.
second
;
if
(
interfaceProperies
.
count
(
key
)
!=
1
||
interfaceProperies
[
key
].
compare
(
value
)
!=
0
)
{
// as soon as any of the criteria fails we break the loop and test the RestInterfaces
return
CountInterfaces
<
RestInterfaces
...
>::
Count
(
interfaceCriteria
);
}
}
// if all criteria are met for this Interface we add 1 to the count and continue with the RestInterfaces
return
1
+
CountInterfaces
<
RestInterfaces
...
>::
Count
(
interfaceCriteria
);
};
}
// end namespace selx
}
// end namespace selx
#endif // #define selxSuperElastixComponent_hxx
#endif // #define selxSuperElastixComponent_hxx
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