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

p_run_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_SITE_SET_P_RUN_PITER_HH
00027 # define MLN_CORE_SITE_SET_P_RUN_PITER_HH
00028 
00034 # include <mln/core/site_set/p_run.hh>
00035 # include <mln/core/internal/site_set_iterator_base.hh>
00036 
00037 
00038 namespace mln
00039 {
00040 
00044   template <typename P>
00045   class p_run_fwd_piter_
00046     :
00047     public internal::site_set_iterator_base< p_run<P>,
00048                                              p_run_fwd_piter_<P> >
00049   {
00050     typedef p_run_fwd_piter_<P> self_;
00051     typedef internal::site_set_iterator_base< p_run<P>, self_ > super_;
00052   public:
00053 
00055     p_run_fwd_piter_();
00056 
00058     p_run_fwd_piter_(const p_run<P>& r);
00059 
00061     bool is_valid_() const;
00062 
00064     void invalidate_();
00065 
00067     void start_();
00068 
00070     void next_();
00071 
00072   protected:
00073     using super_::p_;
00074     using super_::s_;
00075   };
00076 
00077 
00078 
00082   template <typename P>
00083   class p_run_bkd_piter_
00084     :
00085     public internal::site_set_iterator_base< p_run<P>,
00086                                              p_run_bkd_piter_<P> >
00087   {
00088     typedef p_run_bkd_piter_<P> self_;
00089     typedef internal::site_set_iterator_base< p_run<P>, self_ > super_;
00090   public:
00091 
00093     p_run_bkd_piter_();
00094 
00096     p_run_bkd_piter_(const p_run<P>& r);
00097 
00099     bool is_valid_() const;
00100 
00102     void invalidate_();
00103 
00105     void start_();
00106 
00108     void next_();
00109 
00110   protected:
00111     using super_::p_;
00112     using super_::s_;
00113   };
00114 
00115 
00116 
00117 # ifndef MLN_INCLUDE_ONLY
00118 
00119   // p_run_fwd_piter_<P>
00120 
00121   template <typename P>
00122   inline
00123   p_run_fwd_piter_<P>::p_run_fwd_piter_()
00124   {
00125   }
00126 
00127   template <typename P>
00128   inline
00129   p_run_fwd_piter_<P>::p_run_fwd_piter_(const p_run<P>& r)
00130   {
00131     this->change_target(r);
00132   }
00133 
00134   template <typename P>
00135   inline
00136   bool
00137   p_run_fwd_piter_<P>::is_valid_() const
00138   {
00139     mln_invariant(p_.index() >= 0);
00140     return p_.index() < int(s_->length());
00141   }
00142 
00143   template <typename P>
00144   inline
00145   void
00146   p_run_fwd_piter_<P>::invalidate_()
00147   {
00148     p_.change_index(s_->length());
00149   }
00150 
00151   template <typename P>
00152   inline
00153   void
00154   p_run_fwd_piter_<P>::start_()
00155   {
00156     p_.change_index(0);
00157   }
00158 
00159   template <typename P>
00160   inline
00161   void
00162   p_run_fwd_piter_<P>::next_()
00163   {
00164     p_.inc_index();
00165   }
00166 
00167 
00168   // p_run_bkd_piter_<P>
00169 
00170   template <typename P>
00171   inline
00172   p_run_bkd_piter_<P>::p_run_bkd_piter_()
00173   {
00174   }
00175 
00176   template <typename P>
00177   inline
00178   p_run_bkd_piter_<P>::p_run_bkd_piter_(const p_run<P>& r)
00179   {
00180     this->change_target(r);
00181   }
00182 
00183   template <typename P>
00184   inline
00185   bool
00186   p_run_bkd_piter_<P>::is_valid_() const
00187   {
00188     mln_invariant(p_.index() < int(s_->length()));
00189     return p_.index() >= 0;
00190   }
00191 
00192   template <typename P>
00193   inline
00194   void
00195   p_run_bkd_piter_<P>::invalidate_()
00196   {
00197     p_.change_index(-1);
00198   }
00199 
00200   template <typename P>
00201   inline
00202   void
00203   p_run_bkd_piter_<P>::start_()
00204   {
00205     p_.change_index(s_->length() - 1);
00206   }
00207 
00208   template <typename P>
00209   inline
00210   void
00211   p_run_bkd_piter_<P>::next_()
00212   {
00213     p_.dec_index();
00214   }
00215 
00216 
00217 # endif // ! MLN_INCLUDE_ONLY
00218 
00219 } // end of namespace mln
00220 
00221 
00222 #endif // ! MLN_CORE_SITE_SET_P_RUN_PITER_HH

Generated on Tue Oct 4 2011 15:24:16 for Milena (Olena) by  doxygen 1.7.1