DGtal  0.9.4beta
Public Types | Public Member Functions | Private Member Functions | Private Attributes
DGtal::ConstRangeFromPointAdapter< TRange, TFunctor, TReturnType > Class Template Reference

#include <DGtal/base/ConstRangeFromPointAdapter.h>

Public Types

typedef TRange::Point Point
 
typedef ConstIteratorAdapter< typename TRange::ConstIterator, TFunctor, TReturnType > ConstIterator
 
typedef std::reverse_iterator< ConstIteratorConstReverseIterator
 

Public Member Functions

 ConstRangeFromPointAdapter (ConstAlias< TRange > aRange, ConstAlias< TFunctor > aFunctor)
 
 ConstRangeFromPointAdapter (const ConstRangeFromPointAdapter &other)
 
ConstRangeFromPointAdapteroperator= (const ConstRangeFromPointAdapter &other)
 
 ~ConstRangeFromPointAdapter ()
 
bool isValid () const
 
ConstIterator begin () const
 
ConstIterator begin (const Point &aPoint) const
 
ConstIterator end () const
 
ConstReverseIterator rbegin () const
 
ConstReverseIterator rbegin (const Point &aPoint) const
 
ConstReverseIterator rend () const
 

Private Member Functions

 BOOST_CONCEPT_ASSERT ((CConstBidirectionalRangeFromPoint< TRange >))
 

Private Attributes

const TRange * myRangePtr
 
const TFunctor * myFunctorPtr
 

Detailed Description

template<typename TRange, typename TFunctor, typename TReturnType>
class DGtal::ConstRangeFromPointAdapter< TRange, TFunctor, TReturnType >

Aim: model of CConstBidirectionalRangeFromPoint that adapts any bidirectional range and provides services to iterate over it (in a read-only manner).

Template Parameters
TRangea model of CConstBidirectionalRangeFromPoint

Moreover, the provided iterators are adapted with a functor f given at construction so that operator* calls f(*it), instead of calling directly operator* of the iterator it.

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

NB: the underlying range and functor are stored as aliasing pointers in order to avoid copies. As a consequence the pointed object must exist and must not be deleted during the use of any instance of this class.

See also
ConstIteratorAdapter BasicFunctors.h

Definition at line 86 of file ConstRangeFromPointAdapter.h.

Member Typedef Documentation

template<typename TRange , typename TFunctor , typename TReturnType >
typedef ConstIteratorAdapter<typename TRange::ConstIterator,TFunctor,TReturnType> DGtal::ConstRangeFromPointAdapter< TRange, TFunctor, TReturnType >::ConstIterator

Definition at line 95 of file ConstRangeFromPointAdapter.h.

template<typename TRange , typename TFunctor , typename TReturnType >
typedef std::reverse_iterator<ConstIterator> DGtal::ConstRangeFromPointAdapter< TRange, TFunctor, TReturnType >::ConstReverseIterator

Definition at line 96 of file ConstRangeFromPointAdapter.h.

template<typename TRange , typename TFunctor , typename TReturnType >
typedef TRange::Point DGtal::ConstRangeFromPointAdapter< TRange, TFunctor, TReturnType >::Point

Definition at line 94 of file ConstRangeFromPointAdapter.h.

Constructor & Destructor Documentation

template<typename TRange , typename TFunctor , typename TReturnType >
DGtal::ConstRangeFromPointAdapter< TRange, TFunctor, TReturnType >::ConstRangeFromPointAdapter ( ConstAlias< TRange >  aRange,
ConstAlias< TFunctor >  aFunctor 
)
inline

Standard constructor from one range and one functor.

Parameters
aRangethe range to adapt.
aFunctorfunctor used to adapt on-the-fly the elements of the range

Definition at line 106 of file ConstRangeFromPointAdapter.h.

template<typename TRange , typename TFunctor , typename TReturnType >
DGtal::ConstRangeFromPointAdapter< TRange, TFunctor, TReturnType >::ConstRangeFromPointAdapter ( const ConstRangeFromPointAdapter< TRange, TFunctor, TReturnType > &  other)
inline

Copy constructor.

Parameters
otherthe iterator to clone.

Definition at line 114 of file ConstRangeFromPointAdapter.h.

115  : myRangePtr(other.myRangePtr), myFunctorPtr(other.myFunctorPtr) {}
template<typename TRange , typename TFunctor , typename TReturnType >
DGtal::ConstRangeFromPointAdapter< TRange, TFunctor, TReturnType >::~ConstRangeFromPointAdapter ( )
inline

Destructor. Does nothing.

Definition at line 135 of file ConstRangeFromPointAdapter.h.

135 {}

Member Function Documentation

template<typename TRange , typename TFunctor , typename TReturnType >
ConstIterator DGtal::ConstRangeFromPointAdapter< TRange, TFunctor, TReturnType >::begin ( ) const
inline

Iterator service.

Returns
begin iterator

Definition at line 162 of file ConstRangeFromPointAdapter.h.

References DGtal::ConstRangeFromPointAdapter< TRange, TFunctor, TReturnType >::myFunctorPtr.

Referenced by DGtal::ConstRangeFromPointAdapter< TRange, TFunctor, TReturnType >::rend().

162  {
163  return ConstIterator( myRangePtr->begin(), *myFunctorPtr );
164  }
ConstIteratorAdapter< typename TRange::ConstIterator, TFunctor, TReturnType > ConstIterator
template<typename TRange , typename TFunctor , typename TReturnType >
ConstIterator DGtal::ConstRangeFromPointAdapter< TRange, TFunctor, TReturnType >::begin ( const Point aPoint) const
inline

