DGtal 1.3.0
Loading...
Searching...
No Matches
ConstRangeFromPointAdapter.h
1
17#pragma once
18
34#if defined(ConstRangeFromPointAdapter_RECURSES)
35#error Recursive header files inclusion detected in ConstRangeFromPointAdapter.h
36#else // defined(ConstRangeFromPointAdapter_RECURSES)
38#define ConstRangeFromPointAdapter_RECURSES
39
40#if !defined ConstRangeFromPointAdapter_h
42#define ConstRangeFromPointAdapter_h
43
45// Inclusions
46#include "DGtal/base/ConstAlias.h"
47#include "DGtal/base/BasicFunctors.h"
48#include "DGtal/base/Circulator.h"
49#include "DGtal/base/CConstBidirectionalRangeFromPoint.h"
50#include "DGtal/base/ConstIteratorAdapter.h"
51#include "boost/concept_check.hpp"
53
54namespace DGtal
55{
56
57
59 // class ConstRangeFromPointAdapter
61
85 template <typename TRange, typename TFunctor, typename TReturnType>
87 {
88
89 BOOST_CONCEPT_ASSERT(( CConstBidirectionalRangeFromPoint<TRange> ));
90
91 // ------------------------- inner types --------------------------------
92 public:
93
94 typedef typename TRange::Point Point;
96 typedef std::reverse_iterator<ConstIterator> ConstReverseIterator;
97
98 // ------------------------- standard services --------------------------------
99
107 ConstAlias<TFunctor> aFunctor )
108 : myRangePtr(&aRange), myFunctorPtr(&aFunctor) {}
109
116
123 {
124 if ( this != &other )
125 {
126 myRangePtr = other.myRangePtr;
128 }
129 return *this;
130 }
131
136
141 bool isValid() const { return true; }
142
143
144 // ------------------------- private data --------------------------------
145 private:
149 const TRange* myRangePtr;
153 const TFunctor* myFunctorPtr;
154
155 // ------------------------- iterator services --------------------------------
156 public:
157
163 return ConstIterator( myRangePtr->begin(), *myFunctorPtr );
164 }
165
171 return ConstIterator( myRangePtr->begin(aPoint), *myFunctorPtr );
172 }
173
179 return ConstIterator( myRangePtr->end(), *myFunctorPtr );
180 }
181
187 return ConstReverseIterator(this->end());
188 }
189
194 ConstReverseIterator rbegin(const Point& aPoint) const {
196 if ( it != this->end() ) ++it;
197 return ConstReverseIterator( it );
198 }
199
205 return ConstReverseIterator(this->begin());
206 }
207
208
209 }; //end class ConstRangeFromPointAdapter
210
211} // namespace DGtal
212
214
215
216#endif // !defined ConstRangeFromPointAdapter_h
217
218#undef ConstRangeFromPointAdapter_RECURSES
219#endif // else defined(ConstRangeFromPointAdapter_RECURSES)
Aim: This class encapsulates its parameter class so that to indicate to the user that the object/poin...
Definition: ConstAlias.h:187
This class adapts any iterator so that operator* returns another element than the one pointed to by t...
Aim: model of CConstBidirectionalRangeFromPoint that adapts any bidirectional range and provides serv...
ConstRangeFromPointAdapter & operator=(const ConstRangeFromPointAdapter &other)
BOOST_CONCEPT_ASSERT((CConstBidirectionalRangeFromPoint< TRange >))
ConstIteratorAdapter< typename TRange::ConstIterator, TFunctor, TReturnType > ConstIterator
ConstIterator begin(const Point &aPoint) const
ConstRangeFromPointAdapter(const ConstRangeFromPointAdapter &other)
ConstReverseIterator rbegin(const Point &aPoint) const
ConstRangeFromPointAdapter(ConstAlias< TRange > aRange, ConstAlias< TFunctor > aFunctor)
std::reverse_iterator< ConstIterator > ConstReverseIterator
DGtal is the top-level namespace which contains all DGtal functions and types.
const Point aPoint(3, 4)