DGtal 2.1.0
Loading...
Searching...
No Matches
DGtal::ConstRangeFromPointAdapter< TRange, TFunctor, TReturnType > Class Template Reference

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

#include <DGtal/base/ConstRangeFromPointAdapter.h>

Public Types

typedef TRange::Point Point
 
typedef ConstIteratorAdapter< typename TRange::ConstIterator, TFunctor, TReturnType > ConstIterator
 
typedef boost::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 87 of file ConstRangeFromPointAdapter.h.

Member Typedef Documentation

◆ ConstIterator

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

Definition at line 96 of file ConstRangeFromPointAdapter.h.

◆ ConstReverseIterator

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

Definition at line 97 of file ConstRangeFromPointAdapter.h.

◆ Point

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

Definition at line 95 of file ConstRangeFromPointAdapter.h.

Constructor & Destructor Documentation

◆ ConstRangeFromPointAdapter() [1/2]

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 107 of file ConstRangeFromPointAdapter.h.

◆ ConstRangeFromPointAdapter() [2/2]

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 115 of file ConstRangeFromPointAdapter.h.

116 : myRangePtr(other.myRangePtr), myFunctorPtr(other.myFunctorPtr) {}

◆ ~ConstRangeFromPointAdapter()

template<typename TRange , typename TFunctor , typename TReturnType >
DGtal::ConstRangeFromPointAdapter< TRange, TFunctor, TReturnType >::~ConstRangeFromPointAdapter ( )
inline

Destructor. Does nothing.

Definition at line 136 of file ConstRangeFromPointAdapter.h.

136{}

Member Function Documentation

◆ begin() [1/2]

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

◆ begin() [2/2]

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 171 of file ConstRangeFromPointAdapter.h.

171 {
172 return ConstIterator( myRangePtr->begin(aPoint), *myFunctorPtr );
173 }
const Point aPoint(3, 4)

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

◆ BOOST_CONCEPT_ASSERT()

template<typename TRange , typename TFunctor , typename TReturnType >
DGtal::ConstRangeFromPointAdapter< TRange, TFunctor, TReturnType >::BOOST_CONCEPT_ASSERT ( (CConstBidirectionalRangeFromPoint< TRange >)  )
private

◆ end()

◆ isValid()

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 142 of file ConstRangeFromPointAdapter.h.

142{ return true; }

◆ operator=()

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 123 of file ConstRangeFromPointAdapter.h.

124 {
125 if ( this != &other )
126 {
127 myRangePtr = other.myRangePtr;
128 myFunctorPtr = other.myFunctorPtr;
129 }
130 return *this;
131 }

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

◆ rbegin() [1/2]

template<typename TRange , typename TFunctor , typename TReturnType >
ConstReverseIterator DGtal::ConstRangeFromPointAdapter< TRange, TFunctor, TReturnType >::rbegin ( ) const
inline

Iterator service.

Returns
rbegin iterator

Definition at line 187 of file ConstRangeFromPointAdapter.h.

187 {
188 return ConstReverseIterator(this->end());
189 }
boost::reverse_iterator< ConstIterator > ConstReverseIterator

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

◆ rbegin() [2/2]

template<typename TRange , typename TFunctor , typename TReturnType >
ConstReverseIterator DGtal::ConstRangeFromPointAdapter< TRange, TFunctor, TReturnType >::rbegin ( const Point aPoint) const
inline

◆ rend()

template<typename TRange , typename TFunctor , typename TReturnType >
ConstReverseIterator DGtal::ConstRangeFromPointAdapter< TRange, TFunctor, TReturnType >::rend ( ) const
inline

Iterator service.

Returns
rend iterator

Definition at line 205 of file ConstRangeFromPointAdapter.h.

205 {
206 return ConstReverseIterator(this->begin());
207 }

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

Field Documentation

◆ myFunctorPtr

◆ myRangePtr


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