Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
otb
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Julien Cabieces
otb
Commits
60968460
Commit
60968460
authored
6 years ago
by
Julien Michel
Browse files
Options
Downloads
Patches
Plain Diff
TEST: Add more testing cases, and support non const operators
parent
490d8c35
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Modules/Core/Functor/include/otbFunctorImageFilter.hxx
+2
-2
2 additions, 2 deletions
Modules/Core/Functor/include/otbFunctorImageFilter.hxx
Modules/Core/Functor/test/otbFunctorImageFilter.cxx
+27
-2
27 additions, 2 deletions
Modules/Core/Functor/test/otbFunctorImageFilter.cxx
with
29 additions
and
4 deletions
Modules/Core/Functor/include/otbFunctorImageFilter.hxx
+
2
−
2
View file @
60968460
...
...
@@ -139,13 +139,13 @@ template <typename T> struct GetProxy<itk::ConstNeighborhoodIterator<T> >
};
// Will be easier to write in c++17 with std::apply and fold expressions
template
<
class
Tuple
,
class
Oper
,
size_t
...
Is
>
auto
CallOperatorImpl
(
Tuple
&
t
,
const
Oper
&
oper
,
std
::
index_sequence
<
Is
...
>
)
template
<
class
Tuple
,
class
Oper
,
size_t
...
Is
>
auto
CallOperatorImpl
(
Tuple
&
t
,
Oper
&
oper
,
std
::
index_sequence
<
Is
...
>
)
{
return
oper
(
GetProxy
<
typename
std
::
remove_reference
<
decltype
(
std
::
get
<
Is
>
(
t
))
>::
type
>::
Get
(
std
::
get
<
Is
>
(
t
))...);
}
// Will be easier to write in c++17 with std::apply and fold expressions
template
<
class
Oper
,
typename
...
Args
>
auto
CallOperator
(
const
Oper
&
oper
,
std
::
tuple
<
Args
...
>
&
t
)
template
<
class
Oper
,
typename
...
Args
>
auto
CallOperator
(
Oper
&
oper
,
std
::
tuple
<
Args
...
>
&
t
)
{
return
CallOperatorImpl
(
t
,
oper
,
std
::
make_index_sequence
<
sizeof
...(
Args
)
>
{});
}
...
...
This diff is collapsed.
Click to expand it.
Modules/Core/Functor/test/otbFunctorImageFilter.cxx
+
27
−
2
View file @
60968460
...
...
@@ -90,6 +90,21 @@ template <typename T> struct TypesCheck
}
};
// Fake test operator non const
template
<
typename
TOut
,
typename
TIn
>
struct
TestOperatorNonConst
{
auto
operator
()(
const
TIn
&
)
{
TOut
res
(
OutputSize
());
return
res
;
}
constexpr
size_t
OutputSize
(...)
const
{
return
1
;
}
};
template
<
typename
TOut
,
typename
TIn
>
void
TestFilter
()
{
...
...
@@ -109,16 +124,22 @@ template <typename T> struct TypesCheck
// Build and run filter
auto
functor
=
TestOperator
<
TOut
,
TIn
>
{};
auto
filter
=
NewFunctorFilter
(
functor
);
using
FilterType
=
typename
decltype
(
filter
)
::
ObjectType
;
static_assert
(
FilterType
::
NumberOfInputs
==
1
,
""
);
static_assert
(
std
::
is_same
<
typename
FilterType
::
template
InputImageType
<
0
>,
InputImageType
>::
value
,
""
);
filter
->
SetVariadicInputs
(
in
);
filter
->
SetInput1
(
in
);
filter
->
template
SetVariadicInput
<
0
>(
in
);
// template keyword to avoid C++ parse ambiguity
filter
->
Update
();
// Test with non const operator
auto
functorNonConstOperator
=
TestOperatorNonConst
<
TOut
,
TIn
>
{};
auto
filterWithNonConstOperator
=
NewFunctorFilter
(
functorNonConstOperator
);
filterWithNonConstOperator
->
SetInput1
(
in
);
filterWithNonConstOperator
->
Update
();
// Test with simple lambda
auto
lambda
=
[]
(
const
TIn
&
)
{
...
...
@@ -128,6 +149,10 @@ template <typename T> struct TypesCheck
auto
filterWithLambda
=
NewFunctorFilter
(
lambda
,
1
,
{{
0
,
0
}});
filterWithLambda
->
SetVariadicInputs
(
in
);
filterWithLambda
->
Update
();
// Test with standard filter use
using
FullFilterType
=
otb
::
FunctorImageFilter
<
TestOperator
<
TOut
,
TIn
>>
;
auto
filter2
=
FullFilterType
::
New
();
}
TypesCheck
()
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment