DGtal  0.9.3beta
Public Types | Public Member Functions | Private Attributes
DGtal::functors::Composer< TFunctor1, TFunctor2, ReturnType > Class Template Reference

#include <DGtal/base/BasicFunctors.h>

Public Types

typedef ReturnType Value
 

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 285 of file BasicFunctors.h.

Member Typedef Documentation

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

Necessary for DistanceVisitor.

Definition at line 289 of file BasicFunctors.h.

Constructor & Destructor Documentation

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

Default constructor

Definition at line 294 of file BasicFunctors.h.

294 : myF1(NULL), myF2(NULL) {}
const TFunctor2 * myF2
const TFunctor1 * myF1
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 300 of file BasicFunctors.h.

300 : myF1(&aF1), myF2(&aF2) {}
const TFunctor2 * myF2
const TFunctor1 * myF1
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 305 of file BasicFunctors.h.

305 : myF1(other.myF1), myF2(other.myF2) {}
const TFunctor2 * myF2
const TFunctor1 * myF1

Member Function Documentation

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 336 of file BasicFunctors.h.

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

337  {
338  ASSERT( myF1 );
339  ASSERT( myF2 );
340  return myF2->operator()( myF1->operator()( aInput ) );
341  }
const TFunctor2 * myF2
const TFunctor1 * myF1
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 311 of file BasicFunctors.h.

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

312  {
313  if (this != &other)
314  {
315  myF1 = other.myF1;
316  myF2 = other.myF2;
317  }
318  return *this;
319  }
const TFunctor2 * myF2
const TFunctor1 * myF1

Field Documentation

template<typename TFunctor1, typename TFunctor2, typename ReturnType>
const TFunctor1* DGtal::functors::Composer< TFunctor1, TFunctor2, ReturnType >::myF1
private
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: