26 #ifndef MLN_CORE_IMAGE_IMORPH_DECORATED_IMAGE_HH
27 # define MLN_CORE_IMAGE_IMORPH_DECORATED_IMAGE_HH
29 # include <mln/core/internal/image_identity.hh>
31 # include <mln/value/proxy.hh>
42 template <
typename I,
typename D>
struct decorated_image;
48 template <
typename I,
typename E>
49 struct decorated_image_impl_
53 void write_(
const mln_psite(I)& p,
const mln_value(I)& v);
56 template <
typename I,
typename E>
57 struct decorated_image_impl_< const I, E >
63 template <
typename I,
typename D>
64 struct data< decorated_image<I,D> >
66 data(I& ima,
const D& deco);
80 template <
typename I,
typename D>
82 public internal::decorated_image_impl_< I, decorated_image<I,D> >,
83 public internal::image_identity< I, mln_domain(I), decorated_image<I,D> >
87 typedef internal::decorated_image_impl_< I, self_ > impl_;
102 void init_(I& ima, const D& deco);
111 rvalue operator()(const psite& p) const;
114 lvalue operator()(const psite& p);
117 rvalue read_(const mln_psite(I)& p) const;
131 template <typename I, typename D>
133 const D& decoration);
135 template <typename I, typename D>
137 const D& decoration);
141 # ifndef MLN_INCLUDE_ONLY
147 template <
typename I,
typename D>
159 template <
typename I,
typename D>
165 template <
typename I,
typename D>
169 mln_precondition(exact(ima).is_valid());
170 this->data_ =
new internal::data< decorated_image<I,D> >(ima, deco);
173 template <
typename I,
typename D>
176 decorated_image<I,D>::init_(I& ima,
const D& deco)
178 mln_precondition(exact(ima).is_valid());
179 this->data_ =
new internal::data<decorated_image<I,D> >(ima, deco);
182 template <
typename I,
typename D>
184 decorated_image<I,D>::~decorated_image()
186 void (D::*mr)(
const I&,
const mln_psite(I)&)
const = & D::reading;
188 typedef mlc_unconst(I) I_;
189 void (D::*mw)(I_&, const mln_psite(I_)&, const mln_value(I_)&) =
194 template <typename I, typename D>
199 mln_precondition(this->delegatee_() != 0);
203 template <
typename I,
typename D>
208 mln_precondition(this->delegatee_() != 0);
213 template <
typename I,
typename D>
218 this->data_->deco_.reading(this->data_->ima_, p);
219 return this->data_->ima_(p);
224 template <
typename I,
typename E>
227 decorated_image_impl_<I,E>::write_(
const mln_psite(I)& p,
228 const mln_value(I)& v)
230 E& ima = internal::force_exact<E>(*this);
231 ima.
decoration().writing(*ima.delegatee_(), p, v);
232 (*ima.delegatee_())(p) = v;
237 template <
typename I,
typename D>
246 template <
typename I,
typename D>
251 return this->data_->deco_;
254 template <
typename I,
typename D>
259 return this->data_->deco_;
264 template <
typename I,
typename D>
273 template <
typename I,
typename D>
275 decorated_image<const I, D> decorate(
const Image<I>& ima,
278 decorated_image<const I, D> tmp(exact(ima), decoration);
282 # endif // ! MLN_INCLUDE_ONLY
287 #endif // ! MLN_CORE_IMAGE_IMORPH_DECORATED_IMAGE_HH