Commit b1f3c0ea authored by Roland Levillain's avatar Roland Levillain
Browse files

Allow iterators to perform extra work while changing their target.

	* mln/core/concept/pseudo_site.hh
	(change_target(Pseudo_Site<P>&, const typename P::target_t&)):
	Remove useless declaration.
	Wrap long lines.
	* mln/core/internal/site_set_iterator_base.hh
	(mln::internal::site_set_iterator_base<S, E>::change_target_):
	New method.
	Call its exact version...
	(mln::internal::site_set_iterator_base<S, E>::change_target):
	...here.

git-svn-id: https://svn.lrde.epita.fr/svn/oln/trunk@4573 4aad255d-cdde-0310-9447-f3009e2ae8c0
parent 5aef4f43
2009-09-29 Roland Levillain <roland@lrde.epita.fr>
Allow iterators to perform extra work while changing their target.
* mln/core/concept/pseudo_site.hh
(change_target(Pseudo_Site<P>&, const typename P::target_t&)):
Remove useless declaration.
Wrap long lines.
* mln/core/internal/site_set_iterator_base.hh
(mln::internal::site_set_iterator_base<S, E>::change_target_):
New method.
Call its exact version...
(mln::internal::site_set_iterator_base<S, E>::change_target):
...here.
2009-09-29 Roland Levillain <roland@lrde.epita.fr>
 
Work around std::vector<bool> specialization in mln::complex_image.
......@@ -79,10 +79,9 @@ namespace mln
namespace if_possible
{
// Nota: This procedure is used in internal::site_iterator_base.
template <typename P>
void change_target(Pseudo_Site<P>& p, const typename P::target_t& new_target);
// Nota: This procedure is used in
// internal::site_set_iterator_base and
// site_relative_iterator_base.
template <typename O, typename T>
void change_target(Object<O>&, const T&);
......@@ -125,9 +124,10 @@ namespace mln
template <>
struct helper< /* is an Object */ true >
{
template <typename P>
void change_target(Pseudo_Site<P>& p, const mln_target(P)& new_target) const
void change_target(Pseudo_Site<P>& p,
const mln_target(P)& new_target) const
{
exact(p).change_target(new_target);
}
......@@ -157,7 +157,8 @@ namespace mln
void change_target(O& o, const D& d)
{
enum { is_object = mlc_is_a(O, Object)::value };
mln::if_possible::internal::helper< is_object >().change_target(exact(o), d);
mln::if_possible::internal::helper< is_object >().change_target(exact(o),
d);
}
} // end of namespace mln::if_possible
......
......@@ -45,7 +45,8 @@ namespace mln
/// Parameter \c S is the targeted site set type.
///
/// IMPORTANT: Sub-classes have to define start_, next_,
/// is_valid_ and invalidate_.
/// is_valid_ and invalidate_. They may also define
/// change_target_.
//
template <typename S, typename E>
class site_set_iterator_base : public site_iterator_base<S, E>
......@@ -64,6 +65,10 @@ namespace mln
/// Change the site set targeted by this iterator.
void change_target(const S& s);
/// Part of the change_target specific to the exact iterator
/// type, empty by default (to be overloaded).
void change_target_(const S& s);
protected:
/// The psite designated by this iterator.
......@@ -100,10 +105,20 @@ namespace mln
// p might be also updated since it can hold a pointer towards
// the set it designates, so:
if_possible::change_target(p_, s);
// Likewise, the iterator might need to update specific data.
exact(this)->change_target_(s);
// Last:
this->invalidate();
}
template <typename S, typename E>
inline
void
site_set_iterator_base<S, E>::change_target_(const S& /* s */)
{
// Empty by default.
}
template <typename S, typename E>
inline
const mln_psite(S)&
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment