27 #ifndef MLN_CORE_IMAGE_IMORPH_DECORATED_IMAGE_HH
28 # define MLN_CORE_IMAGE_IMORPH_DECORATED_IMAGE_HH
30 # include <mln/core/internal/image_identity.hh>
32 # include <mln/value/proxy.hh>
43 template <
typename I,
typename D>
struct decorated_image;
49 template <
typename I,
typename E>
54 void write_(
const mln_psite(I)&
p,
const mln_value(I)& v);
57 template <
typename I,
typename E>
66 template <
typename I,
typename D>
69 data(I& ima,
const D& deco);
83 template <
typename I,
typename D>
106 void init_(I& ima, const D& deco);
116 rvalue operator()(const psite&
p) const;
119 lvalue operator()(const psite&
p);
123 rvalue
read_(const mln_psite(I)& p) const;
138 template <typename I, typename D>
140 const D& decoration);
142 template <typename I, typename D>
144 const D& decoration);
148 # ifndef MLN_INCLUDE_ONLY
152 template <
typename I,
typename D>
159 template <
typename I,
typename D,
typename D2>
165 template <
typename I,
typename D,
typename J>
166 void init_(tag::image_t, decorated_image<I,D>& target,
const J& model)
172 target.init_(ima, d);
180 template <
typename I,
typename D>
192 template <
typename I,
typename D>
194 decorated_image<I,D>::decorated_image()
198 template <
typename I,
typename D>
200 decorated_image<I,D>::decorated_image(I& ima,
const D& deco)
202 mln_precondition(
exact(ima).is_valid());
203 this->data_ =
new internal::data< decorated_image<I,D> >(ima, deco);
206 template <
typename I,
typename D>
209 decorated_image<I,D>::init_(I& ima,
const D& deco)
211 mln_precondition(
exact(ima).is_valid());
212 this->data_ =
new internal::data<decorated_image<I,D> >(ima, deco);
215 template <
typename I,
typename D>
217 decorated_image<I,D>::~decorated_image()
219 void (D::*mr)(
const I&,
const mln_psite(I)&)
const = & D::reading;
221 typedef mlc_unconst(I) I_;
222 void (D::*mw)(I_&, const mln_psite(I_)&, const mln_value(I_)&) =
227 template <typename I, typename D>
229 typename decorated_image<I,D>::rvalue
230 decorated_image<I,D>::operator()(const psite& p)
const
232 mln_precondition(this->delegatee_() != 0);
236 template <
typename I,
typename D>
238 typename decorated_image<I,D>::lvalue
239 decorated_image<I,D>::operator()(
const psite& p)
241 mln_precondition(this->delegatee_() != 0);
243 return lvalue(*
this, p);
246 template <
typename I,
typename D>
249 decorated_image<I,D>::read_(const mln_psite(I)& p)
const
251 this->data_->deco_.reading(this->data_->ima_, p);
252 return this->data_->ima_(p);
257 template <
typename I,
typename E>
260 decorated_image_impl_<I,E>::write_(
const mln_psite(I)& p,
261 const mln_value(I)& v)
263 E& ima = internal::force_exact<E>(*this);
264 ima.decoration().writing(*ima.delegatee_(), p, v);
265 (*ima.delegatee_())(p) = v;
270 template <
typename I,
typename D>
272 decorated_image<I,D>::operator decorated_image<const I, D>()
const
274 decorated_image<const I, D> tmp(this->data_->ima_, this->data_->deco_);
279 template <
typename I,
typename D>
282 decorated_image<I,D>::decoration()
const
284 return this->data_->deco_;
287 template <
typename I,
typename D>
290 decorated_image<I,D>::decoration()
292 return this->data_->deco_;
297 template <
typename I,
typename D>
299 decorated_image<I, D>
decorate(Image<I>& ima,
302 decorated_image<I, D> tmp(
exact(ima), decoration);
306 template <
typename I,
typename D>
308 decorated_image<const I, D>
decorate(
const Image<I>& ima,
311 decorated_image<const I, D> tmp(
exact(ima), decoration);
315 # endif // ! MLN_INCLUDE_ONLY
320 #endif // ! MLN_CORE_IMAGE_IMORPH_DECORATED_IMAGE_HH