26 #ifndef MLN_DATA_CONVERT_HH
27 # define MLN_DATA_CONVERT_HH
35 # include <mln/core/routine/duplicate.hh>
36 # include <mln/fun/v2v/convert.hh>
37 # include <mln/data/transform.hh>
51 template <
typename V,
typename I>
53 convert(const V& v, const Image<I>& input);
57 # ifndef MLN_INCLUDE_ONLY
62 template <
typename V,
typename I>
65 convert_tests(
const V&,
const Image<I>& input)
67 mln_precondition(exact(input).is_valid());
79 template <
typename V,
typename I>
82 convert(const V& v, const Image<I>& input)
84 trace::entering(
"data::impl::generic::convert");
85 internal::convert_tests(v, input);
87 fun::v2v::convert<V> f;
90 trace::exiting("
data::impl::generic::convert");
97 template <typename V, typename I>
100 convert_identity(const V& v, const Image<I>& input)
102 trace::entering(
"data::impl::convert_identity");
103 internal::convert_tests(v, input);
105 mln_concrete(I) output =
duplicate(input);
107 trace::exiting("
data::impl::convert_identity");
117 template <
typename V,
typename I>
120 convert_dispatch(metal::bool_<true>,
121 const V& v, const Image<I>& input)
123 return impl::convert_identity(v, input);
126 template <
typename V,
typename I>
129 convert_dispatch(metal::bool_<false>,
130 const V& v, const Image<I>& input)
132 return impl::generic::convert(v, input);
135 template <
typename V,
typename I>
138 convert_dispatch(const V& v, const Image<I>& input)
141 test = mlc_equal(V, mln_value(I))::
value
143 return convert_dispatch(metal::bool_<test>(),
151 template <
typename V,
typename I>
154 convert(const V& v, const
Image<I>& input)
156 trace::entering(
"data::convert");
158 internal::convert_tests(v, input);
160 mln_ch_value(I, V) output = internal::convert_dispatch(v, input);
162 trace::exiting(
"data::convert");
167 # endif // ! MLN_INCLUDE_ONLY
174 #endif // ! MLN_DATA_CONVERT_HH