DGtal  0.6.devel
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
ConstIteratorAdapter.h
1 
17 #pragma once
18 
31 #if defined(ConstIteratorAdapter_RECURSES)
32 #error Recursive header files inclusion detected in ConstIteratorAdapter.h
33 #else // defined(ConstIteratorAdapter_RECURSES)
34 
35 #define ConstIteratorAdapter_RECURSES
36 
37 #if !defined ConstIteratorAdapter_h
38 
39 #define ConstIteratorAdapter_h
40 
42 // Inclusions
43 #include <iostream>
44 #include "DGtal/base/Common.h"
45 #include "DGtal/base/IteratorTraits.h"
46 #include <boost/iterator/iterator_adaptor.hpp>
47 #include <boost/utility.hpp>
49 
50 namespace DGtal
51 {
52 
54  // template class ConstIteratorAdapter
78  template <typename TIterator, typename TLightFunctor, typename TReturnType = typename TLightFunctor::Value >
80  : public boost::iterator_adaptor< ConstIteratorAdapter<TIterator,TLightFunctor,TReturnType>,
81  TIterator, TReturnType, boost::use_default, TReturnType >
82  {
83  typedef typename
84  boost::iterator_adaptor< ConstIteratorAdapter<TIterator,TLightFunctor,TReturnType>,
85  TIterator, TReturnType, boost::use_default, TReturnType >
87 
89 
90  public:
91 
93 
94 
99 
106  ConstIteratorAdapter(TIterator const& i, TLightFunctor f)
107  : Super(i), myF(f) { }
108 
114  template <
115  class OtherFunctor
116  , class OtherIterator
117  , class OtherReturnType>
120  )
121  : Super(other.base()), myF(other.functor())
122  {}
123 
129  TLightFunctor functor() const
130  { return myF; }
131 
132  private:
133 
140  typename Super::reference dereference() const
141  { return myF(*this->base()); }
142 
144  TLightFunctor myF;
145  };
146 
147 
148 } // namespace DGtal
149 
150 
152 // Includes inline functions.
153 //#include "DGtal/base/ConstIteratorAdapter.ih"
154 
155 // //
157 
158 #endif // !defined ConstIteratorAdapter_h
159 
160 #undef ConstIteratorAdapter_RECURSES
161 #endif // else defined(ConstIteratorAdapter_RECURSES)