27 #ifndef MLN_CORE_INTERNAL_SITE_RELATIVE_ITERATOR_BASE_HH
28 # define MLN_CORE_INTERNAL_SITE_RELATIVE_ITERATOR_BASE_HH
40 # include <mln/core/internal/site_iterator_base.hh>
41 # include <mln/metal/converts_to.hh>
60 template <
typename S,
typename E,
typename C = mln_psite(S)>
61 class site_relative_iterator_base :
public site_iterator_base< S, E >
66 site_relative_iterator_base();
69 void center_at(
const P& c);
82 const C& center()
const;
89 const mln_psite(S)& subj_();
92 const mln_psite(S)& p_hook_()
const;
95 void change_target(
const S& s);
114 template <
typename P>
115 void center_at_(
const P& c);
123 # ifndef MLN_INCLUDE_ONLY
125 template <
typename S,
typename E,
typename C>
127 site_relative_iterator_base<S,E,C>::site_relative_iterator_base()
130 void (E::*m1)() = & E::do_start_;
132 void (E::*m2)() = & E::do_next_;
134 mln_psite(S) (E::*m3)()
const = & E::compute_p_;
138 template <
typename S,
typename E,
typename C>
139 template <
typename P>
142 site_relative_iterator_base<S,E,C>::center_at(
const P& c)
144 mlc_converts_to(P,
const C&)::check();
145 c_ = &
static_cast< const C&
>(c);
146 exact(
this)->center_at_(c);
150 template <
typename S,
typename E,
typename C>
153 site_relative_iterator_base<S,E,C>::start_()
155 exact(
this)->do_start_();
156 if (this->is_valid())
157 p_ = exact(
this)->compute_p_();
160 template <
typename S,
typename E,
typename C>
163 site_relative_iterator_base<S,E,C>::next_()
165 exact(
this)->do_next_();
166 if (this->is_valid())
167 p_ = exact(
this)->compute_p_();
170 template <
typename S,
typename E,
typename C>
173 site_relative_iterator_base<S,E,C>::center()
const
175 mln_precondition(c_ != 0);
179 template <
typename S,
typename E,
typename C>
182 site_relative_iterator_base<S,E,C>::site_set()
const
184 mln_precondition(this->s_ != 0);
188 template <
typename S,
typename E,
typename C>
191 site_relative_iterator_base<S,E,C>::subj_()
193 mln_assertion(exact(
this)->compute_p_() == p_);
197 template <
typename S,
typename E,
typename C>
200 site_relative_iterator_base<S,E,C>::p_hook_()
const
205 template <
typename S,
typename E,
typename C>
208 site_relative_iterator_base<S,E,C>::change_target(
const S& s)
213 if_possible::change_target(p_, s);
218 template <
typename S,
typename E,
typename C>
221 site_relative_iterator_base<S,E,C>::update()
223 mln_precondition(this->s_ && c_);
224 p_ = exact(
this)->compute_p_();
225 mln_postcondition(this->is_valid());
229 template <
typename S,
typename E,
typename C>
230 template <
typename P>
233 site_relative_iterator_base<S,E,C>::center_at_(
const P&)
238 # endif // ! MLN_INCLUDE_ONLY
245 #endif // ! MLN_CORE_INTERNAL_SITE_RELATIVE_ITERATOR_BASE_HH