DGtal
1.5.beta
|
Aim: hold any object callable on points as a DGtal::concepts::CPointFunctor model. More...
#include <DGtal/kernel/PointFunctorHolder.h>
Public Types | |
using | Self = PointFunctorHolder< TPoint, TValue, TFunctor > |
using | Point = TPoint |
using | Value = TValue |
using | Functor = TFunctor |
Public Member Functions | |
template<typename Function , typename std::enable_if<!std::is_base_of< PointFunctorHolder, typename std::decay< Function >::type >::value, int >::type = 0> | |
PointFunctorHolder (Function &&fn) | |
Constructor. More... | |
Value | operator() (Point const &aPoint) const |
Evaluates the functor at the given point. More... | |
void | selfDisplay (std::ostream &out) const |
Writes/Displays the object on an output stream. More... | |
constexpr bool | isValid () const |
Checks the validity/consistency of the object. More... | |
Private Attributes | |
Functor | myFunctor |
The held functor. More... | |
Aim: hold any object callable on points as a DGtal::concepts::CPointFunctor model.
TPoint | Point type. |
TValue | Value type returned by the functor. |
TFunctor | Type of the functor. |
The functor must accept a point and return a value whose type is Value.
A typical usage would be:
In you want to use a function instead of a functor or lambda, consider wrapping it into a lambda to avoid a performance penalty due to the fact that a pointer to a function cannot be inlined:
You can find more informations about how to use this class appropriately in the module about Using functions, functors and lambdas in DGtal.
Definition at line 95 of file PointFunctorHolder.h.
using DGtal::functors::PointFunctorHolder< TPoint, TValue, TFunctor >::Functor = TFunctor |
Definition at line 104 of file PointFunctorHolder.h.
using DGtal::functors::PointFunctorHolder< TPoint, TValue, TFunctor >::Point = TPoint |
Definition at line 102 of file PointFunctorHolder.h.
using DGtal::functors::PointFunctorHolder< TPoint, TValue, TFunctor >::Self = PointFunctorHolder<TPoint, TValue, TFunctor> |
Definition at line 101 of file PointFunctorHolder.h.
using DGtal::functors::PointFunctorHolder< TPoint, TValue, TFunctor >::Value = TValue |
Definition at line 103 of file PointFunctorHolder.h.
|
inlineexplicit |
Constructor.
Function | The type of the callable object (auto-deduced). |
fn | The callable object. |
Definition at line 119 of file PointFunctorHolder.h.
|
inlineconstexpr |
Checks the validity/consistency of the object.
Definition at line 152 of file PointFunctorHolder.h.
|
inline |
Evaluates the functor at the given point.
aPoint | The point. |
Definition at line 132 of file PointFunctorHolder.h.
References aPoint(), and DGtal::functors::PointFunctorHolder< TPoint, TValue, TFunctor >::myFunctor.
|
inline |
Writes/Displays the object on an output stream.
out | the output stream where the object is written. |
Definition at line 142 of file PointFunctorHolder.h.
References DGtal::functors::PointFunctorHolder< TPoint, TValue, TFunctor >::myFunctor.
|
private |
The held functor.
Definition at line 160 of file PointFunctorHolder.h.
Referenced by DGtal::functors::PointFunctorHolder< TPoint, TValue, TFunctor >::operator()(), and DGtal::functors::PointFunctorHolder< TPoint, TValue, TFunctor >::selfDisplay().