27 #ifndef MLN_CORE_IMAGE_VMORPH_THRU_IMAGE_HH
28 # define MLN_CORE_IMAGE_VMORPH_THRU_IMAGE_HH
36 # include <mln/core/internal/image_value_morpher.hh>
37 # include <mln/core/concept/meta_function.hh>
38 # include <mln/metal/bexpr.hh>
39 # include <mln/trait/functions.hh>
46 template <
typename I,
typename F>
class thru_image;
50 template <
typename I,
typename F>
class thru_image_write;
51 template <
typename I,
typename F>
class thru_image_read;
56 template <
typename I,
typename F>
61 typedef mlc_if(mlc_and(mln_trait_fun_is_assignable(F),
62 mlc_and(mlc_not(mlc_is_const(I)),
63 mlc_equal(mln_trait_image_pw_io(I),
64 trait::image::pw_io::read_write))),
71 template <typename I, typename F>
74 data(I& ima,
const F& f);
86 template <
typename I,
typename F>
87 struct image_<
thru_image<I, F> > : image_< typename mln::internal::thru_find_impl<I, F>::ret >
90 typedef trait::image::category::value_morpher
category;
91 typedef mln_internal_trait_image_speed_from(I) speed;
92 typedef trait::image::value_access::computed value_access;
95 template <typename I, typename F>
96 struct image_< mln::internal::thru_image_write<I, F> > : image_< I >
98 typedef trait::image::vw_io::read_write vw_io;
101 template <
typename I,
typename F>
102 struct image_< mln::internal::thru_image_read<I, F> > : image_< I >
104 typedef trait::image::vw_io::read vw_io;
116 template <
typename I,
typename F>
134 rvalue operator()(const mln_psite(I)&
p) const;
135 rvalue operator()(const mln_psite(I)&
p);
140 template <typename I, typename F>
150 lvalue operator()(
const mln_psite(I)& p);
159 template <
typename I,
typename F>
170 void init_(I& ima,
const F& f);
177 template <
typename I,
typename F>
181 template <
typename I,
typename F>
185 template <
typename I,
typename M>
189 template <
typename I,
typename M>
193 # ifndef MLN_INCLUDE_ONLY
200 template <
typename I,
typename F>
212 template <
typename I,
typename F>
214 thru_image<I, F>::thru_image()
218 template <
typename I,
typename F>
220 thru_image<I, F>::thru_image(I& ima,
const F& f)
222 mln_precondition(ima.is_valid());
226 template <
typename I,
typename F>
228 thru_image<I, F>::thru_image(I& ima)
230 mln_precondition(ima.is_valid());
234 template <
typename I,
typename F>
237 thru_image<I, F>::init_(I& ima,
const F& f)
239 mln_precondition(! this->is_valid());
240 mln_precondition(ima.is_valid());
241 this->data_ =
new internal::data< thru_image<I, F> >(ima, f);
244 template <
typename I,
typename F>
246 thru_image<I, F>::operator thru_image<const I, F>()
const
248 thru_image<const I, F> tmp(this->data_->ima_, this->data_->f_);
255 template <
typename I,
typename F>
257 typename thru_image_read<I, F>::rvalue
258 thru_image_read<I, F>::operator()(
const mln_psite(I)& p)
const
260 mln_precondition(this->is_valid());
261 return this->data_->f_(this->data_->ima_(p));
264 template <
typename I,
typename F>
266 typename thru_image_read<I, F>::rvalue
267 thru_image_read<I, F>::operator()(
const mln_psite(I)& p)
269 mln_precondition(this->is_valid());
270 return this->data_->f_(this->data_->ima_(p));
273 template <
typename I,
typename F>
275 typename thru_image_write<I, F>::lvalue
276 thru_image_write<I, F>::operator()(
const mln_psite(I)& p)
278 mln_precondition(this->is_valid());
279 return this->data_->f_(this->data_->ima_(p));
285 template <
typename I,
typename F>
293 template <
typename I,
typename F>
297 thru_image<const I, F> tmp(
exact(ima),
exact(f));
301 template <
typename I,
typename M>
302 thru_image<I, mln_fun_with(M, mln_value(I))>
305 typedef mln_fun_with(M, mln_value(I)) F;
306 thru_image<I, F> tmp(exact(ima), F(exact(f).state()));
311 template <typename I, typename M>
312 thru_image<const I, mln_fun_with(M, mln_value(I))>
313 thru(const mln::Meta_Function<M>& f, const Image<I>& ima)
315 typedef mln_fun_with(M, mln_value(I)) F;
316 thru_image<const I, F> tmp(exact(ima), F(exact(f).state()));
321 # endif // ! MLN_INCLUDE_ONLY
326 #endif // ! MLN_CORE_IMAGE_VMORPH_THRU_IMAGE_HH