2358: Update relative iterators on graph image vicinity.

* mln/core/internal/graph_vicinity_piter.hh (mln::internal::graph_vicinity_piter_<P, S, E>): Take and additional parameter S. Inherit from internal::site_relative_iterator_base. Adjust. (graph_vicinity_piter_<P, S, E>::graph_vicinity_piter_): New default ctor. Adjust other ctor. (mln::internal::graph_vicinity_piter_<P, S, E>::self_) (mln::internal::graph_vicinity_piter_<P, S, E>::super_) (mln::internal::graph_vicinity_piter_<P, S, E>::psite) (mln::internal::graph_vicinity_piter_<P, S, E>::point) (mln::internal::graph_vicinity_piter_<P, S, E>::coord): Remove typedefs. (mln::internal::graph_vicinity_piter_<P, S, E>::to_point) (mln::internal::graph_vicinity_piter_<P, S, E>::to_psite) (mln::internal::graph_vicinity_piter_<P, S, E>::operator psite) (mln::internal::graph_vicinity_piter_<P, S, E>::p_ref) (mln::internal::graph_vicinity_piter_<P, S, E>::pg) (mln::internal::graph_vicinity_piter_<P, S, E>::operator[]): Remove methods. (mln::internal::graph_vicinity_piter_<P, S, E>::p_ref_) (mln::internal::graph_vicinity_piter_<P, S, E>::saved_p_ref_) (mln::internal::graph_vicinity_piter_<P, S, E>::psite_) (mln::internal::graph_vicinity_piter_<P, S, E>::p_): Remove attributes. (operator<<(std::ostream&, const graph_vicinity_piter_<P, E>&_)): Adjust, turn into... (operator<<(std::ostream&, const graph_vicinity_piter_<P, S, E>&_)): ...this. Adjust. --- milena/ChangeLog | 36 ++++++ milena/mln/core/internal/graph_vicinity_piter.hh | 144 +++++----------------- 2 files changed, 65 insertions(+), 115 deletions(-) diff --git a/milena/ChangeLog b/milena/ChangeLog index ee2ec1b..e450700 100644 --- a/milena/ChangeLog +++ b/milena/ChangeLog @@ -1,5 +1,41 @@ 2008-09-22 Roland Levillain <roland@lrde.epita.fr> + Update relative iterators on graph image vicinity. + + * mln/core/internal/graph_vicinity_piter.hh + (mln::internal::graph_vicinity_piter_<P, S, E>): Take and + additional parameter S. + Inherit from internal::site_relative_iterator_base. + Adjust. + (graph_vicinity_piter_<P, S, E>::graph_vicinity_piter_): + New default ctor. + Adjust other ctor. + (mln::internal::graph_vicinity_piter_<P, S, E>::self_) + (mln::internal::graph_vicinity_piter_<P, S, E>::super_) + (mln::internal::graph_vicinity_piter_<P, S, E>::psite) + (mln::internal::graph_vicinity_piter_<P, S, E>::point) + (mln::internal::graph_vicinity_piter_<P, S, E>::coord): + Remove typedefs. + (mln::internal::graph_vicinity_piter_<P, S, E>::to_point) + (mln::internal::graph_vicinity_piter_<P, S, E>::to_psite) + (mln::internal::graph_vicinity_piter_<P, S, E>::operator psite) + (mln::internal::graph_vicinity_piter_<P, S, E>::p_ref) + (mln::internal::graph_vicinity_piter_<P, S, E>::pg) + (mln::internal::graph_vicinity_piter_<P, S, E>::operator[]): + Remove methods. + (mln::internal::graph_vicinity_piter_<P, S, E>::p_ref_) + (mln::internal::graph_vicinity_piter_<P, S, E>::saved_p_ref_) + (mln::internal::graph_vicinity_piter_<P, S, E>::psite_) + (mln::internal::graph_vicinity_piter_<P, S, E>::p_): + Remove attributes. + (operator<<(std::ostream&, const graph_vicinity_piter_<P, E>&_)): + Adjust, turn into... + (operator<<(std::ostream&, const graph_vicinity_piter_<P, S, E>&_)): + ...this. + Adjust. + +2008-09-22 Roland Levillain <roland@lrde.epita.fr> + Update iterators on mln::p_graph. * mln/core/site_set/p_graph_piter.hh diff --git a/milena/mln/core/internal/graph_vicinity_piter.hh b/milena/mln/core/internal/graph_vicinity_piter.hh index 4a53616..b51ab97 100644 --- a/milena/mln/core/internal/graph_vicinity_piter.hh +++ b/milena/mln/core/internal/graph_vicinity_piter.hh @@ -32,46 +32,43 @@ /// \brief Factored implementation for point iterators on a graph windows /// and graph neighborhoods, called "vicinities". +# include <set> + +# include <mln/core/internal/site_relative_iterator_base.hh> +# include <mln/core/site_set/p_graph.hh> +# include <mln/core/image/graph_psite.hh> + /* FIXME: Factor those classes: - mln::internal::graph_vicinity_piter.hh - mln::internal::line_graph_vicinity_piter.hh */ -# include <mln/core/concept/site_iterator.hh> -# include <mln/core/site_set/p_graph.hh> -# include <mln/core/image/graph_psite.hh> - /* FIXME: Due to the poor interface of mln::p_graph and mln::util::graph, we show to much implementation details here. Enrich their interfaces to avoid that. */ + namespace mln { // Fwd decls. template <typename P> class p_graph; template <typename P> class graph_psite; + // FIXME: Consider renaming graph_vicinity_piter_ as + // graph_relative_piter_. - /*----------------------------------------. - | internal::graph_vicinity_piter_<P, E>. | - `----------------------------------------*/ namespace internal { /// \brief Base for iterator on a graph vicinity. - template <typename P, typename E> - class graph_vicinity_piter_ : public Site_Iterator< E > + template <typename P, typename S, typename E> + class graph_vicinity_piter_ + : public internal::site_relative_iterator_base< S, E > { - typedef graph_vicinity_piter_<P, E> self_; - typedef Site_Iterator< self_ > super_; - public: enum { dim = P::dim }; - typedef graph_psite<P> psite; - typedef P point; - typedef mln_coord(P) coord; // FIXME: Dummy typedef. typedef void dpoint; // FIXME: Dummy value. @@ -81,145 +78,62 @@ namespace mln typedef std::set<util::vertex_id> sites_t; public: - /// Conversion and accessors. - /// \{ - /// Reference to the corresponding point. - const point& to_point() const; - /// Reference to the corresponding point site. - const psite& to_psite() const; - /// Convert the iterator into a line graph psite. - operator psite() const; - - /// Return the reference psite. - const psite& p_ref() const; - /// Return the mln::p_graph corresponding to this piter. - const p_graph<P>& pg() const; /// Return the set of sites (adjacent vertex ids). sites_t& sites(); - /// Read-only access to the \a i-th coordinate. - coord operator[](unsigned i) const; - /// \} - protected: /// Construction. /// \{ + graph_vicinity_piter_(); template <typename Pref> - graph_vicinity_piter_(const Point_Site<Pref>& p_ref); - /// \} - - /// Internals, used by the vicinity. - /// \{ - public: - /// An internal iterator on the set of vertices of the underlying graph. - util::vertex_id id_; + graph_vicinity_piter_(const Pref& p_ref); /// \} protected: - /// The ``central'' psite of the vicinity (for instance, the - /// center of the neighborhood, in the case of a neighborhood - /// piter). - const psite& p_ref_; - - /// The last reference psite whose ajacent psites have been computed. - psite saved_p_ref_; /// The set of edge ids adjacent to the reference psite. sites_t sites_; - - /// The psite corresponding to this iterator. - psite psite_; - /// The point corresponding to this iterator. - point p_; }; - /* FIXME: This hand-made delegation is painful. We should rely on - the general mechanism provided by Point_Site. But then again, we - need to refine/adjust the interface of Point_Site w.r.t. the - mandatory conversions to points. */ - template <typename P, typename E> + + /// Print an mln::line_graph_vicinity_piter_<P, S, E>. + template <typename P, typename S, typename E> inline std::ostream& - operator<<(std::ostream& ostr, const graph_vicinity_piter_<P, E>& p); + operator<<(std::ostream& ostr, const graph_vicinity_piter_<P, S, E>& p); # ifndef MLN_INCLUDE_ONLY - template <typename P, typename E> - template <typename Pref> + template <typename P, typename S, typename E> inline - graph_vicinity_piter_<P, E>::graph_vicinity_piter_(const Point_Site<Pref>& p_ref) - : p_ref_(exact(p_ref).to_psite()), - // Initialize psite_ to a dummy value. - psite_(), - p_() + graph_vicinity_piter_<P, S, E>::graph_vicinity_piter_() { } - template <typename P, typename E> - inline - const P& - graph_vicinity_piter_<P, E>::to_point() const - { - return p_; - } - - template <typename P, typename E> - inline - const graph_psite<P>& - graph_vicinity_piter_<P, E>::to_psite() const - { - return psite_; - } - - template <typename P, typename E> - inline - graph_vicinity_piter_<P, E>::operator graph_psite<P>() const - { - mln_precondition(exact(*this).is_valid()); - return psite_; - } - - template <typename P, typename E> - inline - const graph_psite<P>& - graph_vicinity_piter_<P, E>::p_ref() const - { - return p_ref_; - } - - template <typename P, typename E> + template <typename P, typename S, typename E> + template <typename Pref> inline - const p_graph<P>& - graph_vicinity_piter_<P, E>::pg() const + graph_vicinity_piter_<P, S, E>::graph_vicinity_piter_(const Pref& p_ref) { - return p_ref_.pg(); + center_at(p_ref); } - template <typename P, typename E> + template <typename P, typename S, typename E> inline std::set<util::vertex_id>& - graph_vicinity_piter_<P, E>::sites() + graph_vicinity_piter_<P, S, E>::sites() { return sites_; } - template <typename P, typename E> - inline - mln_coord(P) - graph_vicinity_piter_<P, E>::operator[](unsigned i) const - { - assert(i < dim); - return p_[i]; - } - - template <typename P, typename E> + template <typename P, typename S, typename E> inline std::ostream& - operator<<(std::ostream& ostr, const graph_vicinity_piter_<P, E>& p) + operator<<(std::ostream& ostr, const graph_vicinity_piter_<P, S, E>& p) { - return ostr << p.to_psite(); + return ostr << p.unproxy_(); } # endif // ! MLN_INCLUDE_ONLY -- 1.5.6.5
participants (1)
-
Roland Levillain