Milena (Olena)  User documentation 2.0a Id
site_set_iterator_base.hh
00001 // Copyright (C) 2008, 2009, 2011 EPITA Research and Development
00002 // Laboratory (LRDE)
00003 //
00004 // This file is part of Olena.
00005 //
00006 // Olena is free software: you can redistribute it and/or modify it under
00007 // the terms of the GNU General Public License as published by the Free
00008 // Software Foundation, version 2 of the License.
00009 //
00010 // Olena is distributed in the hope that it will be useful,
00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013 // General Public License for more details.
00014 //
00015 // You should have received a copy of the GNU General Public License
00016 // along with Olena.  If not, see <http://www.gnu.org/licenses/>.
00017 //
00018 // As a special exception, you may use this file as part of a free
00019 // software project without restriction.  Specifically, if other files
00020 // instantiate templates or use macros or inline functions from this
00021 // file, or you compile this file and link it with other files to produce
00022 // an executable, this file does not by itself cause the resulting
00023 // executable to be covered by the GNU General Public License.  This
00024 // exception does not however invalidate any other reasons why the
00025 // executable file might be covered by the GNU General Public License.
00026 
00027 #ifndef MLN_CORE_INTERNAL_SITE_SET_ITERATOR_BASE_HH
00028 # define MLN_CORE_INTERNAL_SITE_SET_ITERATOR_BASE_HH
00029 
00034 
00035 # include <mln/core/internal/site_iterator_base.hh>
00036 
00037 
00038 namespace mln
00039 {
00040 
00041   namespace internal
00042   {
00043 
00051     //
00052     template <typename S, typename E>
00053     class site_set_iterator_base : public site_iterator_base<S, E>
00054     {
00055     public:
00056 
00058       typedef S pset;
00059 
00061       const S& site_set() const;
00062 
00064       const mln_psite(S)& p_hook_() const;
00065 
00067       void change_target(const S& s);
00068 
00071       void change_target_(const S& s);
00072 
00073     protected:
00074 
00076       mln_psite(S) p_;
00077 
00079       site_set_iterator_base();
00080     };
00081 
00082 
00083 #ifndef MLN_INCLUDE_ONLY
00084 
00085     template <typename S, typename E>
00086     inline
00087     site_set_iterator_base<S, E>::site_set_iterator_base()
00088     {
00089     }
00090 
00091     template <typename S, typename E>
00092     inline
00093     const S&
00094     site_set_iterator_base<S, E>::site_set() const
00095     {
00096       mln_precondition(this->s_ != 0);
00097       return *this->s_;
00098     }
00099 
00100     template <typename S, typename E>
00101     inline
00102     void
00103     site_set_iterator_base<S, E>::change_target(const S& s)
00104     {
00105       this->s_ = & s;
00106       // p might be also updated since it can hold a pointer towards
00107       // the set it designates, so:
00108       if_possible::change_target(p_, s);
00109       // Likewise, the iterator might need to update specific data.
00110       exact(this)->change_target_(s);
00111       // Last:
00112       this->invalidate();
00113     }
00114 
00115     template <typename S, typename E>
00116     inline
00117     void
00118     site_set_iterator_base<S, E>::change_target_(const S& s)
00119     {
00120       (void) s;
00121       // Empty by default.
00122     }
00123 
00124     template <typename S, typename E>
00125     inline
00126     const mln_psite(S)&
00127     site_set_iterator_base<S, E>::p_hook_() const
00128     {
00129       return p_;
00130     }
00131 
00132 #endif // ! MLN_INCLUDE_ONLY
00133 
00134   } // end of namespace internal
00135 
00136 } // end of namespace mln
00137 
00138 
00139 #endif // ! MLN_CORE_INTERNAL_SITE_SET_ITERATOR_BASE_HH
 All Classes Namespaces Functions Variables Typedefs Enumerator