$extrastylesheet
Olena  User documentation 2.1
An Image Processing Platform
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
pixel_iterator_base.hh
1 // Copyright (C) 2007, 2008, 2009, 2012 EPITA Research and Development
2 // Laboratory (LRDE)
3 //
4 // This file is part of Olena.
5 //
6 // Olena is free software: you can redistribute it and/or modify it under
7 // the terms of the GNU General Public License as published by the Free
8 // Software Foundation, version 2 of the License.
9 //
10 // Olena is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 // General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with Olena. If not, see <http://www.gnu.org/licenses/>.
17 //
18 // As a special exception, you may use this file as part of a free
19 // software project without restriction. Specifically, if other files
20 // instantiate templates or use macros or inline functions from this
21 // file, or you compile this file and link it with other files to produce
22 // an executable, this file does not by itself cause the resulting
23 // executable to be covered by the GNU General Public License. This
24 // exception does not however invalidate any other reasons why the
25 // executable file might be covered by the GNU General Public License.
26 
27 #ifndef MLN_CORE_INTERNAL_PIXEL_ITERATOR_BASE_HH
28 # define MLN_CORE_INTERNAL_PIXEL_ITERATOR_BASE_HH
29 
33 
34 # include <mln/core/concept/pixel_iterator.hh>
35 # include <mln/core/internal/pixel_impl.hh>
36 # include <mln/core/trait/qlf_value.hh>
37 
38 
39 namespace mln
40 {
41 
42  namespace internal
43  {
44 
45  /*---------------------------------------.
46  | internal::pixel_iterator_base_<I, E>. |
47  `---------------------------------------*/
48 
53  template <typename I, typename E>
55  public internal::pixel_impl_<I, E>
56  {
57  typedef internal::pixel_impl_<I, E> super_;
58 
59  protected:
62 
63  protected:
64 
66  mln_qlf_value(I)* boi_;
67 
69  mln_qlf_value(I)* eoi_;
70 
72  void start_();
73  };
74 
75 
76  /*-----------------------------------------------.
77  | internal::forward_pixel_iterator_base_<I, E>. |
78  `-----------------------------------------------*/
79 
84  template <typename I, typename E>
86  {
87  typedef pixel_iterator_base_<I, E> super_;
88 
89  public:
90 
94  void start();
96  void invalidate();
98  bool is_valid() const;
100 
101  protected:
102 
105  };
106 
107 
108  /*------------------------------------------------.
109  | internal::backward_pixel_iterator_base_<I, E>. |
110  `------------------------------------------------*/
111 
116  template <typename I, typename E>
118  {
119  typedef pixel_iterator_base_<I, E> super_;
120 
121  public:
125  void start();
127  void invalidate();
129  bool is_valid() const;
131 
132  protected:
133 
136  };
137 
138 
139 
140 #ifndef MLN_INCLUDE_ONLY
141 
142 
143  /*---------------------------------------.
144  | internal::pixel_iterator_base_<I, E>. |
145  `---------------------------------------*/
146 
147  template <typename I, typename E>
148  inline
150  : super_(image)
151  {
152  mln_precondition(image.is_valid());
153  I& ima = this->image_;
154  boi_ = & ima( ima.domain().pmin() ) - 1;
155  eoi_ = & ima( ima.domain().pmax() ) + 1;
156  exact(*this).invalidate();
157  }
158 
159  template <typename I, typename E>
160  inline
161  void
163  {
164  // Default impl is no-op.
165  }
166 
167 
168  /*-----------------------------------------------.
169  | internal::forward_pixel_iterator_base_<I, E>. |
170  `-----------------------------------------------*/
171 
172  template <typename I, typename E>
173  inline
175  : super_(image)
176  {
177  }
178 
179  template <typename I, typename E>
180  inline
181  void
183  {
184  this->value_ptr_ = this->boi_ + 1;
185  exact(this)->start_();
186  }
187 
188  template <typename I, typename E>
189  inline
190  void
192  {
193  this->value_ptr_ = this->eoi_;
194  }
195 
196  template <typename I, typename E>
197  inline
198  bool
200  {
201  return this->value_ptr_ != this->eoi_;
202  }
203 
204 
205  /*------------------------------------------------.
206  | internal::backward_pixel_iterator_base_<I, E>. |
207  `------------------------------------------------*/
208 
209  template <typename I, typename E>
210  inline
212  : super_(image)
213  {
214  }
215 
216  template <typename I, typename E>
217  inline
218  void
220  {
221  this->value_ptr_ = this->eoi_ - 1;
222  exact(this)->start_();
223  }
224 
225  template <typename I, typename E>
226  inline
227  void
229  {
230  this->value_ptr_ = this->boi_;
231  }
232 
233  template <typename I, typename E>
234  inline
235  bool
237  {
238  return this->value_ptr_ != this->boi_;
239  }
240 
241 #endif // ! MLN_INCLUDE_ONLY
242 
243  } // end of namespace internal
244 
245 } // end of namespace mln
246 
247 
248 #endif // ! MLN_CORE_INTERNAL_PIXEL_ITERATOR_BASE_HH