Iterator service.

Returns
begin iterator from a point

Definition at line 170 of file ConstRangeFromPointAdapter.h.

References DGtal::ConstRangeFromPointAdapter< TRange, TFunctor, TReturnType >::myFunctorPtr.

170  {
171  return ConstIterator( myRangePtr->begin(aPoint), *myFunctorPtr );
172  }
ConstIteratorAdapter< typename TRange::ConstIterator, TFunctor, TReturnType > ConstIterator
template<typename TRange , typename TFunctor , typename TReturnType >
DGtal::ConstRangeFromPointAdapter< TRange, TFunctor, TReturnType >::BOOST_CONCEPT_ASSERT ( (CConstBidirectionalRangeFromPoint< TRange >)  )
private
template<typename TRange , typename TFunctor , typename TReturnType >
ConstIterator DGtal::ConstRangeFromPointAdapter< TRange, TFunctor, TReturnType >::end ( ) const
inline

Iterator service.

Returns
end iterator

Definition at line 178 of file ConstRangeFromPointAdapter.h.

References DGtal::ConstRangeFromPointAdapter< TRange, TFunctor, TReturnType >::myFunctorPtr.

Referenced by DGtal::ConstRangeFromPointAdapter< TRange, TFunctor, TReturnType >::rbegin().

178  {
179  return ConstIterator( myRangePtr->end(), *myFunctorPtr );
180  }
ConstIteratorAdapter< typename TRange::ConstIterator, TFunctor, TReturnType > ConstIterator
template<typename TRange , typename TFunctor , typename TReturnType >
bool DGtal::ConstRangeFromPointAdapter< TRange, TFunctor, TReturnType >::isValid ( ) const
inline

Checks the validity/consistency of the object.

Returns
'true' if the object is valid, 'false' otherwise.

Definition at line 141 of file ConstRangeFromPointAdapter.h.

141 { return true; }
template<typename TRange , typename TFunctor , typename TReturnType >
ConstRangeFromPointAdapter& DGtal::ConstRangeFromPointAdapter< TRange, TFunctor, TReturnType >::operator= ( const ConstRangeFromPointAdapter< TRange, TFunctor, TReturnType > &  other)
inline

Assignment.

Parameters
otherthe iterator to copy.
Returns
a reference on 'this'.

Definition at line 122 of file ConstRangeFromPointAdapter.h.

References DGtal::ConstRangeFromPointAdapter< TRange, TFunctor, TReturnType >::myFunctorPtr, and DGtal::ConstRangeFromPointAdapter< TRange, TFunctor, TReturnType >::myRangePtr.

123  {
124  if ( this != &other )
125  {
126  myRangePtr = other.myRangePtr;
127  myFunctorPtr = other.myFunctorPtr;
128  }
129  return *this;
130  }
template<typename TRange , typename TFunctor , typename TReturnType >
ConstReverseIterator DGtal::ConstRangeFromPointAdapter< TRange, TFunctor, TReturnType >::rbegin ( ) const
inline

Iterator service.

Returns
rbegin iterator

Definition at line 186 of file ConstRangeFromPointAdapter.h.

References DGtal::ConstRangeFromPointAdapter< TRange, TFunctor, TReturnType >::end().

186  {
187  return ConstReverseIterator(this->end());
188  }
std::reverse_iterator< ConstIterator > ConstReverseIterator
template<typename TRange , typename TFunctor , typename TReturnType >
ConstReverseIterator DGtal::ConstRangeFromPointAdapter< TRange, TFunctor, TReturnType >::rbegin ( const Point aPoint) const
inline

Iterator service.

Returns
rbegin iterator from a point

Definition at line 194 of file ConstRangeFromPointAdapter.h.

References DGtal::ConstRangeFromPointAdapter< TRange, TFunctor, TReturnType >::end(), and DGtal::ConstRangeFromPointAdapter< TRange, TFunctor, TReturnType >::myFunctorPtr.

194  {
195  ConstIterator it( myRangePtr->begin(aPoint), *myFunctorPtr );
196  if ( it != this->end() ) ++it;
197  return ConstReverseIterator( it );
198  }
std::reverse_iterator< ConstIterator > ConstReverseIterator
template<typename TRange , typename TFunctor , typename TReturnType >
ConstReverseIterator DGtal::ConstRangeFromPointAdapter< TRange, TFunctor, TReturnType >::rend ( ) const
inline

Iterator service.

Returns
rend iterator

Definition at line 204 of file ConstRangeFromPointAdapter.h.

References DGtal::ConstRangeFromPointAdapter< TRange, TFunctor, TReturnType >::begin().

204  {
205  return ConstReverseIterator(this->begin());
206  }
std::reverse_iterator< ConstIterator > ConstReverseIterator

Field Documentation

template<typename TRange , typename TFunctor , typename TReturnType >
const TFunctor* DGtal::ConstRangeFromPointAdapter< TRange, TFunctor, TReturnType >::myFunctorPtr
private
template<typename TRange , typename TFunctor , typename TReturnType >
const TRange* DGtal::ConstRangeFromPointAdapter< TRange, TFunctor, TReturnType >::myRangePtr
private

Aliasing pointer on the range

Definition at line 149 of file ConstRangeFromPointAdapter.h.

Referenced by DGtal::ConstRangeFromPointAdapter< TRange, TFunctor, TReturnType >::operator=().


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