00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 
00022 
00023 
00024 
00025 
00026 #ifndef MLN_CORE_INTERNAL_PIXEL_ITERATOR_BASE_HH
00027 # define MLN_CORE_INTERNAL_PIXEL_ITERATOR_BASE_HH
00028 
00032 
00033 # include <mln/core/concept/pixel_iterator.hh>
00034 # include <mln/core/internal/pixel_impl.hh>
00035 # include <mln/core/trait/qlf_value.hh>
00036 
00037 
00038 namespace mln
00039 {
00040 
00041   namespace internal
00042   {
00043 
00044     
00045 
00046 
00047 
00049     template <typename I, typename E>
00050     class pixel_iterator_base_ : public Pixel_Iterator<E>,
00051                                  public internal::pixel_impl_<I, E>
00052     {
00053       typedef internal::pixel_impl_<I, E> super_;
00054 
00055     protected:
00057       pixel_iterator_base_(I& image);
00058 
00059     protected:
00060 
00062       mln_qlf_value(I)* boi_;
00063 
00065       mln_qlf_value(I)* eoi_;
00066 
00068       void start_();
00069     };
00070 
00071 
00072     
00073 
00074 
00075 
00077     template <typename I, typename E>
00078     class forward_pixel_iterator_base_ : public pixel_iterator_base_<I, E>
00079     {
00080       typedef pixel_iterator_base_<I, E> super_;
00081 
00082     public:
00083 
00087       void start();
00089       void invalidate();
00091       bool is_valid() const;
00093 
00094     protected:
00095 
00097       forward_pixel_iterator_base_(I& image);
00098     };
00099 
00100 
00101     
00102 
00103 
00104 
00106     template <typename I, typename E>
00107     class backward_pixel_iterator_base_ : public pixel_iterator_base_<I, E>
00108     {
00109       typedef pixel_iterator_base_<I, E> super_;
00110 
00111     public:
00115       void start();
00117       void invalidate();
00119       bool is_valid() const;
00121 
00122     protected:
00123 
00125       backward_pixel_iterator_base_(I& image);
00126     };
00127 
00128 
00129 
00130 #ifndef MLN_INCLUDE_ONLY
00131 
00132 
00133     
00134 
00135 
00136 
00137     template <typename I, typename E>
00138     inline
00139     pixel_iterator_base_<I, E>::pixel_iterator_base_(I& image)
00140       : super_(image)
00141     {
00142       mln_precondition(image.is_valid());
00143       I& ima = this->image_;
00144       boi_ = & ima( ima.domain().pmin() ) - 1;
00145       eoi_ = & ima( ima.domain().pmax() ) + 1;
00146       exact(*this).invalidate();
00147     }
00148 
00149     template <typename I, typename E>
00150     inline
00151     void
00152     pixel_iterator_base_<I, E>::start_()
00153     {
00154       
00155     }
00156 
00157 
00158     
00159 
00160 
00161 
00162     template <typename I, typename E>
00163     inline
00164     forward_pixel_iterator_base_<I, E>::forward_pixel_iterator_base_(I& image)
00165       : super_(image)
00166     {
00167     }
00168 
00169     template <typename I, typename E>
00170     inline
00171     void
00172     forward_pixel_iterator_base_<I, E>::start()
00173     {
00174       this->value_ptr_ = this->boi_ + 1;
00175       exact(this)->start_();
00176     }
00177 
00178     template <typename I, typename E>
00179     inline
00180     void
00181     forward_pixel_iterator_base_<I, E>::invalidate()
00182     {
00183       this->value_ptr_ = this->eoi_;
00184     }
00185 
00186     template <typename I, typename E>
00187     inline
00188     bool
00189     forward_pixel_iterator_base_<I, E>::is_valid() const
00190     {
00191       return this->value_ptr_ != this->eoi_;
00192     }
00193 
00194 
00195     
00196 
00197 
00198 
00199     template <typename I, typename E>
00200     inline
00201     backward_pixel_iterator_base_<I, E>::backward_pixel_iterator_base_(I& image)
00202       : super_(image)
00203     {
00204     }
00205 
00206     template <typename I, typename E>
00207     inline
00208     void
00209     backward_pixel_iterator_base_<I, E>::start()
00210     {
00211       this->value_ptr_ = this->eoi_ - 1;
00212       exact(this)->start_();
00213     }
00214 
00215     template <typename I, typename E>
00216     inline
00217     void
00218     backward_pixel_iterator_base_<I, E>::invalidate()
00219     {
00220       this->value_ptr_ = this->boi_;
00221     }
00222 
00223     template <typename I, typename E>
00224     inline
00225     bool
00226     backward_pixel_iterator_base_<I, E>::is_valid() const
00227     {
00228       return this->value_ptr_ != this->boi_;
00229     }
00230 
00231 #endif // ! MLN_INCLUDE_ONLY
00232 
00233   } 
00234 
00235 } 
00236 
00237 
00238 #endif // ! MLN_CORE_INTERNAL_PIXEL_ITERATOR_BASE_HH