DGtal  0.9.3beta
Public Types | Public Member Functions | Private Member Functions
DGtal::IteratorAdapter< TIterator, TFunctor, TReturnType > Class Template Reference

#include <DGtal/base/IteratorAdapter.h>

Inheritance diagram for DGtal::IteratorAdapter< TIterator, TFunctor, TReturnType >:
[legend]
Collaboration diagram for DGtal::IteratorAdapter< TIterator, TFunctor, TReturnType >:
[legend]

Public Types

typedef IteratorAdapter< TIterator, TFunctor, TReturnType > Self
 
typedef boost::transform_iterator< TFunctor, TIterator, TReturnType &, TReturnType > Parent
 

Public Member Functions

 IteratorAdapter ()
 
 IteratorAdapter (const TIterator &iter, TFunctor func)
 
 IteratorAdapter (const Self &other)
 
 IteratorAdapter (const Parent &other)
 
Selfoperator= (const Self &other)
 
Selfoperator= (const Parent &other)
 
 ~IteratorAdapter ()
 

Private Member Functions

 BOOST_CONCEPT_ASSERT ((boost_concepts::LvalueIteratorConcept< TIterator >))
 

Detailed Description

template<typename TIterator, typename TFunctor, typename TReturnType = typename TFunctor::Value>
class DGtal::IteratorAdapter< TIterator, TFunctor, TReturnType >

This class adapts any lvalue iterator so that operator* returns a member on the element pointed to by the iterator, instead the element itself.

Description of template class 'IteratorAdapter'

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. This operation returns a reference (or constant reference) on a member of the element pointed to by the iterator, which can be read as well as assigned (if the member is not constant).

Template Parameters
TFunctorthe type of functor that transforms the pointed element into another one
TReturnTypethe type of the element returned by the underlying functor

Definition at line 76 of file IteratorAdapter.h.

Member Typedef Documentation

template<typename TIterator , typename TFunctor , typename TReturnType = typename TFunctor::Value>
typedef boost::transform_iterator< TFunctor, TIterator, TReturnType&, TReturnType > DGtal::IteratorAdapter< TIterator, TFunctor, TReturnType >::Parent

parent class

Definition at line 87 of file IteratorAdapter.h.

template<typename TIterator , typename TFunctor , typename TReturnType = typename TFunctor::Value>
typedef IteratorAdapter< TIterator, TFunctor, TReturnType > DGtal::IteratorAdapter< TIterator, TFunctor, TReturnType >::Self

this class

Definition at line 85 of file IteratorAdapter.h.

Constructor & Destructor Documentation

template<typename TIterator , typename TFunctor , typename TReturnType = typename TFunctor::Value>
DGtal::IteratorAdapter< TIterator, TFunctor, TReturnType >::IteratorAdapter ( )
inline

Default constructor

Definition at line 92 of file IteratorAdapter.h.

92 : Parent() {}
boost::transform_iterator< TFunctor, TIterator, TReturnType &, TReturnType > Parent
template<typename TIterator , typename TFunctor , typename TReturnType = typename TFunctor::Value>
DGtal::IteratorAdapter< TIterator, TFunctor, TReturnType >::IteratorAdapter ( const TIterator &  iter,
TFunctor  func 
)
inline

Constructor from an iterator and a functor

Parameters
iterany iterator
funcany functor

Definition at line 99 of file IteratorAdapter.h.

99 : Parent(iter,func) {}
boost::transform_iterator< TFunctor, TIterator, TReturnType &, TReturnType > Parent
template<typename TIterator , typename TFunctor , typename TReturnType = typename TFunctor::Value>
DGtal::IteratorAdapter< TIterator, TFunctor, TReturnType >::IteratorAdapter ( const Self other)
inline

Copy operator

Parameters
otherthe object of type Self to copy.

Definition at line 105 of file IteratorAdapter.h.

105 : Parent( static_cast<const Parent&>(other) ) {}
boost::transform_iterator< TFunctor, TIterator, TReturnType &, TReturnType > Parent
template<typename TIterator , typename TFunctor , typename TReturnType = typename TFunctor::Value>
DGtal::IteratorAdapter< TIterator, TFunctor, TReturnType >::IteratorAdapter ( const Parent other)
inline

Copy operator

Parameters
otherthe object of type Parent to copy.

Definition at line 111 of file IteratorAdapter.h.

111 : Parent(other) {}
boost::transform_iterator< TFunctor, TIterator, TReturnType &, TReturnType > Parent
template<typename TIterator , typename TFunctor , typename TReturnType = typename TFunctor::Value>
DGtal::IteratorAdapter< TIterator, TFunctor, TReturnType >::~IteratorAdapter ( )
inline

Destructor.

Definition at line 140 of file IteratorAdapter.h.

140 {}

Member Function Documentation

template<typename TIterator , typename TFunctor , typename TReturnType = typename TFunctor::Value>
DGtal::IteratorAdapter< TIterator, TFunctor, TReturnType >::BOOST_CONCEPT_ASSERT ( (boost_concepts::LvalueIteratorConcept< TIterator >)  )
private
template<typename TIterator , typename TFunctor , typename TReturnType = typename TFunctor::Value>
Self& DGtal::IteratorAdapter< TIterator, TFunctor, TReturnType >::operator= ( const Self other)
inline

Assignement operator

Parameters
otherthe object of type Self to copy.
Returns
this

Definition at line 118 of file IteratorAdapter.h.

119  {
120  if (this != &other)
121  Parent::operator=( static_cast<const Parent&>(other) );
122  return *this;
123  }
template<typename TIterator , typename TFunctor , typename TReturnType = typename TFunctor::Value>
Self& DGtal::IteratorAdapter< TIterator, TFunctor, TReturnType >::operator= ( const Parent other)
inline

Assignement operator

Parameters
otherthe object of type Parent to copy.
Returns
this

Definition at line 130 of file IteratorAdapter.h.

131  {
132  if (this != &other)
133  Parent::operator=(other);
134  return *this;
135  }

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