DGtal 1.3.0
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Private Attributes
DGtal::functors::Composer< TFunctor1, TFunctor2, ReturnType > Class Template Reference

Aim: Define a new Functor from the composition of two other functors. More...

#include <DGtal/base/BasicFunctors.h>

Public Types

typedef ReturnType Value
 Necessary for DistanceVisitor. More...
 

Public Member Functions

 Composer ()
 
 Composer (const TFunctor1 &aF1, const TFunctor2 &aF2)
 
 Composer (const Composer &other)
 
Composeroperator= (const Composer &other)
 
template<typename TInput >
ReturnType operator() (const TInput &aInput) const
 

Private Attributes

const TFunctor1 * myF1
 
const TFunctor2 * myF2
 

Detailed Description

template<typename TFunctor1, typename TFunctor2, typename ReturnType>
class DGtal::functors::Composer< TFunctor1, TFunctor2, ReturnType >

Aim: Define a new Functor from the composition of two other functors.

Description of template class 'Composer'

Template Parameters
TFunctor1first functor
TFunctor2second functor
ReturnTypereturn type
Examples
graph/volDistanceTraversal.cpp.

Definition at line 417 of file BasicFunctors.h.

Member Typedef Documentation

◆ Value

template<typename TFunctor1 , typename TFunctor2 , typename ReturnType >
typedef ReturnType DGtal::functors::Composer< TFunctor1, TFunctor2, ReturnType >::Value

Necessary for DistanceVisitor.

Definition at line 421 of file BasicFunctors.h.

Constructor & Destructor Documentation

◆ Composer() [1/3]

template<typename TFunctor1 , typename TFunctor2 , typename ReturnType >
DGtal::functors::Composer< TFunctor1, TFunctor2, ReturnType >::Composer ( )
inline

Default constructor

Definition at line 426 of file BasicFunctors.h.

426: myF1(NULL), myF2(NULL) {}
const TFunctor2 * myF2
const TFunctor1 * myF1

◆ Composer() [2/3]

template<typename TFunctor1 , typename TFunctor2 , typename ReturnType >
DGtal::functors::Composer< TFunctor1, TFunctor2, ReturnType >::Composer ( const TFunctor1 &  aF1,
const TFunctor2 &  aF2 
)
inline

Constructor

Parameters
aF1any Functor
aF2any Functor

Definition at line 432 of file BasicFunctors.h.

432: myF1(&aF1), myF2(&aF2) {}

◆ Composer() [3/3]

template<typename TFunctor1 , typename TFunctor2 , typename ReturnType >
DGtal::functors::Composer< TFunctor1, TFunctor2, ReturnType >::Composer ( const Composer< TFunctor1, TFunctor2, ReturnType > &  other)
inline

Copy Operator

Parameters
otherobject to copy

Definition at line 437 of file BasicFunctors.h.

437: myF1(other.myF1), myF2(other.myF2) {}

Member Function Documentation

◆ operator()()

template<typename TFunctor1 , typename TFunctor2 , typename ReturnType >
template<typename TInput >
ReturnType DGtal::functors::Composer< TFunctor1, TFunctor2, ReturnType >::operator() ( const TInput &  aInput) const
inline

Operator ()

NB: myF2 return type should be equal to (or implicitly castable into) ReturnType

Returns
object of type ReturnType coming from the composition myF1 o myF2 on aInput, ie. myF2 ( myF1 ( aInput ) )
Template Parameters
TInputtype of the input value

Definition at line 468 of file BasicFunctors.h.

469 {
470 ASSERT( myF1 );
471 ASSERT( myF2 );
472 return myF2->operator()( myF1->operator()( aInput ) );
473 }

References DGtal::functors::Composer< TFunctor1, TFunctor2, ReturnType >::myF1, and DGtal::functors::Composer< TFunctor1, TFunctor2, ReturnType >::myF2.

◆ operator=()

template<typename TFunctor1 , typename TFunctor2 , typename ReturnType >
Composer & DGtal::functors::Composer< TFunctor1, TFunctor2, ReturnType >::operator= ( const Composer< TFunctor1, TFunctor2, ReturnType > &  other)
inline

Assignement Operator

Parameters
otherobject to copy

Definition at line 443 of file BasicFunctors.h.

444 {
445 if (this != &other)
446 {
447 myF1 = other.myF1;
448 myF2 = other.myF2;
449 }
450 return *this;
451 }

References DGtal::functors::Composer< TFunctor1, TFunctor2, ReturnType >::myF1, and DGtal::functors::Composer< TFunctor1, TFunctor2, ReturnType >::myF2.

Field Documentation

◆ myF1

template<typename TFunctor1 , typename TFunctor2 , typename ReturnType >
const TFunctor1* DGtal::functors::Composer< TFunctor1, TFunctor2, ReturnType >::myF1
private

◆ myF2

template<typename TFunctor1 , typename TFunctor2 , typename ReturnType >
const TFunctor2* DGtal::functors::Composer< TFunctor1, TFunctor2, ReturnType >::myF2
private

The documentation for this class was generated from the following file: