• Main Page
  • Related Pages
  • Modules
  • Namespaces
  • Classes
  • Files
  • File List

complex_window_piter.hh

00001 // Copyright (C) 2008, 2009 EPITA Research and Development Laboratory (LRDE)
00002 //
00003 // This file is part of Olena.
00004 //
00005 // Olena is free software: you can redistribute it and/or modify it under
00006 // the terms of the GNU General Public License as published by the Free
00007 // Software Foundation, version 2 of the License.
00008 //
00009 // Olena is distributed in the hope that it will be useful,
00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012 // General Public License for more details.
00013 //
00014 // You should have received a copy of the GNU General Public License
00015 // along with Olena.  If not, see <http://www.gnu.org/licenses/>.
00016 //
00017 // As a special exception, you may use this file as part of a free
00018 // software project without restriction.  Specifically, if other files
00019 // instantiate templates or use macros or inline functions from this
00020 // file, or you compile this file and link it with other files to produce
00021 // an executable, this file does not by itself cause the resulting
00022 // executable to be covered by the GNU General Public License.  This
00023 // exception does not however invalidate any other reasons why the
00024 // executable file might be covered by the GNU General Public License.
00025 
00026 #ifndef MLN_CORE_IMAGE_COMPLEX_WINDOW_PITER_HH
00027 # define MLN_CORE_IMAGE_COMPLEX_WINDOW_PITER_HH
00028 
00031 
00032 # include <mln/core/concept/window.hh>
00033 # include <mln/core/internal/site_relative_iterator_base.hh>
00034 
00035 // FIXME: These might be factor-able, both between fwd/bkd and nbh/win.
00036 
00037 /* FIXME: Do we really want to inherit from
00038    internal::site_relative_iterator_base?  It might duplicate things,
00039    since most of the implementation of this iterator is delegated to
00040    the underlying complex iter.  Think about introducing base class
00041    replacement.  */
00042 
00043 
00044 namespace mln
00045 {
00046 
00047   /*------------------------------------.
00048   | complex_window_fwd_piter<I, G, W>.  |
00049   `------------------------------------*/
00050 
00052   template <typename I, typename G, typename W>
00053   class complex_window_fwd_piter
00054     : public internal::site_relative_iterator_base< W,
00055                                                     complex_window_fwd_piter<I, G, W> >
00056   {
00057     typedef complex_window_fwd_piter<I, G, W> self_;
00058     typedef internal::site_relative_iterator_base< W, self_ > super_;
00059 
00060   public:
00062     typedef mln_psite(W) psite;
00064     typedef typename W::complex_fwd_iter iter_type;
00065 
00066   public:
00069     complex_window_fwd_piter();
00070     template <typename Pref>
00071     complex_window_fwd_piter(const Window<W>& win, const Pref& p_ref);
00073 
00075     template <typename Pref>
00076     void init_(const Window<W>& win, const Pref& p_ref);
00077 
00081     bool is_valid_() const;
00083     void invalidate_();
00084 
00086     void do_start_();
00088     void do_next_();
00089 
00091     template <typename Pref>
00092     void center_at_(const Pref& c);
00093 
00095     psite compute_p_() const;
00097 
00100     const iter_type& iter() const;
00101     iter_type& iter();
00103 
00104   private:
00106     iter_type iter_;
00107   };
00108 
00109 
00111   template <typename I, typename G, typename W>
00112   std::ostream&
00113   operator<<(std::ostream& ostr,
00114              const complex_window_fwd_piter<I, G, W>& p);
00115 
00116 
00117   /*------------------------------------.
00118   | complex_window_bkd_piter<I, G, W>.  |
00119   `------------------------------------*/
00120 
00122   template <typename I, typename G, typename W>
00123   class complex_window_bkd_piter
00124     : public internal::site_relative_iterator_base< W,
00125                                                     complex_window_bkd_piter<I, G, W> >
00126   {
00127     typedef complex_window_bkd_piter<I, G, W> self_;
00128     typedef internal::site_relative_iterator_base< W, self_ > super_;
00129 
00130   public:
00132     typedef mln_psite(W) psite;
00134     typedef typename W::complex_bkd_iter iter_type;
00135 
00136   public:
00139     complex_window_bkd_piter();
00140     template <typename Pref>
00141     complex_window_bkd_piter(const Window<W>& win, const Pref& p_ref);
00143 
00145     template <typename Pref>
00146     void init_(const Window<W>& win, const Pref& p_ref);
00147 
00151     bool is_valid_() const;
00153     void invalidate_();
00154 
00156     void do_start_();
00158     void do_next_();
00159 
00161     template <typename Pref>
00162     void center_at_(const Pref& c);
00163 
00165     psite compute_p_() const;
00167 
00170     const iter_type& iter() const;
00171     iter_type& iter();
00173 
00174   private:
00176     iter_type iter_;
00177   };
00178 
00179 
00181   template <typename I, typename G, typename W>
00182   std::ostream&
00183   operator<<(std::ostream& ostr,
00184              const complex_window_bkd_piter<I, G, W>& p);
00185 
00186 
00187 
00188 # ifndef MLN_INCLUDE_ONLY
00189 
00190   /*------------------------------------.
00191   | complex_window_fwd_piter<I, G, W>.  |
00192   `------------------------------------*/
00193 
00194   template <typename I, typename G, typename W>
00195   inline
00196   complex_window_fwd_piter<I, G, W>::complex_window_fwd_piter()
00197   {
00198   }
00199 
00200   template <typename I, typename G, typename W>
00201   template <typename Pref>
00202   inline
00203   complex_window_fwd_piter<I, G, W>::complex_window_fwd_piter(const Window<W>& win,
00204                                                               const Pref& p_ref)
00205   {
00206     init_(win, p_ref);
00207   }
00208 
00209   template <typename I, typename G, typename W>
00210   template <typename Pref>
00211   inline
00212   void
00213   complex_window_fwd_piter<I, G, W>::init_(const Window<W>& win,
00214                                            const Pref& p_ref)
00215   {
00216     this->change_target(exact(win));
00217     this->center_at(p_ref);
00218     mln_postcondition(!this->is_valid());
00219   }
00220 
00221 
00222   template <typename I, typename G, typename W>
00223   inline
00224   bool
00225   complex_window_fwd_piter<I, G, W>::is_valid_() const
00226   {
00227     return iter_.is_valid();
00228   }
00229 
00230   template <typename I, typename G, typename W>
00231   inline
00232   void
00233   complex_window_fwd_piter<I, G, W>::invalidate_()
00234   {
00235     iter_.invalidate();
00236   }
00237 
00238   template <typename I, typename G, typename W>
00239   inline
00240   void
00241   complex_window_fwd_piter<I, G, W>::do_start_()
00242   {
00243     iter_.start();
00244   }
00245 
00246   template <typename I, typename G, typename W>
00247   inline
00248   void
00249   complex_window_fwd_piter<I, G, W>::do_next_()
00250   {
00251     iter_.next();
00252   }
00253 
00254   template <typename I, typename G, typename W>
00255   template <typename Pref>
00256   inline
00257   void
00258   complex_window_fwd_piter<I, G, W>::center_at_(const Pref&)
00259   {
00260     iter_.center_at(this->center().face());
00261   }
00262 
00263   template <typename I, typename G, typename W>
00264   inline
00265   mln_psite(W)
00266   complex_window_fwd_piter<I, G, W>::compute_p_() const
00267   {
00268     return psite(this->center().site_set(), iter_);
00269   }
00270 
00271   template <typename I, typename G, typename W>
00272   inline
00273   const typename W::complex_fwd_iter&
00274   complex_window_fwd_piter<I, G, W>::iter() const
00275   {
00276     return iter_;
00277   }
00278 
00279   template <typename I, typename G, typename W>
00280   inline
00281   typename W::complex_fwd_iter&
00282   complex_window_fwd_piter<I, G, W>::iter()
00283   {
00284     return iter_;
00285   }
00286 
00287 
00288   template <typename I, typename G, typename W>
00289   inline
00290   std::ostream&
00291   operator<<(std::ostream& ostr,
00292              const complex_window_fwd_piter<I, G, W>& p)
00293   {
00294     return ostr << p.unproxy_();
00295   }
00296 
00297 
00298   /*------------------------------------.
00299   | complex_window_bkd_piter<I, G, W>.  |
00300   `------------------------------------*/
00301 
00302   template <typename I, typename G, typename W>
00303   inline
00304   complex_window_bkd_piter<I, G, W>::complex_window_bkd_piter()
00305   {
00306   }
00307 
00308   template <typename I, typename G, typename W>
00309   template <typename Pref>
00310   inline
00311   complex_window_bkd_piter<I, G, W>::complex_window_bkd_piter(const Window<W>& win,
00312                                                               const Pref& p_ref)
00313   {
00314     init_(win, p_ref);
00315   }
00316 
00317   template <typename I, typename G, typename W>
00318   template <typename Pref>
00319   inline
00320   void
00321   complex_window_bkd_piter<I, G, W>::init_(const Window<W>& win,
00322                                            const Pref& p_ref)
00323   {
00324     this->change_target(exact(win));
00325     this->center_at(p_ref);
00326     mln_postcondition(!this->is_valid());
00327   }
00328 
00329 
00330   template <typename I, typename G, typename W>
00331   inline
00332   bool
00333   complex_window_bkd_piter<I, G, W>::is_valid_() const
00334   {
00335     return iter_.is_valid();
00336   }
00337 
00338   template <typename I, typename G, typename W>
00339   inline
00340   void
00341   complex_window_bkd_piter<I, G, W>::invalidate_()
00342   {
00343     iter_.invalidate();
00344   }
00345 
00346   template <typename I, typename G, typename W>
00347   inline
00348   void
00349   complex_window_bkd_piter<I, G, W>::do_start_()
00350   {
00351     iter_.start();
00352   }
00353 
00354   template <typename I, typename G, typename W>
00355   inline
00356   void
00357   complex_window_bkd_piter<I, G, W>::do_next_()
00358   {
00359     iter_.next();
00360   }
00361 
00362   template <typename I, typename G, typename W>
00363   template <typename Pref>
00364   inline
00365   void
00366   complex_window_bkd_piter<I, G, W>::center_at_(const Pref& c)
00367   {
00368     iter_.center_at(this->center().face());
00369   }
00370 
00371   template <typename I, typename G, typename W>
00372   inline
00373   mln_psite(W)
00374   complex_window_bkd_piter<I, G, W>::compute_p_() const
00375   {
00376     return psite(this->center().site_set(), iter_);
00377   }
00378 
00379   template <typename I, typename G, typename W>
00380   inline
00381   const typename W::complex_bkd_iter&
00382   complex_window_bkd_piter<I, G, W>::iter() const
00383   {
00384     return iter_;
00385   }
00386 
00387   template <typename I, typename G, typename W>
00388   inline
00389   typename W::complex_bkd_iter&
00390   complex_window_bkd_piter<I, G, W>::iter()
00391   {
00392     return iter_;
00393   }
00394 
00395 
00396   template <typename I, typename G, typename W>
00397   inline
00398   std::ostream&
00399   operator<<(std::ostream& ostr,
00400              const complex_window_bkd_piter<I, G, W>& p)
00401   {
00402     return ostr << p.unproxy_();
00403   }
00404 
00405 # endif // ! MLN_INCLUDE_ONLY
00406 
00407 } // end of namespace mln
00408 
00409 #endif // ! MLN_CORE_IMAGE_COMPLEX_WINDOW_PITER_HH

Generated on Fri Oct 19 2012 04:15:41 for Milena (Olena) by  doxygen 1.7.1