27 #ifndef MLN_CORE_IMAGE_DMORPH_EXTENSION_IMA_HH
28 # define MLN_CORE_IMAGE_DMORPH_EXTENSION_IMA_HH
35 # include <mln/core/internal/image_identity.hh>
43 template <
typename I,
typename J>
class extension_ima;
50 template <
typename I,
typename J>
51 struct data< extension_ima<I, J> >
53 data(I& ima,
const J& ext);
65 template <
typename I,
typename J>
66 struct image_< extension_ima<I, J> > : image_< I >
69 typedef trait::image::category::identity_morpher category;
70 typedef mln_internal_trait_image_speed_from(I) speed;
71 typedef trait::image::value_access::indirect value_access;
74 typedef trait::image::ext_domain::extendable ext_domain;
75 typedef trait::image::ext_value::multiple ext_value;
76 typedef trait::image::ext_io::read_only ext_io;
79 template <typename I, typename J, typename V>
80 struct ch_value< extension_ima<I, J>, V >
82 typedef mlc_converts_to(mln_value(J), V) keep_ext;
83 typedef mln_ch_value(I, V) Iv;
84 typedef extension_ima<Iv, J> Iv_ext;
85 typedef mlc_if(keep_ext, Iv_ext, Iv) ret;
96 template <typename I, typename J>
99 : public internal::image_identity< I, mln_domain(I),
extension_ima<I, J> >,
100 private mlc_converts_to(mln_value(J), mln_value(I))::check_t
121 void init_(I& ima, const J& ext);
126 template <typename P>
127 bool has(const P& p) const;
131 mln_value(I) operator()(const mln_psite(I)& p) const;
134 mln_morpher_lvalue(I) operator()(const mln_psite(I)& p);
138 const J& extension() const;
144 template <typename I, typename J, typename M>
145 void init_(tag::image_t,
extension_ima<I,J>& target, const M& model);
147 template <typename J, typename I>
148 void init_(tag::extension_t, J& target, const
extension_ima<I,J>& model);
152 # ifndef MLN_INCLUDE_ONLY
159 template <
typename I,
typename J>
163 ext_(const_cast<J&>(ext))
171 template <
typename I,
typename J>
177 template <
typename I,
typename J>
184 template <
typename I,
typename J>
189 this->data_ =
new internal::data< extension_ima<I, J> >(ima, ext);
192 template <
typename I,
typename J>
193 template <
typename P>
198 mln_precondition(this->is_valid());
199 mln_precondition(this->data_->ext_.is_valid());
201 this->data_->ima_.domain().has(p)
202 || this->data_->ext_.has(p);
205 template <
typename I,
typename J>
210 mln_precondition(this->is_valid());
211 mln_precondition(has(p));
214 if (this->data_->ima_.domain().has(p))
215 return this->data_->ima_(p);
217 return this->data_->ext_(p);
220 template <
typename I,
typename J>
222 mln_morpher_lvalue(I)
225 static mln_value(I) cpy;
226 mln_precondition(this->is_valid());
227 mln_precondition(has(p));
229 if (this->data_->ima_.domain().has(p))
230 return this->data_->ima_(p);
236 cpy = this->data_->ext_(p);
241 template <
typename I,
typename J>
246 mln_precondition(this->is_valid());
247 return this->data_->ext_;
252 template <
typename I,
typename J,
typename M>
257 init_(tag::image, ima, model);
259 init_(tag::extension, ext, model);
260 target.init_(ima, ext);
263 template <
typename J,
typename I>
265 void init_(tag::extension_t, J& target,
const extension_ima<I,J>& model)
267 typedef mlc_unconst(J) J_;
268 J_& ext_ = const_cast<J_&>(model.extension());
269 J_& target_ = const_cast<J_&>(target);
273 # endif // ! MLN_INCLUDE_ONLY
278 #endif // ! MLN_CORE_IMAGE_DMORPH_EXTENSION_IMA_HH