27 #ifndef MLN_CORE_IMAGE_DMORPH_EXTENSION_FUN_HH
28 # define MLN_CORE_IMAGE_DMORPH_EXTENSION_FUN_HH
38 # include <mln/core/internal/image_identity.hh>
46 template <
typename I,
typename F>
class extension_fun;
53 template <
typename I,
typename F>
54 struct data< extension_fun<I, F> >
56 data(I& ima,
const F& fun);
68 template <
typename I,
typename F>
69 struct image_< extension_fun<I, F> > : image_< I >
72 typedef trait::image::category::identity_morpher category;
73 typedef mln_internal_trait_image_speed_from(I) speed;
74 typedef trait::image::value_access::indirect value_access;
77 typedef trait::image::ext_domain::infinite ext_domain;
78 typedef trait::image::ext_value::multiple ext_value;
79 typedef trait::image::ext_io::read_only ext_io;
82 template <typename I, typename F, typename V>
83 struct ch_value< extension_fun<I, F>, V >
85 typedef mlc_converts_to(mln_result(F), V) keep_ext;
86 typedef mln_ch_value(I, V) Iv;
87 typedef extension_fun<Iv, F> Iv_ext;
88 typedef mlc_if(keep_ext, Iv_ext, Iv) ret;
99 template <typename I, typename F>
101 : public internal::image_identity< I, mln_domain(I),
extension_fun<I, F> >,
102 private mlc_converts_to(mln_result(F), mln_value(I))::check_t
124 void init_(I& ima, const F& fun);
130 template <typename P>
131 bool has(const P& p) const;
135 mln_value(I) operator()(const mln_psite(I)& p) const;
138 mln_morpher_lvalue(I) operator()(const mln_psite(I)& p);
142 const F& extension() const;
148 template <typename I, typename F, typename J>
149 void init_(tag::image_t,
extension_fun<I,F>& target, const J& model);
151 template <typename F, typename I>
152 void init_(tag::extension_t, F& target, const
extension_fun<I,F>& model);
157 # ifndef MLN_INCLUDE_ONLY
164 template <
typename I,
typename F>
177 template <
typename I,
typename F>
183 template <
typename I,
typename F>
190 template <
typename I,
typename F>
195 this->data_ =
new internal::data< extension_fun<I, F> >(ima, fun);
198 template <
typename I,
typename F>
199 template <
typename P>
207 template <
typename I,
typename F>
212 mln_precondition(this->is_valid());
215 if (this->data_->ima_.domain().has(p))
216 return this->data_->ima_(p);
218 return this->data_->fun_(p);
221 template <
typename I,
typename F>
223 mln_morpher_lvalue(I)
226 static mln_value(I) cpy;
227 mln_precondition(this->is_valid());
229 if (this->data_->ima_.domain().has(p))
230 return this->data_->ima_(p);
236 cpy = this->data_->fun_(p);
241 template <
typename I,
typename F>
246 mln_precondition(this->is_valid());
247 return this->data_->fun_;
253 template <
typename I,
typename F,
typename J>
257 init_(tag::image, ima, model);
259 init_(tag::extension, fun, model);
260 target.init_(ima, fun);
263 template <
typename F,
typename I>
264 void init_(tag::extension_t, F& target,
const extension_fun<I,F>& model)
266 target = model.extension();
269 # endif // ! MLN_INCLUDE_ONLY
274 #endif // ! MLN_CORE_IMAGE_DMORPH_EXTENSION_FUN_HH