26 #ifndef MLN_PW_INTERNAL_IMAGE_BASE_HH
27 # define MLN_PW_INTERNAL_IMAGE_BASE_HH
33 # include <mln/core/internal/image_primary.hh>
34 # include <mln/core/routine/init.hh>
35 # include <mln/metal/unqualif.hh>
36 # include <mln/metal/not_equal.hh>
37 # include <mln/value/set.hh>
51 template <
typename F,
typename S,
typename E>
63 template <
typename F,
typename S,
typename E>
65 : default_image_<mln_result(F),E>
68 typedef typename F::mutable_result mutable_result;
69 typedef mlc_not_equal(mutable_result,
void) is_mutable;
73 typedef trait::image::category::
primary category;
74 typedef trait::image::speed::fast speed;
75 typedef trait::image::size::regular size;
78 typedef trait::image::vw_io::none vw_io;
79 typedef trait::image::vw_set::none vw_set;
80 typedef trait::image::value_access::computed value_access;
81 typedef trait::image::value_storage::disrupted value_storage;
82 typedef trait::image::value_browsing::site_wise_only value_browsing;
83 typedef trait::image::value_alignment::irrelevant value_alignment;
84 typedef mlc_if(is_mutable,
85 trait::image::value_io::read_write,
86 trait::image::value_io::read_only) value_io;
89 typedef mlc_if(is_mutable,
90 trait::image::pw_io::read_write,
91 trait::image::pw_io::read) pw_io;
92 typedef undef localization;
93 typedef undef dimension;
96 typedef trait::image::ext_domain::none ext_domain;
97 typedef trait::image::ext_value::irrelevant ext_value;
98 typedef trait::image::ext_io::irrelevant ext_io;
113 template <
typename F,
typename S,
typename E>
115 :
public mln::internal::image_primary<mln_result(F), S, E >
117 typedef typename F::mutable_result mutable_result;
118 typedef mlc_not_equal(mutable_result,
void) is_mutable;
122 typedef F function_t;
125 typedef mln_result(F) value;
128 typedef mln_result(F) rvalue;
131 typedef mlc_if(is_mutable, mutable_result, mln_result(F)) lvalue;
134 void init_(const Function_v2v<F>& f, const Site_Set<S>& ps);
137 const S& domain() const;
143 rvalue operator()(const mln_psite(S)& p) const;
147 lvalue operator()(const mln_psite(S)& p);
151 image_base(const Function_v2v<F>& f, const Site_Set<S>& ps);
161 template <typename F, typename S, typename E>
162 void init_(tag::function_t, F& f, const pw::internal::image_base<F,S,E>& model);
164 template <typename F1, typename F2, typename S, typename E>
165 void init_(tag::function_t, F1& f, const pw::internal::image_base<F2,S,E>& model);
168 # ifndef MLN_INCLUDE_ONLY
172 template <
typename F,
typename S,
typename E>
173 void init_(tag::function_t, F& f,
const pw::internal::image_base<F,S,E>& model)
175 f = model.function();
178 template <
typename F1,
typename F2,
typename S,
typename E>
179 void init_(tag::function_t, F1& f,
const pw::internal::image_base<F2,S,E>& model)
181 init_(tag::function, f, model.function());
191 template <
typename F,
typename S,
typename E>
193 image_base<F,S,E>::image_base()
197 template <
typename F,
typename S,
typename E>
199 image_base<F,S,E>::image_base(
const Function_v2v<F>& f,
const Site_Set<S>& ps)
201 this->data_ =
new mln::internal::data<E>(exact(f), exact(ps));
204 template <
typename F,
typename S,
typename E>
207 image_base<F,S,E>::init_(
const Function_v2v<F>& f,
const Site_Set<S>& ps)
209 this->data_ =
new mln::internal::data<E>(exact(f), exact(ps));
212 template <
typename F,
typename S,
typename E>
215 image_base<F,S,E>::domain()
const
217 return this->data_->domain_;
220 template <
typename F,
typename S,
typename E>
223 image_base<F,S,E>:: function()
const
225 return this->data_->f_;
229 template <
typename F,
typename S,
typename E>
231 typename image_base<F,S,E>::rvalue
232 image_base<F,S,E>::operator()(
const mln_psite(S)& p)
const
234 mln_precondition(this->data_->domain_.has(p));
235 return this->data_->f_(p);
238 template <
typename F,
typename S,
typename E>
240 typename image_base<F,S,E>::lvalue
241 image_base<F,S,E>::operator()(
const mln_psite(S)& p)
243 mln_precondition(this->data_->domain_.has(p));
244 return this->data_->f_(p);
251 # endif // ! MLN_INCLUDE_ONLY
256 #endif // ! MLN_PW_INTERNAL_IMAGE_BASE_HH