26 #ifndef MLN_CORE_INTERNAL_PIXEL_ITERATOR_BASE_HH
27 # define MLN_CORE_INTERNAL_PIXEL_ITERATOR_BASE_HH
33 # include <mln/core/concept/pixel_iterator.hh>
34 # include <mln/core/internal/pixel_impl.hh>
35 # include <mln/core/trait/qlf_value.hh>
49 template <
typename I,
typename E>
50 class pixel_iterator_base_ :
public Pixel_Iterator<E>,
51 public internal::pixel_impl_<I, E>
53 typedef internal::pixel_impl_<I, E> super_;
57 pixel_iterator_base_(I& image);
62 mln_qlf_value(I)* boi_;
65 mln_qlf_value(I)* eoi_;
77 template <
typename I,
typename E>
78 class forward_pixel_iterator_base_ :
public pixel_iterator_base_<I, E>
80 typedef pixel_iterator_base_<I, E> super_;
91 bool is_valid()
const;
97 forward_pixel_iterator_base_(I& image);
106 template <
typename I,
typename E>
107 class backward_pixel_iterator_base_ :
public pixel_iterator_base_<I, E>
109 typedef pixel_iterator_base_<I, E> super_;
119 bool is_valid()
const;
125 backward_pixel_iterator_base_(I& image);
130 #ifndef MLN_INCLUDE_ONLY
137 template <
typename I,
typename E>
139 pixel_iterator_base_<I, E>::pixel_iterator_base_(I& image)
142 mln_precondition(image.is_valid());
143 I&
ima = this->image_;
144 boi_ = &
ima( ima.domain().pmin() ) - 1;
145 eoi_ = &
ima( ima.domain().pmax() ) + 1;
146 exact(*this).invalidate();
149 template <
typename I,
typename E>
152 pixel_iterator_base_<I, E>::start_()
162 template <
typename I,
typename E>
164 forward_pixel_iterator_base_<I, E>::forward_pixel_iterator_base_(I& image)
169 template <
typename I,
typename E>
172 forward_pixel_iterator_base_<I, E>::start()
174 this->value_ptr_ = this->boi_ + 1;
175 exact(
this)->start_();
178 template <
typename I,
typename E>
181 forward_pixel_iterator_base_<I, E>::invalidate()
183 this->value_ptr_ = this->eoi_;
186 template <
typename I,
typename E>
189 forward_pixel_iterator_base_<I, E>::is_valid()
const
191 return this->value_ptr_ != this->eoi_;
199 template <
typename I,
typename E>
201 backward_pixel_iterator_base_<I, E>::backward_pixel_iterator_base_(I& image)
206 template <
typename I,
typename E>
209 backward_pixel_iterator_base_<I, E>::start()
211 this->value_ptr_ = this->eoi_ - 1;
212 exact(
this)->start_();
215 template <
typename I,
typename E>
218 backward_pixel_iterator_base_<I, E>::invalidate()
220 this->value_ptr_ = this->boi_;
223 template <
typename I,
typename E>
226 backward_pixel_iterator_base_<I, E>::is_valid()
const
228 return this->value_ptr_ != this->boi_;
231 #endif // ! MLN_INCLUDE_ONLY
238 #endif // ! MLN_CORE_INTERNAL_PIXEL_ITERATOR_BASE_HH