
* mln/core/dpsites_piter.hh, * mln/core/image/complex_neighborhood_piter.hh, * mln/core/image/graph_window_piter.hh, * mln/core/neighb.hh: implement center_at_(). * mln/core/internal/site_relative_iterator_base.hh: call center_at_(). Derived classes must implement that method. --- milena/ChangeLog | 13 ++++ milena/mln/core/dpsites_piter.hh | 74 ++++++++++++------- .../mln/core/image/complex_neighborhood_piter.hh | 33 +++------ milena/mln/core/image/graph_window_piter.hh | 29 +++++--- .../core/internal/site_relative_iterator_base.hh | 3 +- milena/mln/core/neighb.hh | 24 ++++++ 6 files changed, 116 insertions(+), 60 deletions(-) diff --git a/milena/ChangeLog b/milena/ChangeLog index 6e38723..57392db 100644 --- a/milena/ChangeLog +++ b/milena/ChangeLog @@ -1,5 +1,18 @@ 2008-12-30 Guillaume Lazzara <z@lrde.epita.fr> + Add a call to center_at_() in + site_relative_iterator_base::center_at() (ticket #176). + + * mln/core/dpsites_piter.hh, + * mln/core/image/complex_neighborhood_piter.hh, + * mln/core/image/graph_window_piter.hh, + * mln/core/neighb.hh: implement center_at_(). + + * mln/core/internal/site_relative_iterator_base.hh: call center_at_(). + Derived classes must implement that method. + +2008-12-30 Guillaume Lazzara <z@lrde.epita.fr> + Fix from_to dispatch. * mln/convert/from_to.hh: dispatch functions where not called at all. diff --git a/milena/mln/core/dpsites_piter.hh b/milena/mln/core/dpsites_piter.hh index 99d95f5..6895cba 100644 --- a/milena/mln/core/dpsites_piter.hh +++ b/milena/mln/core/dpsites_piter.hh @@ -1,4 +1,5 @@ // Copyright (C) 2007, 2008 EPITA Research and Development Laboratory +// (LRDE) // // This file is part of the Olena Library. This library is free // software; you can redistribute it and/or modify it under the terms @@ -28,11 +29,10 @@ #ifndef MLN_CORE_DPSITES_PITER_HH # define MLN_CORE_DPSITES_PITER_HH -/*! \file mln/core/dpsites_piter.hh - * - * \brief Definition of forward and backward mln::dpoint_ based - * iterators. - */ +/// \file mln/core/dpsites_piter.hh +/// +/// Definition of forward and backward mln::dpoint_ based +/// iterators. # include <vector> # include <mln/core/internal/site_relative_iterator_base.hh> @@ -41,23 +41,21 @@ namespace mln { - /*! \brief A generic forward iterator on points of windows and of - * neighborhoods. - * - * The parameter \c V is the type of std::vector enclosing - * structure. - */ + /// A generic forward iterator on points of windows and of + /// neighborhoods. + /// + /// The parameter \c V is the type of std::vector enclosing + /// structure. template <typename V> class dpsites_fwd_piter : public internal::site_relative_iterator_base< V, dpsites_fwd_piter<V> > { public: - /*! \brief Constructor. - * - * \param[in] v Object that can provide an array of delta-points. - * \param[in] c Center point to iterate around. - */ + /// Constructor. + /// + /// \param[in] v Object that can provide an array of delta-points. + /// \param[in] c Center point to iterate around. template <typename P> dpsites_fwd_piter(const V& v, const P& c); @@ -76,6 +74,10 @@ namespace mln /// Go to the next point. void do_next_(); + /// Set the reference psite. + template <typename Pref> + void center_at_(const Pref&); + /// Compute the current psite. mln_psite(V) compute_p_() const; @@ -85,23 +87,21 @@ namespace mln }; - /*! \brief A generic backward iterator on points of windows and of - * neighborhoods. - * - * The parameter \c V is the type of std::vector enclosing - * structure. - */ + /// A generic backward iterator on points of windows and of + /// neighborhoods. + /// + /// The parameter \c V is the type of std::vector enclosing + /// structure. template <typename V> class dpsites_bkd_piter : public internal::site_relative_iterator_base< V, dpsites_bkd_piter<V> > { public: - /*! \brief Constructor. - * - * \param[in] v Object that can provide an array of delta-points. - * \param[in] c Center point to iterate around. - */ + /// Constructor. + /// + /// \param[in] v Object that can provide an array of delta-points. + /// \param[in] c Center point to iterate around. template <typename P> dpsites_bkd_piter(const V& v, const P& c); @@ -120,6 +120,10 @@ namespace mln /// Go to the next point. void do_next_(); + /// Set the reference psite. + template <typename Pref> + void center_at_(const Pref&); + /// Compute the current psite. mln_psite(V) compute_p_() const; @@ -183,6 +187,14 @@ namespace mln } template <typename V> + template <typename Pref> + inline + void + dpsites_fwd_piter<V>::center_at_(const Pref&) + { + } + + template <typename V> inline mln_psite(V) dpsites_fwd_piter<V>::compute_p_() const @@ -241,6 +253,14 @@ namespace mln } template <typename V> + template <typename Pref> + inline + void + dpsites_bkd_piter<V>::center_at_(const Pref&) + { + } + + template <typename V> inline mln_psite(V) dpsites_bkd_piter<V>::compute_p_() const diff --git a/milena/mln/core/image/complex_neighborhood_piter.hh b/milena/mln/core/image/complex_neighborhood_piter.hh index 6c44649..f69455c 100644 --- a/milena/mln/core/image/complex_neighborhood_piter.hh +++ b/milena/mln/core/image/complex_neighborhood_piter.hh @@ -41,9 +41,7 @@ internal::site_relative_iterator_base? I might duplicate things, since most of the implementation of this iterator is delegated to the underlying complex iter. Moreover, change_target_() is - useless, and center_at() ``hides'' an existing method in (one of) - the super class(es) which is not sound, IMHO. Think about - introducing base class replacement. */ + useless. Think about introducing base class replacement. */ namespace mln @@ -53,7 +51,7 @@ namespace mln | complex_neighborhood_fwd_piter<I, G, N>. | `------------------------------------------*/ - /// \brief Forward iterator on complex neighborhood. + /// Forward iterator on complex neighborhood. template <typename I, typename G, typename N> class complex_neighborhood_fwd_piter : public internal::site_relative_iterator_base< N, @@ -90,16 +88,13 @@ namespace mln void do_next_(); /// Set the reference psite. - /* FIXME: Careful, this method overrides the (non virtual) method - internal::site_relative_iterator_base<S, E>::center_at. See - FIXME above. */ template <typename Pref> - void center_at(const Pref& c); + void center_at_(const Pref& c); /// Compute the current psite. psite compute_p_() const; /// \} - /// \brief Accessors. + /// Accessors. /// \{ const iter_type& iter() const; iter_type& iter(); @@ -122,7 +117,7 @@ namespace mln | complex_neighborhood_bkd_piter<I, G, N>. | `------------------------------------------*/ - /// \brief Backward iterator on complex neighborhood. + /// Backward iterator on complex neighborhood. template <typename I, typename G, typename N> class complex_neighborhood_bkd_piter : public internal::site_relative_iterator_base< N, @@ -159,16 +154,14 @@ namespace mln void do_next_(); /// Set the reference psite. - /* FIXME: Careful, this method overrides the (non virtual) method - internal::site_relative_iterator_base<S, E>::center_at. See - FIXME above. */ template <typename Pref> - void center_at(const Pref& c); + void center_at_(const Pref&); + /// Compute the current psite. psite compute_p_() const; /// \} - /// \brief Accessors. + /// Accessors. /// \{ const iter_type& iter() const; iter_type& iter(); @@ -207,7 +200,7 @@ namespace mln const Pref& p_ref) { this->change_target(exact(nbh)); - center_at(p_ref); + this->center_at(p_ref); mln_postcondition(!this->is_valid()); } @@ -247,9 +240,8 @@ namespace mln template <typename Pref> inline void - complex_neighborhood_fwd_piter<I, G, N>::center_at(const Pref& c) + complex_neighborhood_fwd_piter<I, G, N>::center_at_(const Pref& c) { - super_::center_at(c); iter_.center_at(this->center().face()); } @@ -305,7 +297,7 @@ namespace mln const Pref& p_ref) { this->change_target(exact(nbh)); - center_at(p_ref); + this->center_at(p_ref); mln_postcondition(!this->is_valid()); } @@ -345,9 +337,8 @@ namespace mln template <typename Pref> inline void - complex_neighborhood_bkd_piter<I, G, N>::center_at(const Pref& c) + complex_neighborhood_bkd_piter<I, G, N>::center_at_(const Pref& c) { - super_::center_at(c); iter_.center_at(this->center().face()); } diff --git a/milena/mln/core/image/graph_window_piter.hh b/milena/mln/core/image/graph_window_piter.hh index 86abb4d..a6b29e3 100644 --- a/milena/mln/core/image/graph_window_piter.hh +++ b/milena/mln/core/image/graph_window_piter.hh @@ -39,6 +39,8 @@ namespace mln { + // Forward declaration. + template <typename S, typename I> class p_graph_piter; /// Forward iterator on line graph window. template <typename S, typename W, typename I> @@ -53,10 +55,6 @@ namespace mln /// Associated types /// \{ typedef mln_result(S::fun_t) P; - enum { dim = P::dim }; - - // FIXME: Dummy typedef. - typedef void dpoint; /// \} /// Construction. @@ -80,11 +78,12 @@ namespace mln void do_next_(); /// Set the reference psite. - /* FIXME: Careful, this method overrides the (non virtual) method - internal::site_relative_iterator_base<S, E>::center_at. See - FIXME above. */ template <typename Pref> - void center_at(const Pref& c); + void center_at_(const Pref& c); + + /// Set the reference psite. + template <typename I2> + void center_at_(const p_graph_piter<S, I2>& c); /// Return the graph element pointed by this iterator. const mln_graph_element(S)& element() const; @@ -119,7 +118,7 @@ namespace mln graph_window_piter<S,W,I>::graph_window_piter(const Window<W>& win, const Pref& p_ref) { - center_at(p_ref); + this->center_at(p_ref); this->change_target(exact(win)); mln_postcondition(!this->is_valid()); } @@ -160,9 +159,17 @@ namespace mln template <typename Pref> inline void - graph_window_piter<S, W, I>::center_at(const Pref& c) + graph_window_piter<S, W, I>::center_at_(const Pref& c) + { + iter_.center_at(c.p_hook_()); + } + + template <typename S, typename W, typename I> + template <typename I2> + inline + void + graph_window_piter<S, W, I>::center_at_(const p_graph_piter<S, I2>& c) { - super_::center_at(c); iter_.center_at(c.hook_elt_()); } diff --git a/milena/mln/core/internal/site_relative_iterator_base.hh b/milena/mln/core/internal/site_relative_iterator_base.hh index 4438134..c65503f 100644 --- a/milena/mln/core/internal/site_relative_iterator_base.hh +++ b/milena/mln/core/internal/site_relative_iterator_base.hh @@ -56,7 +56,7 @@ namespace mln /// Parameter \c S is the targeted "site set definition" type. It /// can be either a Window, or a Neighborhood. /// - /// IMPORTANT: Sub-classes have to define do_start_, do_next_, + /// IMPORTANT: Sub-classes have to define center_at_, do_start_, do_next_, /// is_valid_, invalidate_ and compute_p_. They shall define /// NEITHER start_ NOR next_. /// @@ -142,6 +142,7 @@ namespace mln mlc_converts_to(P, const mln_psite(S)&)::check(); c_ = & static_cast< const mln_psite(S)& >(c); this->invalidate(); + exact(this)->center_at_(c); } template <typename S, typename E> diff --git a/milena/mln/core/neighb.hh b/milena/mln/core/neighb.hh index f1ebf69..d509af0 100644 --- a/milena/mln/core/neighb.hh +++ b/milena/mln/core/neighb.hh @@ -140,6 +140,10 @@ namespace mln /// Go to the next point. void do_next_(); + /// Do some work while centering the iterator. + template <typename Pref> + void center_at_(const Pref&); + /// Compute the current psite. mln_psite(W) compute_p_() const; @@ -178,6 +182,10 @@ public: /// Go to the next point. void do_next_(); + /// Do some work while centering the iterator. + template <typename Pref> + void center_at_(const Pref&); + /// Compute the current psite. mln_psite(W) compute_p_() const; @@ -310,6 +318,14 @@ protected: } template <typename W> + template <typename Pref> + inline + void + neighb_fwd_niter<W>::center_at_(const Pref&) + { + } + + template <typename W> inline mln_psite(W) neighb_fwd_niter<W>::compute_p_() const @@ -370,6 +386,14 @@ protected: } template <typename W> + template <typename Pref> + inline + void + neighb_bkd_niter<W>::center_at_(const Pref&) + { + } + + template <typename W> inline mln_psite(W) neighb_bkd_niter<W>::compute_p_() const -- 1.5.6.5