26 #ifndef MLN_CORE_CONCEPT_PSEUDO_SITE_HH
27 # define MLN_CORE_CONCEPT_PSEUDO_SITE_HH
37 # include <mln/core/concept/site_proxy.hh>
38 # include <mln/metal/is_a.hh>
46 template <
typename E>
struct Pseudo_Site;
73 bool has_target()
const;
86 template <
typename O,
typename T>
92 # ifndef MLN_INCLUDE_ONLY
96 Pseudo_Site<E>::Pseudo_Site()
98 typedef mln_target(E) target;
100 void (E::*m1)(const target&) = & E::change_target;
102 const target* (E::*m2)() const = & E::target_;
106 template <typename E>
109 Pseudo_Site<E>::has_target()
const
111 return exact(
this)->target_() != 0;
116 namespace if_possible
122 template <
bool b>
struct helper;
125 struct helper< true >
128 template <
typename P>
129 void change_target(Pseudo_Site<P>& p,
130 const mln_target(P)& new_target)
const
132 exact(p).change_target(new_target);
135 template <
typename O,
typename D>
136 void change_target(Object<O>&,
const D&)
const
144 struct helper< false >
146 template <
typename O,
typename D>
147 void change_target(O&,
const D&)
const
156 template <
typename O,
typename D>
157 void change_target(O& o,
const D& d)
159 enum { is_object = mlc_is_a(O, Object)::
value };
160 mln::if_possible::internal::helper< is_object >().change_target(exact(o),
166 # endif // ! MLN_INCLUDE_ONLY
171 #endif // ! MLN_CORE_CONCEPT_PSEUDO_SITE_HH