DGtal  1.5.beta
OutputIteratorAdapter.h
1 
17 #pragma once
18 
31 #if defined(OutputIteratorAdapter_RECURSES)
32 #error Recursive header files inclusion detected in OutputIteratorAdapter.h
33 #else // defined(OutputIteratorAdapter_RECURSES)
35 #define OutputIteratorAdapter_RECURSES
36 
37 #if !defined OutputIteratorAdapter_h
39 #define OutputIteratorAdapter_h
40 
42 // Inclusions
43 #include "DGtal/base/Common.h"
44 #include "DGtal/base/ConstAlias.h"
45 #include "DGtal/base/BasicFunctors.h"
46 #include "DGtal/base/CUnaryFunctor.h"
47 #include "DGtal/base/Circulator.h"
48 
49 #include <iostream>
50 
52 
53 namespace DGtal
54 {
55 
57  // template class OutputIteratorAdapter
74  template <typename TIterator, typename TFunctor, typename TInputValue>
76  {
77  // ----------------------- Types definitions ------------------------------
78 
79  public:
80 
81  using iterator_category = std::output_iterator_tag;
82  using value_type = void;
83  using difference_type = void;
84  using pointer = void;
85  using reference = void;
86 
87 
88 
89  typedef TIterator Iterator;
92  typename std::iterator_traits<Iterator>::value_type&, TInputValue& > ));
93 
94  // ----------------------- Standard services ------------------------------
95  public:
102  : myIt(it), myF(&f) {}
103 
109  : myIt(other.myIt), myF(other.myF) {}
110 
115 
116  // ----------------------- Interface --------------------------------------
117  public:
118 
124  OutputIteratorAdapter& operator=(const TInputValue& aValue)
125  {
126  myF->operator()( *myIt ) = aValue;
127  return *this;
128  }
129 
134  OutputIteratorAdapter& operator*() { return *this; }
135 
140  OutputIteratorAdapter& operator++() { ++myIt; return *this; }
141 
147  {
148  OutputIteratorAdapter tmp = *this;
149  ++myIt;
150  return tmp;
151  }
152 
153 
154  // ------------------------- Hidden services ------------------------------
155  protected:
156 
157 
158  private:
159 
160  // ------------------------- Private Datas --------------------------------
161  private:
166 
170  const TFunctor* myF;
171 
172  }; // end of class OutputIteratorAdapter
173 
174 }
176 // Includes inline functions.
177 //#include "DGtal/images/OutputIteratorAdapter.ih"
178 
179 //
181 
182 #endif // !defined OutputIteratorAdapter_h
183 
184 #undef OutputIteratorAdapter_RECURSES
185 #endif // else defined(OutputIteratorAdapter_RECURSES)
Aim: This class encapsulates its parameter class so that to indicate to the user that the object/poin...
Definition: ConstAlias.h:187
Aim: Adapts an output iterator i with a unary functor f, both given at construction,...
std::output_iterator_tag iterator_category
OutputIteratorAdapter & operator++()
OutputIteratorAdapter(const OutputIteratorAdapter &other)
OutputIteratorAdapter & operator=(const TInputValue &aValue)
OutputIteratorAdapter(const Iterator &it, ConstAlias< TFunctor > f)
OutputIteratorAdapter & operator*()
OutputIteratorAdapter operator++(int)
BOOST_CONCEPT_ASSERT((boost::ForwardIterator< Iterator >))
BOOST_CONCEPT_ASSERT((concepts::CUnaryFunctor< TFunctor, typename std::iterator_traits< Iterator >::value_type &, TInputValue & >))
DGtal is the top-level namespace which contains all DGtal functions and types.
Aim: Defines a unary functor, which associates arguments to results.
Definition: CUnaryFunctor.h:90
Go to http://www.sgi.com/tech/stl/ForwardIterator.html.
Definition: Boost.dox:40