DGtal  0.9.4beta
Public Types | Public Member Functions | Private Types | Private Member Functions | Private Attributes | Friends
DGtal::ConstIteratorAdapter< TIterator, TLightFunctor, TReturnType > Class Template Reference

#include <DGtal/base/ConstIteratorAdapter.h>

Inheritance diagram for DGtal::ConstIteratorAdapter< TIterator, TLightFunctor, TReturnType >:
[legend]
Collaboration diagram for DGtal::ConstIteratorAdapter< TIterator, TLightFunctor, TReturnType >:
[legend]

Public Types

typedef IteratorCirculatorTraits< TIterator >::Type Type
 

Public Member Functions

 ConstIteratorAdapter ()
 
 ConstIteratorAdapter (TIterator const &i, TLightFunctor f)
 
template<class OtherFunctor , class OtherIterator , class OtherReturnType >
 ConstIteratorAdapter (ConstIteratorAdapter< OtherFunctor, OtherIterator, OtherReturnType > const &other)
 
TLightFunctor functor () const
 

Private Types

typedef boost::iterator_adaptor< ConstIteratorAdapter< TIterator, TLightFunctor, TReturnType >, TIterator, TReturnType, boost::use_default, TReturnType > Super
 

Private Member Functions

Super::reference dereference () const
 

Private Attributes

TLightFunctor myF
 

Friends

class boost::iterator_core_access
 

Detailed Description

template<typename TIterator, typename TLightFunctor, typename TReturnType = typename TLightFunctor::Value>
class DGtal::ConstIteratorAdapter< TIterator, TLightFunctor, TReturnType >

This class adapts any iterator so that operator* returns another element than the one pointed to by the iterator.

Description of template class 'ConstIteratorAdapter'

Template Parameters
TIteratorthe type of the iterator to adapt.

To achieve this goal, the adapter is based on a functor f given at construction so that operator* calls f(*it), instead of calling directly operator* of the underlying iterator it.

Template Parameters
TLightFunctorthe type of functor that transforms the pointed element into another one (required to be light because the functor is passed by value)
TReturnTypethe type of the element returned by the underlying functor (if TLightFunctor has a nested type called 'Value', TReturnType is set to TLightFunctor::Value by default)

NB: from boost/iterator/transform_iterator.hpp

Definition at line 79 of file ConstIteratorAdapter.h.

Member Typedef Documentation

template<typename TIterator, typename TLightFunctor, typename TReturnType = typename TLightFunctor::Value>
typedef boost::iterator_adaptor< ConstIteratorAdapter<TIterator,TLightFunctor,TReturnType>, TIterator, TReturnType, boost::use_default, TReturnType > DGtal::ConstIteratorAdapter< TIterator, TLightFunctor, TReturnType >::Super
private

Definition at line 86 of file ConstIteratorAdapter.h.

template<typename TIterator, typename TLightFunctor, typename TReturnType = typename TLightFunctor::Value>
typedef IteratorCirculatorTraits<TIterator>::Type DGtal::ConstIteratorAdapter< TIterator, TLightFunctor, TReturnType >::Type

Definition at line 92 of file ConstIteratorAdapter.h.

Constructor & Destructor Documentation

template<typename TIterator, typename TLightFunctor, typename TReturnType = typename TLightFunctor::Value>
DGtal::ConstIteratorAdapter< TIterator, TLightFunctor, TReturnType >::ConstIteratorAdapter ( )
inline

Default constructor

Definition at line 98 of file ConstIteratorAdapter.h.

98 { }
template<typename TIterator, typename TLightFunctor, typename TReturnType = typename TLightFunctor::Value>
DGtal::ConstIteratorAdapter< TIterator, TLightFunctor, TReturnType >::ConstIteratorAdapter ( TIterator const &  i,
TLightFunctor  f 
)
inline

Constructor

Parameters
iany iterator
fany functor

Definition at line 106 of file ConstIteratorAdapter.h.

107  : Super(i), myF(f) { }
boost::iterator_adaptor< ConstIteratorAdapter< TIterator, TLightFunctor, TReturnType >, TIterator, TReturnType, boost::use_default, TReturnType > Super
template<typename TIterator, typename TLightFunctor, typename TReturnType = typename TLightFunctor::Value>
template<class OtherFunctor , class OtherIterator , class OtherReturnType >
DGtal::ConstIteratorAdapter< TIterator, TLightFunctor, TReturnType >::ConstIteratorAdapter ( ConstIteratorAdapter< OtherFunctor, OtherIterator, OtherReturnType > const &  other)
inline

Copy constructor

Parameters
otherthe object to copy

Definition at line 118 of file ConstIteratorAdapter.h.

121  : Super(other.base()), myF(other.functor())
122  {}
boost::iterator_adaptor< ConstIteratorAdapter< TIterator, TLightFunctor, TReturnType >, TIterator, TReturnType, boost::use_default, TReturnType > Super

Member Function Documentation

template<typename TIterator, typename TLightFunctor, typename TReturnType = typename TLightFunctor::Value>
Super::reference DGtal::ConstIteratorAdapter< TIterator, TLightFunctor, TReturnType >::dereference ( ) const
inlineprivate

Dereference function

Returns
the object returned by the functor from the element pointed by the underlying iterator

Definition at line 140 of file ConstIteratorAdapter.h.

References DGtal::ConstIteratorAdapter< TIterator, TLightFunctor, TReturnType >::myF.

141  { return myF(*this->base()); }
template<typename TIterator, typename TLightFunctor, typename TReturnType = typename TLightFunctor::Value>
TLightFunctor DGtal::ConstIteratorAdapter< TIterator, TLightFunctor, TReturnType >::functor ( ) const
inline

Accessor on the functor

Returns
a copy of myF

Definition at line 129 of file ConstIteratorAdapter.h.

References DGtal::ConstIteratorAdapter< TIterator, TLightFunctor, TReturnType >::myF.

130  { return myF; }

Friends And Related Function Documentation

template<typename TIterator, typename TLightFunctor, typename TReturnType = typename TLightFunctor::Value>
friend class boost::iterator_core_access
friend

Definition at line 88 of file ConstIteratorAdapter.h.

Field Documentation

template<typename TIterator, typename TLightFunctor, typename TReturnType = typename TLightFunctor::Value>
TLightFunctor DGtal::ConstIteratorAdapter< TIterator, TLightFunctor, TReturnType >::myF
private

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