1897: Simplify the hierarchy of piters on graph windows and neighborhoods.

https://svn.lrde.epita.fr/svn/oln/trunk/milena Cleared almost 80 lines. Yeepee! Index: ChangeLog from Roland Levillain <roland@lrde.epita.fr> Simplify the hierarchy of piters on graph windows and neighborhoods. * mln/core/graph_window_piter.hh (mln::internal::graph_window_piter_<P, W, E>): Remove class. (mln::graph_window_fwd_piter<P, W>) (mln::graph_window_bkd_piter<P, W>): Inherit from internal::graph_vicinity_piter_ directly. (mln::graph_window_fwd_piter<P, W>::super_) (mln::graph_window_bkd_piter<P, W>::super_): Adjust typedefs. (mln::graph_window_fwd_piter<P, W>::win_) (mln::graph_window_bkd_piter<P, W>::win_): New members. (mln::graph_window_fwd_piter<P, W>::graph_window_fwd_piter) (mln::graph_window_bkd_piter<P, W>::graph_window_bkd_piter): Adjust ctors. * mln/core/graph_neighborhood_piter.hh (mln::internal::graph_neighborhood_piter_<P, N, E>): Remove class. (mln::graph_neighborhood_fwd_piter<P, N>) (mln::graph_neighborhood_bkd_piter<P, N>): Inherit from internal::graph_vicinity_piter_ directly. (mln::graph_neighborhood_fwd_piter<P, N>::super_) (mln::graph_neighborhood_bkd_piter<P, N>::super_): Adjust typedefs. (mln::graph_neighborhood_fwd_piter<P, N>::nbh_) (mln::graph_neighborhood_bkd_piter<P, N>::nbh_): New members. (mln::graph_neighborhood_fwd_piter<P, N>::graph_neighborhood_fwd_piter) (mln::graph_neighborhood_bkd_piter<P, N>::graph_neighborhood_bkd_piter): Adjust ctors. graph_neighborhood_piter.hh | 72 +++++++++----------------------------------- graph_window_piter.hh | 71 +++++++++---------------------------------- 2 files changed, 32 insertions(+), 111 deletions(-) Index: mln/core/graph_neighborhood_piter.hh --- mln/core/graph_neighborhood_piter.hh (revision 1896) +++ mln/core/graph_neighborhood_piter.hh (working copy) @@ -51,47 +51,17 @@ namespace mln { - /*-----------------------------------------------. - | internal::graph_neighborhood_piter_<P, N, E>. | - `-----------------------------------------------*/ - - namespace internal - { - - /// \brief Base for iterator on a graph neighborhood. - template <typename P, typename N, typename E> - class graph_neighborhood_piter_ : public graph_vicinity_piter_<P, E> - { - typedef graph_neighborhood_piter_<P, N, E> self_; - typedef graph_vicinity_piter_<P, E> super_; - - public: - /// Construction. - /// \{ - template <typename Pref> - graph_neighborhood_piter_(const Neighborhood<N>& nbh, - const Point_Site<Pref>& p_ref); - /// \} - - protected: - /// The neighborhood. - const N& nbh_; - }; - - } // end of namespace mln::internal - - /*-------------------------------------. | graph_neighborhood_fwd_piter<P, N>. | `-------------------------------------*/ template <typename P, typename N> class graph_neighborhood_fwd_piter : - public internal::graph_neighborhood_piter_< P, N, + public internal::graph_vicinity_piter_< P, graph_neighborhood_fwd_piter<P, N> > { typedef graph_neighborhood_fwd_piter<P, N> self_; - typedef internal::graph_neighborhood_piter_<P, N, self_> super_; + typedef internal::graph_vicinity_piter_<P, self_> super_; public: /// Construction. @@ -116,6 +86,10 @@ /// Advance the position of the iterator by one step. void step_(); /// \} + + private: + /// The neighborhood. + const N& nbh_; }; @@ -125,11 +99,11 @@ template <typename P, typename N> class graph_neighborhood_bkd_piter : - public internal::graph_neighborhood_piter_< P, N, + public internal::graph_vicinity_piter_< P, graph_neighborhood_bkd_piter<P, N> > { typedef graph_neighborhood_bkd_piter<P, N> self_; - typedef internal::graph_neighborhood_piter_<P, N, self_> super_; + typedef internal::graph_vicinity_piter_<P, self_> super_; public: /// Construction. @@ -154,32 +128,16 @@ /// Advance the position of the iterator by one step. void step_(); /// \} + + private: + /// The neighborhood. + const N& nbh_; }; # ifndef MLN_INCLUDE_ONLY - /*-----------------------------------------------. - | internal::graph_neighborhood_piter_<P, N, E>. | - `-----------------------------------------------*/ - - namespace internal - { - - template <typename P, typename N, typename E> - template <typename Pref> - inline - graph_neighborhood_piter_<P, N, E>::graph_neighborhood_piter_(const Neighborhood<N>& nbh, - const Point_Site<Pref>& p_ref) - : super_(p_ref), - nbh_(exact(nbh)) - { - } - - } // end of namespace mln::internal - - /*-------------------------------------. | graph_neighborhood_fwd_piter<P, N>. | `-------------------------------------*/ @@ -189,7 +147,8 @@ inline graph_neighborhood_fwd_piter<P, N>::graph_neighborhood_fwd_piter(const Neighborhood<N>& nbh, const Point_Site<Pref>& p_ref) - : super_(nbh, p_ref) + : super_(p_ref), + nbh_(exact(nbh)) { } @@ -239,7 +198,8 @@ inline graph_neighborhood_bkd_piter<P, N>::graph_neighborhood_bkd_piter(const Neighborhood<N>& nbh, const Point_Site<Pref>& p_ref) - : super_(nbh, p_ref) + : super_(p_ref), + nbh_(exact(nbh)) { } Index: mln/core/graph_window_piter.hh --- mln/core/graph_window_piter.hh (revision 1896) +++ mln/core/graph_window_piter.hh (working copy) @@ -51,35 +51,6 @@ namespace mln { - /*-----------------------------------------. - | internal::graph_window_piter_<P, W, E>. | - `-----------------------------------------*/ - - namespace internal - { - - /// \brief Base for iterator on a graph window. - template <typename P, typename W, typename E> - class graph_window_piter_ : public graph_vicinity_piter_<P, E> - { - typedef graph_window_piter_<P, W, E> self_; - typedef graph_vicinity_piter_<P, E> super_; - - public: - /// Construction. - /// \{ - template <typename Pref> - graph_window_piter_(const Window<W>& win, const Point_Site<Pref>& p_ref); - /// \} - - protected: - /// The window. - const W& win_; - }; - - } // end of namespace mln::internal - - /*-------------------------------. | graph_window_fwd_piter<P, W>. | `-------------------------------*/ @@ -87,10 +58,10 @@ /// \brief Forward iterator on graph window. template <typename P, typename W> class graph_window_fwd_piter : - public internal::graph_window_piter_< P, W, graph_window_fwd_piter<P, W> > + public internal::graph_vicinity_piter_< P, graph_window_fwd_piter<P, W> > { typedef graph_window_fwd_piter<P, W> self_; - typedef internal::graph_window_piter_<P, W, self_> super_; + typedef internal::graph_vicinity_piter_<P, self_> super_; public: /// Construction. @@ -114,6 +85,10 @@ /// Advance the position of the iterator by one step. void step_(); /// \} + + private: + /// The window. + const W& win_; }; @@ -124,10 +99,10 @@ /// \brief Backward iterator on graph window. template <typename P, typename W> class graph_window_bkd_piter : - public internal::graph_window_piter_< P, W, graph_window_bkd_piter<P, W> > + public internal::graph_vicinity_piter_< P, graph_window_bkd_piter<P, W> > { typedef graph_window_bkd_piter<P, W> self_; - typedef internal::graph_window_piter_<P, W, self_> super_; + typedef internal::graph_vicinity_piter_<P, self_> super_; public: /// Construction. @@ -151,32 +126,16 @@ /// Advance the position of the iterator by one step. void step_(); /// \} + + private: + /// The window. + const W& win_; }; # ifndef MLN_INCLUDE_ONLY - /*-----------------------------------------. - | internal::graph_window_piter_<P, W, E>. | - `-----------------------------------------*/ - - namespace internal - { - - template <typename P, typename W, typename E> - template <typename Pref> - inline - graph_window_piter_<P, W, E>::graph_window_piter_(const Window<W>& win, - const Point_Site<Pref>& p_ref) - : super_(p_ref), - win_(exact(win)) - { - } - - } // end of namespace mln::internal - - /*-------------------------------. | graph_window_fwd_piter<P, W>. | `-------------------------------*/ @@ -186,7 +145,8 @@ inline graph_window_fwd_piter<P, W>::graph_window_fwd_piter(const Window<W>& win, const Point_Site<Pref>& p_ref) - : super_(win, p_ref) + : super_(p_ref), + win_(exact(win)) { } @@ -236,7 +196,8 @@ inline graph_window_bkd_piter<P, W>::graph_window_bkd_piter(const Window<W>& win, const Point_Site<Pref>& p_ref) - : super_(win, p_ref) + : super_(p_ref), + win_(exact(win)) { }
participants (1)
-
Roland Levillain