2648: Use complex_iterator_base to factor iterators' implementations.

* mln/topo/internal/complex_set_iterator_base.hh, * mln/topo/internal/complex_relative_iterator_base.hh (complex_set_iterator_base<F, E>) (complex_relative_iterator_base<F, E>): Inherit from mln::topo::internal::complex_iterator_base<F, E>. (complex_set_iterator_base<F, E>::face) (complex_relative_iterator_base<F, E>::face) (complex_set_iterator_base<F, E>::operator const face_type&) (complex_relative_iterator_base<F, E>::operator const face_type&) (complex_set_iterator_base<F, E>::f_) (complex_relative_iterator_base<F, E>::f_) (operator<<(ostream&, const complex_set_iterator_base<F,E>&)) (operator<<(ostream&, const complex_relative_iterator_base<F,E>&)): Remove. Adjust other methods. * mln/geom/complex_geometry.hh (mln::geom::internal::complex_geometry_data<P>::zero_faces): Rename attribute as... (mln::geom::internal::complex_geometry_data<P>::zero_faces_geom): ...this. Use a more meaningful (though equivalent) type. (mln::geom::complex_geometry<D, P>::add_location): Adjust. (mln::geom::complex_geometry<D, P>::operator()): Likewise. Catch up with mln::topo::internal::complex_iterator_base<F, E>'s interface. --- milena/ChangeLog | 30 +++++++++ milena/mln/geom/complex_geometry.hh | 12 ++-- .../internal/complex_relative_iterator_base.hh | 61 +---------------- .../mln/topo/internal/complex_set_iterator_base.hh | 69 ++----------------- 4 files changed, 47 insertions(+), 125 deletions(-) diff --git a/milena/ChangeLog b/milena/ChangeLog index d10e7be..18a1f8d 100644 --- a/milena/ChangeLog +++ b/milena/ChangeLog @@ -1,5 +1,35 @@ 2008-10-22 Roland Levillain <roland@lrde.epita.fr> + Use complex_iterator_base to factor iterators' implementations. + + * mln/topo/internal/complex_set_iterator_base.hh, + * mln/topo/internal/complex_relative_iterator_base.hh + (complex_set_iterator_base<F, E>) + (complex_relative_iterator_base<F, E>): + Inherit from mln::topo::internal::complex_iterator_base<F, E>. + (complex_set_iterator_base<F, E>::face) + (complex_relative_iterator_base<F, E>::face) + (complex_set_iterator_base<F, E>::operator const face_type&) + (complex_relative_iterator_base<F, E>::operator const face_type&) + (complex_set_iterator_base<F, E>::f_) + (complex_relative_iterator_base<F, E>::f_) + (operator<<(ostream&, const complex_set_iterator_base<F,E>&)) + (operator<<(ostream&, const complex_relative_iterator_base<F,E>&)): + Remove. + Adjust other methods. + * mln/geom/complex_geometry.hh + (mln::geom::internal::complex_geometry_data<P>::zero_faces): + Rename attribute as... + (mln::geom::internal::complex_geometry_data<P>::zero_faces_geom): + ...this. + Use a more meaningful (though equivalent) type. + (mln::geom::complex_geometry<D, P>::add_location): Adjust. + (mln::geom::complex_geometry<D, P>::operator()): Likewise. + Catch up with mln::topo::internal::complex_iterator_base<F, E>'s + interface. + +2008-10-22 Roland Levillain <roland@lrde.epita.fr> + Add a top-level class factoring iterators on complexes. * mln/topo/internal/complex_iterator_base.hh: New. diff --git a/milena/mln/geom/complex_geometry.hh b/milena/mln/geom/complex_geometry.hh index 1634a65..18ed6da 100644 --- a/milena/mln/geom/complex_geometry.hh +++ b/milena/mln/geom/complex_geometry.hh @@ -121,7 +121,7 @@ namespace mln template <typename P> struct complex_geometry_data { - util::multi_site<P> zero_faces; + std::vector<P> zero_faces_geom; }; } @@ -143,8 +143,8 @@ namespace mln { mln_precondition(data_); // FIXME: These two lines are not thread safe. - data_->zero_faces.push_back(p); - return data_->zero_faces.size(); + data_->zero_faces_geom.push_back(p); + return data_->zero_faces_geom.size(); } template <unsigned D, typename P> @@ -158,8 +158,8 @@ namespace mln if (f.n() == 0) { // F is a 0-face. - mln_assertion(f.face_id() < data_->zero_faces.size()); - s.push_back(data_->zero_faces[f.face_id()]); + mln_assertion(f.face_id() < data_->zero_faces_geom.size()); + s.push_back(data_->zero_faces_geom[f.face_id()]); } else { @@ -167,7 +167,7 @@ namespace mln Compute the set of 0-faces transitively adjacent to F. */ topo::adj_m_face_fwd_iter<D> g(f, 0); for_all(g) - s.push_back(data_->zero_faces[g.face().face_id()]); + s.push_back(data_->zero_faces_geom[g.subject().face_id()]); } return s; } diff --git a/milena/mln/topo/internal/complex_relative_iterator_base.hh b/milena/mln/topo/internal/complex_relative_iterator_base.hh index 16b913b..630f0f0 100644 --- a/milena/mln/topo/internal/complex_relative_iterator_base.hh +++ b/milena/mln/topo/internal/complex_relative_iterator_base.hh @@ -45,20 +45,12 @@ | backward_complex_relative_iterator_base<F, E> - \endverbatim + \endverbatim */ -# include <iosfwd> - # include <vector> -# include <mln/metal/equal.hh> - -# include <mln/core/concept/iterator.hh> -# include <mln/topo/complex.hh> - -/* FIXME: Introduce a common factoring class for this class and for - complex_set_iterator_base? */ +# include <mln/topo/internal/complex_iterator_base.hh> /* FIXME: By moving iterator `i_' into internal::complex_relative_iterator_base, we'll be able to factor @@ -85,7 +77,7 @@ namespace mln /// \arg \p F The type of the face handle. /// \arg \p E The type exact type of the iterator. template <typename F, typename E> - class complex_relative_iterator_base : public Iterator<E> + class complex_relative_iterator_base : public complex_iterator_base<F, E> { typedef complex_relative_iterator_base<F, E> self_; @@ -111,16 +103,6 @@ namespace mln void next_(); /// \} - /// \brief Conversion. - /// - /// Return a reference to the corresponding face handle. - /// \{ - /// Explicit conversion (accessor). - const face_type& face() const; - /// Implicit conversion (conversion operator). - operator const face_type&() const; - /// \} - protected: /// A pointer to the center face around which this iterator /// moves. @@ -130,22 +112,9 @@ namespace mln typedef std::vector<face_type> adj_faces_t; /// The set of faces adjacent to the reference face. adj_faces_t adj_faces_; - - /// The face handle this iterator is pointing to. - face_type f_; }; - /* 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 F, typename E> - inline - std::ostream& - operator<<(std::ostream& ostr, - const complex_relative_iterator_base<F, E>& p); - /*---------------------------------------------------------------. | topo::internal::forward_complex_relative_iterator_base<F, E>. | @@ -307,30 +276,6 @@ namespace mln exact(this)->update_f_(); } - template <typename F, typename E> - inline - const F& - complex_relative_iterator_base<F, E>::face() const - { - return f_; - } - - template <typename F, typename E> - inline - complex_relative_iterator_base<F, E>::operator const face_type&() const - { - return f_; - } - - - template <typename F, typename E> - inline - std::ostream& - operator<<(std::ostream& ostr, - const complex_relative_iterator_base<F, E>& p) - { - return ostr << F(p); - } /*---------------------------------------------------------------. diff --git a/milena/mln/topo/internal/complex_set_iterator_base.hh b/milena/mln/topo/internal/complex_set_iterator_base.hh index 6a7588d..c04f5cd 100644 --- a/milena/mln/topo/internal/complex_set_iterator_base.hh +++ b/milena/mln/topo/internal/complex_set_iterator_base.hh @@ -30,17 +30,9 @@ /// \file mln/topo/internal/complex_set_iterator_base.hh /// \brief Definition of an implementation (factoring) class for -/// iterators on faces of a complex. +/// (set) iterators on faces of a complex. -# include <iosfwd> - -# include <mln/metal/equal.hh> - -# include <mln/core/concept/iterator.hh> -# include <mln/topo/complex.hh> - -/* FIXME: Introduce a common factoring class for this class and for - complex_relative_iterator_base? */ +# include <mln/topo/internal/complex_iterator_base.hh> namespace mln @@ -51,12 +43,12 @@ namespace mln namespace internal { - /// \brief Factoring class for iterators on mln::complex. + /// \brief Factoring class for (set) iterators on mln::complex. /// /// \arg \p F The type of the face handle. /// \arg \p E The type exact type of the iterator. template <typename F, typename E> - class complex_set_iterator_base : public Iterator<E> + class complex_set_iterator_base : public complex_iterator_base<F, E> { typedef complex_set_iterator_base<F, E> self_; @@ -86,30 +78,9 @@ namespace mln /// Invalidate the iterator. void invalidate(); /// \} - - /// \brief Conversion. - /// - /// Return a reference to the corresponding face handle. - /// \{ - /// Explicit conversion (accessor). - const face_type& face() const; - /// Implicit conversion (conversion operator). - operator const face_type&() const; - /// \} - - protected: - /// The face handle this iterator is pointing to. - face_type f_; }; - /// Print an mln::topo::internal::complex_set_iterator_base. - template <typename F, typename E> - inline - std::ostream& - operator<<(std::ostream& ostr, const complex_set_iterator_base<F, E>& p); - - # ifndef MLN_INCLUDE_ONLY @@ -124,7 +95,7 @@ namespace mln inline complex_set_iterator_base<F, E>::complex_set_iterator_base(complex_type& c) { - f_.set_cplx(c); + this->f_.set_cplx(c); // Invalidate f_. invalidate(); } @@ -134,7 +105,7 @@ namespace mln void complex_set_iterator_base<F, E>::set_cplx(complex_type& c) { - f_.set_cplx(c); + this->f_.set_cplx(c); // Invalidate f_. invalidate(); } @@ -144,7 +115,7 @@ namespace mln bool complex_set_iterator_base<F, E>::is_valid() const { - return f_.is_valid(); + return this->f_.is_valid(); } template <typename F, typename E> @@ -152,31 +123,7 @@ namespace mln void complex_set_iterator_base<F, E>::invalidate() { - f_.invalidate(); - } - - template <typename F, typename E> - inline - const F& - complex_set_iterator_base<F, E>::face() const - { - return f_; - } - - template <typename F, typename E> - inline - complex_set_iterator_base<F, E>::operator const face_type&() const - { - return f_; - } - - - template <typename F, typename E> - inline - std::ostream& - operator<<(std::ostream& ostr, const complex_set_iterator_base<F, E>& p) - { - return ostr << F(p); + this->f_.invalidate(); } # endif // ! MLN_INCLUDE_ONLY -- 1.5.6.5
participants (1)
-
Roland Levillain