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;
54 template <
typename I,
typename F>
57 typedef thru_image_write<I, F> write;
58 typedef thru_image_read<I, F> read;
59 typedef mlc_if(mlc_and(mln_trait_fun_is_assignable(F),
60 mlc_and(mlc_not(mlc_is_const(I)),
61 mlc_equal(mln_trait_image_pw_io(I),
62 trait::image::pw_io::read_write))),
67 template <typename I, typename F>
68 struct
data< thru_image<I, F> >
70 data(I& ima,
const F& f);
82 template <
typename I,
typename F>
83 struct image_< thru_image<I, F> > : image_< typename mln::internal::thru_find_impl<I, F>::ret >
86 typedef trait::image::category::value_morpher category;
87 typedef mln_internal_trait_image_speed_from(I) speed;
88 typedef trait::image::value_access::computed value_access;
91 template <typename I, typename F>
92 struct image_< mln::internal::thru_image_write<I, F> > : image_< I >
94 typedef trait::image::vw_io::read_write vw_io;
97 template <
typename I,
typename F>
98 struct image_< mln::internal::thru_image_read<I, F> > : image_< I >
100 typedef trait::image::vw_io::read vw_io;
112 template <
typename I,
typename F>
113 class thru_image_read :
public internal::image_value_morpher< I, typename F::result, thru_image<I,F> >
118 typedef thru_image<tag::image_<I>, F> skeleton;
121 typedef mln_psite(I) psite;
124 typedef mln_result(F) value;
127 typedef value rvalue;
128 typedef value lvalue;
130 rvalue operator()(const mln_psite(I)& p) const;
131 rvalue operator()(const mln_psite(I)& p);
136 template <typename I, typename F>
137 class thru_image_write : public thru_image_read<I,F>
143 typedef typename F::lresult lvalue;
145 using thru_image_read<I,F>::operator();
146 lvalue operator()(
const mln_psite(I)& p);
155 template <
typename I,
typename F>
156 class thru_image :
public internal::thru_find_impl<I, F>::ret
164 void init_(I& ima,
const F& f);
170 template <
typename I,
typename F>
174 template <
typename I,
typename F>
178 template <
typename I,
typename M>
182 template <
typename I,
typename M>
186 # ifndef MLN_INCLUDE_ONLY
193 template <
typename I,
typename F>
205 template <
typename I,
typename F>
207 thru_image<I, F>::thru_image()
211 template <
typename I,
typename F>
213 thru_image<I, F>::thru_image(I& ima,
const F& f)
215 mln_precondition(ima.is_valid());
219 template <
typename I,
typename F>
221 thru_image<I, F>::thru_image(I& ima)
223 mln_precondition(ima.is_valid());
227 template <
typename I,
typename F>
230 thru_image<I, F>::init_(I& ima,
const F& f)
232 mln_precondition(! this->is_valid());
233 mln_precondition(ima.is_valid());
234 this->data_ =
new internal::data< thru_image<I, F> >(ima, f);
237 template <
typename I,
typename F>
248 template <
typename I,
typename F>
250 typename thru_image_read<I, F>::rvalue
251 thru_image_read<I, F>::operator()(
const mln_psite(I)& p)
const
253 mln_precondition(this->is_valid());
254 return this->data_->f_(this->data_->ima_(p));
257 template <
typename I,
typename F>
259 typename thru_image_read<I, F>::rvalue
260 thru_image_read<I, F>::operator()(
const mln_psite(I)& p)
262 mln_precondition(this->is_valid());
263 return this->data_->f_(this->data_->ima_(p));
266 template <
typename I,
typename F>
268 typename thru_image_write<I, F>::lvalue
269 thru_image_write<I, F>::operator()(
const mln_psite(I)& p)
271 mln_precondition(this->is_valid());
272 return this->data_->f_(this->data_->ima_(p));
278 template <
typename I,
typename F>
282 thru_image<I, F> tmp(exact(ima), exact(f));
286 template <
typename I,
typename F>
290 thru_image<const I, F> tmp(exact(ima), exact(f));
294 template <
typename I,
typename M>
295 thru_image<I, mln_fun_with(M, mln_value(I))>
298 typedef mln_fun_with(M, mln_value(I)) F;
299 thru_image<I, F> tmp(exact(ima), F(exact(f).state()));
304 template <typename I, typename M>
305 thru_image<const I, mln_fun_with(M, mln_value(I))>
306 thru(const mln::Meta_Function<M>& f, const Image<I>& ima)
308 typedef mln_fun_with(M, mln_value(I)) F;
309 thru_image<const I, F> tmp(exact(ima), F(exact(f).state()));
314 # endif // ! MLN_INCLUDE_ONLY
319 #endif // ! MLN_CORE_IMAGE_VMORPH_THRU_IMAGE_HH