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
00027 #ifndef MLN_CORE_IMAGE_COMPLEX_WINDOW_PITER_HH
00028 # define MLN_CORE_IMAGE_COMPLEX_WINDOW_PITER_HH
00029
00032
00033 # include <mln/core/concept/window.hh>
00034 # include <mln/core/internal/site_relative_iterator_base.hh>
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045 namespace mln
00046 {
00047
00048
00049
00050
00051
00053 template <typename I, typename G, typename W>
00054 class complex_window_fwd_piter
00055 : public internal::site_relative_iterator_base< W,
00056 complex_window_fwd_piter<I, G, W> >
00057 {
00058 typedef complex_window_fwd_piter<I, G, W> self_;
00059 typedef internal::site_relative_iterator_base< W, self_ > super_;
00060
00061 public:
00063 typedef mln_psite(W) psite;
00065 typedef typename W::complex_fwd_iter iter_type;
00066
00067 public:
00070 complex_window_fwd_piter();
00071 template <typename Pref>
00072 complex_window_fwd_piter(const Window<W>& win, const Pref& p_ref);
00074
00076 template <typename Pref>
00077 void init_(const Window<W>& win, const Pref& p_ref);
00078
00082 bool is_valid_() const;
00084 void invalidate_();
00085
00087 void do_start_();
00089 void do_next_();
00090
00092 template <typename Pref>
00093 void center_at_(const Pref& c);
00094
00096 psite compute_p_() const;
00098
00101 const iter_type& iter() const;
00102 iter_type& iter();
00104
00105 private:
00107 iter_type iter_;
00108 };
00109
00110
00112 template <typename I, typename G, typename W>
00113 std::ostream&
00114 operator<<(std::ostream& ostr,
00115 const complex_window_fwd_piter<I, G, W>& p);
00116
00117
00118
00119
00120
00121
00123 template <typename I, typename G, typename W>
00124 class complex_window_bkd_piter
00125 : public internal::site_relative_iterator_base< W,
00126 complex_window_bkd_piter<I, G, W> >
00127 {
00128 typedef complex_window_bkd_piter<I, G, W> self_;
00129 typedef internal::site_relative_iterator_base< W, self_ > super_;
00130
00131 public:
00133 typedef mln_psite(W) psite;
00135 typedef typename W::complex_bkd_iter iter_type;
00136
00137 public:
00140 complex_window_bkd_piter();
00141 template <typename Pref>
00142 complex_window_bkd_piter(const Window<W>& win, const Pref& p_ref);
00144
00146 template <typename Pref>
00147 void init_(const Window<W>& win, const Pref& p_ref);
00148
00152 bool is_valid_() const;
00154 void invalidate_();
00155
00157 void do_start_();
00159 void do_next_();
00160
00162 template <typename Pref>
00163 void center_at_(const Pref& c);
00164
00166 psite compute_p_() const;
00168
00171 const iter_type& iter() const;
00172 iter_type& iter();
00174
00175 private:
00177 iter_type iter_;
00178 };
00179
00180
00182 template <typename I, typename G, typename W>
00183 std::ostream&
00184 operator<<(std::ostream& ostr,
00185 const complex_window_bkd_piter<I, G, W>& p);
00186
00187
00188
00189 # ifndef MLN_INCLUDE_ONLY
00190
00191
00192
00193
00194
00195 template <typename I, typename G, typename W>
00196 inline
00197 complex_window_fwd_piter<I, G, W>::complex_window_fwd_piter()
00198 {
00199 }
00200
00201 template <typename I, typename G, typename W>
00202 template <typename Pref>
00203 inline
00204 complex_window_fwd_piter<I, G, W>::complex_window_fwd_piter(const Window<W>& win,
00205 const Pref& p_ref)
00206 {
00207 init_(win, p_ref);
00208 }
00209
00210 template <typename I, typename G, typename W>
00211 template <typename Pref>
00212 inline
00213 void
00214 complex_window_fwd_piter<I, G, W>::init_(const Window<W>& win,
00215 const Pref& p_ref)
00216 {
00217 this->change_target(exact(win));
00218 this->center_at(p_ref);
00219 mln_postcondition(!this->is_valid());
00220 }
00221
00222
00223 template <typename I, typename G, typename W>
00224 inline
00225 bool
00226 complex_window_fwd_piter<I, G, W>::is_valid_() const
00227 {
00228 return iter_.is_valid();
00229 }
00230
00231 template <typename I, typename G, typename W>
00232 inline
00233 void
00234 complex_window_fwd_piter<I, G, W>::invalidate_()
00235 {
00236 iter_.invalidate();
00237 }
00238
00239 template <typename I, typename G, typename W>
00240 inline
00241 void
00242 complex_window_fwd_piter<I, G, W>::do_start_()
00243 {
00244 iter_.start();
00245 }
00246
00247 template <typename I, typename G, typename W>
00248 inline
00249 void
00250 complex_window_fwd_piter<I, G, W>::do_next_()
00251 {
00252 iter_.next();
00253 }
00254
00255 template <typename I, typename G, typename W>
00256 template <typename Pref>
00257 inline
00258 void
00259 complex_window_fwd_piter<I, G, W>::center_at_(const Pref&)
00260 {
00261 iter_.center_at(this->center().face());
00262 }
00263
00264 template <typename I, typename G, typename W>
00265 inline
00266 mln_psite(W)
00267 complex_window_fwd_piter<I, G, W>::compute_p_() const
00268 {
00269 return psite(this->center().site_set(), iter_);
00270 }
00271
00272 template <typename I, typename G, typename W>
00273 inline
00274 const typename W::complex_fwd_iter&
00275 complex_window_fwd_piter<I, G, W>::iter() const
00276 {
00277 return iter_;
00278 }
00279
00280 template <typename I, typename G, typename W>
00281 inline
00282 typename W::complex_fwd_iter&
00283 complex_window_fwd_piter<I, G, W>::iter()
00284 {
00285 return iter_;
00286 }
00287
00288
00289 template <typename I, typename G, typename W>
00290 inline
00291 std::ostream&
00292 operator<<(std::ostream& ostr,
00293 const complex_window_fwd_piter<I, G, W>& p)
00294 {
00295 return ostr << p.unproxy_();
00296 }
00297
00298
00299
00300
00301
00302
00303 template <typename I, typename G, typename W>
00304 inline
00305 complex_window_bkd_piter<I, G, W>::complex_window_bkd_piter()
00306 {
00307 }
00308
00309 template <typename I, typename G, typename W>
00310 template <typename Pref>
00311 inline
00312 complex_window_bkd_piter<I, G, W>::complex_window_bkd_piter(const Window<W>& win,
00313 const Pref& p_ref)
00314 {
00315 init_(win, p_ref);
00316 }
00317
00318 template <typename I, typename G, typename W>
00319 template <typename Pref>
00320 inline
00321 void
00322 complex_window_bkd_piter<I, G, W>::init_(const Window<W>& win,
00323 const Pref& p_ref)
00324 {
00325 this->change_target(exact(win));
00326 this->center_at(p_ref);
00327 mln_postcondition(!this->is_valid());
00328 }
00329
00330
00331 template <typename I, typename G, typename W>
00332 inline
00333 bool
00334 complex_window_bkd_piter<I, G, W>::is_valid_() const
00335 {
00336 return iter_.is_valid();
00337 }
00338
00339 template <typename I, typename G, typename W>
00340 inline
00341 void
00342 complex_window_bkd_piter<I, G, W>::invalidate_()
00343 {
00344 iter_.invalidate();
00345 }
00346
00347 template <typename I, typename G, typename W>
00348 inline
00349 void
00350 complex_window_bkd_piter<I, G, W>::do_start_()
00351 {
00352 iter_.start();
00353 }
00354
00355 template <typename I, typename G, typename W>
00356 inline
00357 void
00358 complex_window_bkd_piter<I, G, W>::do_next_()
00359 {
00360 iter_.next();
00361 }
00362
00363 template <typename I, typename G, typename W>
00364 template <typename Pref>
00365 inline
00366 void
00367 complex_window_bkd_piter<I, G, W>::center_at_(const Pref& )
00368 {
00369
00370 iter_.center_at(this->center().face());
00371 }
00372
00373 template <typename I, typename G, typename W>
00374 inline
00375 mln_psite(W)
00376 complex_window_bkd_piter<I, G, W>::compute_p_() const
00377 {
00378 return psite(this->center().site_set(), iter_);
00379 }
00380
00381 template <typename I, typename G, typename W>
00382 inline
00383 const typename W::complex_bkd_iter&
00384 complex_window_bkd_piter<I, G, W>::iter() const
00385 {
00386 return iter_;
00387 }
00388
00389 template <typename I, typename G, typename W>
00390 inline
00391 typename W::complex_bkd_iter&
00392 complex_window_bkd_piter<I, G, W>::iter()
00393 {
00394 return iter_;
00395 }
00396
00397
00398 template <typename I, typename G, typename W>
00399 inline
00400 std::ostream&
00401 operator<<(std::ostream& ostr,
00402 const complex_window_bkd_piter<I, G, W>& p)
00403 {
00404 return ostr << p.unproxy_();
00405 }
00406
00407 # endif // ! MLN_INCLUDE_ONLY
00408
00409 }
00410
00411 #endif // ! MLN_CORE_IMAGE_COMPLEX_WINDOW_PITER_HH