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

graph_window_piter.hh

00001 // Copyright (C) 2007, 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_GRAPH_WINDOW_PITER_HH
00027 # define MLN_CORE_IMAGE_GRAPH_WINDOW_PITER_HH
00028 
00032 
00033 # include <mln/core/internal/site_relative_iterator_base.hh>
00034 
00035 
00036 namespace mln
00037 {
00038 
00039   // Forward declaration.
00040   template <typename S, typename I> class p_graph_piter;
00041 
00043   template <typename S, typename W, typename I>
00044   class graph_window_piter
00045     : public internal::site_relative_iterator_base< W,
00046                                           graph_window_piter<S,W,I> >
00047   {
00048     typedef graph_window_piter<S,W,I> self_;
00049     typedef internal::site_relative_iterator_base<W,self_> super_;
00050 
00051   public:
00054     typedef mln_result(S::fun_t) P;
00056 
00059     graph_window_piter();
00060     template <typename Pref>
00061     graph_window_piter(const Window<W>& win,
00062                        const Pref& p_ref);
00064 
00068     bool is_valid_() const;
00070     void invalidate_();
00071 
00073     void do_start_();
00075     void do_next_();
00076 
00078     template <typename Pref>
00079     void center_at_(const Pref& c);
00080 
00082     template <typename I2>
00083     void center_at_(const p_graph_piter<S, I2>& c);
00084 
00086     const mln_graph_element(S)& element() const;
00087 
00089     mln_psite(W) compute_p_() const;
00090 
00095     unsigned id() const;
00097 
00098   private:
00099     I iter_;
00100   };
00101 
00102 
00103 # ifndef MLN_INCLUDE_ONLY
00104 
00105 
00106   template <typename S, typename W, typename I>
00107   inline
00108   graph_window_piter<S,W,I>::graph_window_piter()
00109   {
00110   }
00111 
00112   template <typename S, typename W, typename I>
00113   template <typename Pref>
00114   inline
00115   graph_window_piter<S,W,I>::graph_window_piter(const Window<W>& win,
00116                                                 const Pref& p_ref)
00117   {
00118     this->center_at(p_ref);
00119     this->change_target(exact(win));
00120     mln_postcondition(!this->is_valid());
00121   }
00122 
00123   template <typename S, typename W, typename I>
00124   inline
00125   bool
00126   graph_window_piter<S,W,I>::is_valid_() const
00127   {
00128     return iter_.is_valid();
00129   }
00130 
00131   template <typename S, typename W, typename I>
00132   inline
00133   void
00134   graph_window_piter<S,W,I>::invalidate_()
00135   {
00136     iter_.invalidate();
00137   }
00138 
00139   template <typename S, typename W, typename I>
00140   inline
00141   void
00142   graph_window_piter<S,W,I>::do_start_()
00143   {
00144     iter_.start();
00145   }
00146 
00147   template <typename S, typename W, typename I>
00148   inline
00149   void
00150   graph_window_piter<S,W,I>::do_next_()
00151   {
00152     iter_.next();
00153   }
00154 
00155   template <typename S, typename W, typename I>
00156   template <typename Pref>
00157   inline
00158   void
00159   graph_window_piter<S, W, I>::center_at_(const Pref& c)
00160   {
00161     iter_.center_at(c.p_hook_());
00162   }
00163 
00164   template <typename S, typename W, typename I>
00165   template <typename I2>
00166   inline
00167   void
00168   graph_window_piter<S, W, I>::center_at_(const p_graph_piter<S, I2>& c)
00169   {
00170     iter_.center_at(c.hook_elt_());
00171   }
00172 
00173   template <typename S, typename W, typename I>
00174   inline
00175   mln_psite(W)
00176   graph_window_piter<S,W,I>::compute_p_() const
00177   {
00178     return mln_psite(S)(this->center().site_set(), iter_.id());
00179   }
00180 
00181   template <typename S, typename W, typename I>
00182   inline
00183   const mln_graph_element(S)&
00184   graph_window_piter<S, W, I>::element() const
00185   {
00186     return iter_;
00187   }
00188 
00189 //  template <typename S, typename W, typename I>
00190 //  inline
00191 //  graph_window_piter<S, W, I>::operator unsigned() const
00192 //  {
00193 //    return iter_.id();
00194 //  }
00195 //
00196   template <typename S, typename W, typename I>
00197   inline
00198   unsigned
00199   graph_window_piter<S, W, I>::id() const
00200   {
00201     return iter_.id();
00202   }
00203 
00204 # endif // ! MLN_INCLUDE_ONLY
00205 
00206 } // end of namespace mln
00207 
00208 #endif // ! MLN_CORE_IMAGE_GRAPH_WINDOW_PITER_HH

Generated on Thu Sep 8 2011 18:31:53 for Milena (Olena) by  doxygen 1.7.1