DGtal  1.2.0
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  public std::iterator<std::output_iterator_tag,void,void,void,void>
77  {
78  // ----------------------- Types definitions ------------------------------
79 
80  public:
81 
82  typedef TIterator Iterator;
85  typename std::iterator_traits<Iterator>::value_type&, TInputValue& > ));
86 
87  // ----------------------- Standard services ------------------------------
88  public:
95  : myIt(it), myF(&f) {}
96 
102  : myIt(other.myIt), myF(other.myF) {}
103 
108 
109  // ----------------------- Interface --------------------------------------
110  public:
111 
117  OutputIteratorAdapter& operator=(const TInputValue& aValue)
118  {
119  myF->operator()( *myIt ) = aValue;
120  return *this;
121  }
122 
127  OutputIteratorAdapter& operator*() { return *this; }
128 
133  OutputIteratorAdapter& operator++() { ++myIt; return *this; }
134 
140  {
141  OutputIteratorAdapter tmp = *this;
142  ++myIt;
143  return tmp;
144  }
145 
146 
147  // ------------------------- Hidden services ------------------------------
148  protected:
149 
150 
151  private:
152 
153  // ------------------------- Private Datas --------------------------------
154  private:
159 
163  const TFunctor* myF;
164 
165  }; // end of class OutputIteratorAdapter
166 
167 }
169 // Includes inline functions.
170 //#include "DGtal/images/OutputIteratorAdapter.ih"
171 
172 //
174 
175 #endif // !defined OutputIteratorAdapter_h
176 
177 #undef OutputIteratorAdapter_RECURSES
178 #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,...
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