27 #ifndef MLN_CORE_INTERNAL_GRAPH_PSITE_BASE_HH
28 # define MLN_CORE_INTERNAL_GRAPH_PSITE_BASE_HH
37 # include <mln/core/internal/pseudo_site_base.hh>
47 template <
typename S,
typename E>
48 class graph_psite_base :
public internal::pseudo_site_base_< const mln_site(S)&,
58 const mln_site(S)& subj_();
60 typedef typename S::graph_element::id_t id_t;
65 void change_target(
const S& new_target);
68 void update_id(
unsigned elt_id);
74 const S* target_()
const;
80 const typename S::graph_t& graph()
const;
88 bool is_valid()
const;
93 operator unsigned ()
const;
96 operator typename S::graph_element::id_t ()
const;
99 operator const typename S::graph_element&()
const;
102 const typename S::graph_element& element()
const;
105 const typename S::graph_element& p_hook_()
const;
115 graph_psite_base(
const S& s);
119 graph_psite_base(
const S& ,
unsigned id);
124 typename S::graph_element elt_;
137 template <typename S, typename E>
139 operator==(const graph_psite_base<S,E>& lhs, const graph_psite_base<S,E>& rhs);
145 template <typename S, typename E>
147 operator!=(const graph_psite_base<S,E>& lhs, const graph_psite_base<S,E>& rhs);
155 template <typename S, typename E>
157 operator< (const graph_psite_base<S,E>& lhs, const graph_psite_base<S,E>& rhs);
163 template <typename S, typename P, typename E>
164 struct subject_impl< const graph_psite_base<S,P>&, E >
166 const S* target_()
const;
168 const typename S::graph_t& graph()
const;
170 bool is_valid()
const;
173 const typename S::graph_element& element()
const;
174 const typename S::graph_element& p_hook_()
const;
177 const E& exact_()
const;
180 template <
typename S,
typename P,
typename E>
181 struct subject_impl< graph_psite_base<S,P>&, E > :
182 subject_impl< const graph_psite_base<S,P>&, E >
184 void change_target(
const S& new_target);
185 void update_id(
unsigned elt_id);
195 # ifndef MLN_INCLUDE_ONLY
198 template <
typename S,
typename E>
200 graph_psite_base<S,E>::graph_psite_base()
205 template <
typename S,
typename E>
207 graph_psite_base<S,E>::graph_psite_base(
const S& s)
212 template <
typename S,
typename E>
214 graph_psite_base<S,E>::graph_psite_base(
const S& s,
unsigned id)
221 template <
typename E,
typename S,
typename G>
223 void local_change_graph(E& elt_, S& site_,
const G& g)
226 elt_.change_graph(g);
228 template <
typename E,
typename G>
230 void local_change_graph(E& elt_, E& site_,
const G& g)
232 elt_.change_graph(g);
233 site_.change_graph(g);
237 template <
typename S,
typename E>
240 graph_psite_base<S,E>::change_target(
const S& new_target)
243 local_change_graph(elt_, site_, new_target.graph());
246 template <
typename S,
typename E>
249 graph_psite_base<S,E>::update_id(
unsigned id)
251 mln_precondition(s_ != 0);
253 site_ = s_->function()(elt_.id());
256 template <
typename S,
typename E>
259 graph_psite_base<S,E>::target_()
const
264 template <
typename S,
typename E>
267 graph_psite_base<S,E>::site_set()
const
269 mln_precondition(s_ != 0);
273 template <
typename S,
typename E>
275 const typename S::graph_t&
276 graph_psite_base<S,E>::graph()
const
278 mln_precondition(s_ != 0);
282 template <
typename S,
typename E>
284 typename graph_psite_base<S,E>::id_t
285 graph_psite_base<S,E>::id()
const
290 template <
typename S,
typename E>
293 graph_psite_base<S,E>::is_valid()
const
295 return s_ != 0 && s_->is_valid() && elt_.is_valid();
298 template <
typename S,
typename E>
301 graph_psite_base<S,E>::invalidate()
307 template <
typename S,
typename E>
310 graph_psite_base<S,E>::subj_()
320 template <
typename S,
typename E>
322 graph_psite_base<S,E>::operator unsigned ()
const
324 mln_precondition(is_valid());
328 template <
typename S,
typename E>
330 graph_psite_base<S,E>::operator
typename S::graph_element::id_t ()
const
332 mln_precondition(is_valid());
336 template <
typename S,
typename E>
338 graph_psite_base<S,E>::operator
const typename S::graph_element&()
const
344 template <
typename S,
typename E>
346 const typename S::graph_element&
347 graph_psite_base<S,E>::element()
const
357 template <
typename S,
typename E>
359 const typename S::graph_element&
360 graph_psite_base<S,E>::p_hook_()
const
366 template <
typename S,
typename P,
typename E>
369 subject_impl< const graph_psite_base<S,P>&, E >::exact_()
const
371 return internal::force_exact<const E>(*this);
374 template <
typename S,
typename P,
typename E>
377 subject_impl< const graph_psite_base<S,P>&, E >::target_()
const
379 return exact_().get_subject().target();
382 template <
typename S,
typename P,
typename E>
385 subject_impl< const graph_psite_base<S,P>&, E >::site_set()
const
387 return exact_().get_subject().site_set();
391 template <
typename S,
typename P,
typename E>
393 const typename S::graph_t&
394 subject_impl< const graph_psite_base<S,P>&, E >::graph()
const
396 return exact_().get_subject().graph();
399 template <
typename S,
typename P,
typename E>
402 subject_impl< const graph_psite_base<S,P>&, E >::id()
const
404 return exact_().get_subject().id();
407 template <
typename S,
typename P,
typename E>
410 subject_impl< const graph_psite_base<S,P>&, E >::is_valid()
const
412 return exact_().get_subject().is_valid();
415 template <
typename S,
typename P,
typename E>
417 const typename S::graph_element&
418 subject_impl< const graph_psite_base<S,P>&, E >::element()
const
420 return exact_().get_subject().element();
423 template <
typename S,
typename P,
typename E>
425 const typename S::graph_element&
426 subject_impl< const graph_psite_base<S,P>&, E >::p_hook_()
const
428 return exact_().get_subject().p_hook_();
432 template <
typename S,
typename P,
typename E>
435 subject_impl< graph_psite_base<S,P>&, E >::exact_()
437 return internal::force_exact<E>(*this);
440 template <
typename S,
typename P,
typename E>
443 subject_impl< graph_psite_base<S,P>&, E >::change_target(
const S& new_target)
445 exact_().get_subject().change_target(new_target);
448 template <
typename S,
typename P,
typename E>
451 subject_impl< graph_psite_base<S,P>&, E >::update_id(
unsigned id)
453 exact_().get_subject().update_id(
id);
456 template <
typename S,
typename P,
typename E>
459 subject_impl< graph_psite_base<S,P>&, E >::invalidate()
461 exact_().get_subject().invalidate();
464 # endif // ! MLN_INCLUDE_ONLY
471 #endif // ! MLN_CORE_INTERNAL_GRAPH_PSITE_BASE_HH