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
decf08db
Commit
decf08db
authored
6 years ago
by
Julien Michel
Browse files
Options
Downloads
Patches
Plain Diff
ENH: Replace DefaultConstructibleFunctorImageFilter by a SFINAE enabled New() method
parent
879d0a78
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Modules/Core/Functor/include/otbFunctorImageFilter.h
+12
-38
12 additions, 38 deletions
Modules/Core/Functor/include/otbFunctorImageFilter.h
Modules/Core/Functor/test/otbFunctorImageFilter.cxx
+2
-3
2 additions, 3 deletions
Modules/Core/Functor/test/otbFunctorImageFilter.cxx
with
14 additions
and
41 deletions
Modules/Core/Functor/include/otbFunctorImageFilter.h
+
12
−
38
View file @
decf08db
...
...
@@ -298,6 +298,18 @@ public:
/** Run-time type information (and related methods). */
itkTypeMacro
(
FunctorImageFilter
,
VariadicInputsImageFilter
);
/** New() macro defined only if TFunction is default constructible */
template
<
typename
F
=
TFunction
>
static
std
::
enable_if_t
<
std
::
is_default_constructible
<
F
>::
value
,
Pointer
>
New
()
{
// Explicit default construct
FunctorType
f
;
// Create a filter out of it
Pointer
p
=
new
Self
(
f
,
{{
0
,
0
}});
p
->
UnRegister
();
return
p
;
}
/** Get the functor object.
*
...
...
@@ -417,44 +429,6 @@ template <typename Functor, typename TNameMap = void> auto NewFunctorFilter(Func
return
NewFunctorFilter
<
FunctorType
,
TNameMap
>
(
decoratedF
,
radius
);
}
/**
* \class DefaultConstructibleFunctorImageFilter
* \brief Adds New() to FunctorImageFilter
*
* FunctorImageFilter is not default constructible (to support lambda
* as template parameter), and thus does not offer the New() static method.
*
* This class provides explicit default construction and New() static
* method when it is required to stick with the ITK/OTB workflow of
* default construction. It can not be used with lamda as TFunction.
*
* \sa FunctorImageFilter
* \ingroup OTBFunctor
*/
template
<
class
TFunction
,
class
TNameMap
=
void
>
class
ITK_EXPORT
DefaultConstructibleFunctorImageFilter
:
public
FunctorImageFilter
<
TFunction
,
TNameMap
>
{
public:
// Standard typedefs
using
Self
=
DefaultConstructibleFunctorImageFilter
;
using
FunctorType
=
TFunction
;
using
Pointer
=
itk
::
SmartPointer
<
Self
>
;
using
ConstPointer
=
itk
::
SmartPointer
<
const
Self
>
;
// Superclass through the helper struct
using
Superclass
=
FunctorImageFilter
<
TFunction
,
TNameMap
>
;
using
OutputImageType
=
typename
Superclass
::
OutputImageType
;
itkNewMacro
(
Self
);
itkTypeMacro
(
DefaultConstructibleFunctorImageFilter
,
FunctorImageFilter
);
protected:
DefaultConstructibleFunctorImageFilter
()
:
Superclass
(
TFunction
{},
{{
0
,
0
}}){};
DefaultConstructibleFunctorImageFilter
(
const
Self
&
)
=
delete
;
void
operator
=
(
const
Self
&
)
=
delete
;
~
DefaultConstructibleFunctorImageFilter
()
=
default
;
};
}
// namespace otb
#ifndef OTB_MANUAL_INSTANTIATION
...
...
This diff is collapsed.
Click to expand it.
Modules/Core/Functor/test/otbFunctorImageFilter.cxx
+
2
−
3
View file @
decf08db
...
...
@@ -162,9 +162,8 @@ template <typename TOut,typename TIn> struct TestOperatorVoidReturn
res
=
filter1
->
GetVariadicNamedInput
(
tag
{});
filter1
->
Update
();
// Test default constructible version
using
DefaultConstructibleFilterType
=
DefaultConstructibleFunctorImageFilter
<
decltype
(
functor
)
>
;
auto
oldStyleNewFilter
=
DefaultConstructibleFilterType
::
New
();
// Test static New() operator
auto
oldStyleNewFilter
=
FunctorImageFilter
<
decltype
(
functor
)
>::
New
();
oldStyleNewFilter
->
SetVariadicInputs
(
in
);
oldStyleNewFilter
->
Update
();
...
...
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