27 #ifndef MLN_VALUE_STACK_HH
28 # define MLN_VALUE_STACK_HH
34 # include <mln/core/internal/image_value_morpher.hh>
36 # include <mln/algebra/vec.hh>
37 # include <mln/value/set.hh>
38 # include <mln/value/proxy.hh>
45 namespace value {
template <
unsigned n,
typename I>
struct stack_image; }
53 template <
unsigned n,
typename I>
57 data(
const algebra::vec<n,I>& imas);
58 algebra::vec<n,I> imas_;
69 template <
unsigned n,
typename I>
70 struct helper_stack_image_lvalue_
72 typedef value::proxy< stack_image<n,I> > ret;
73 static ret make(stack_image<n,I>& ima,
const mln_psite(I)& p)
80 template <
unsigned n,
typename I>
81 struct helper_stack_image_lvalue_< n, const I >
83 typedef algebra::vec<n, mln_value(I)> ret;
84 static ret make(stack_image<n, const I>& ima,
const mln_psite(I)& p)
99 template <
unsigned n,
typename I>
100 struct image_< mln::value::stack_image<n, I> >
101 : default_image_morpher< I,
102 algebra::vec<n, mln_value(I)>,
103 mln::value::stack_image<n, I> >
107 typedef trait::image::category::value_morpher category;
109 typedef trait::image::nature::vectorial nature;
123 typedef trait::image::speed::fast speed;
144 template <
unsigned n,
typename I>
146 :
public mln::internal::image_value_morpher< I,
147 algebra::vec<n, mln_value(I)>,
157 typedef algebra::vec<n, mln_value(I)>
value;
166 typedef typename internal::helper_stack_image_lvalue_<n,I>::ret
lvalue;
180 void init_(const algebra::vec<n,I>& imas);
186 rvalue operator()(const psite& p) const;
187 rvalue read_(const psite& p) const;
190 lvalue operator()(const psite&);
191 void write_(const psite& p, const value& v);
195 template <typename I>
200 template <typename I>
207 # ifndef MLN_INCLUDE_ONLY
213 template <
unsigned n,
typename I>
228 template <
unsigned n,
typename I>
234 template <
unsigned n,
typename I>
241 template <
unsigned n,
typename I>
246 this->data_ =
new mln::internal::data< stack_image<n, I> >(imas);
247 for (
unsigned i = 0; i < n; ++i)
249 mln_precondition(imas[i].
is_valid());
253 template <
unsigned n,
typename I>
257 for (
unsigned i = 0; i < n; ++i)
258 mln_invariant(this->data_->imas_[i].is_valid());
262 template <
unsigned n,
typename I>
267 mln_precondition(this->has(p));
268 algebra::vec<n, mln_value(I)> tmp;
269 for (
unsigned i = 0; i < n; ++i)
270 tmp[i] = this->data_->imas_[i].operator()(p);
274 template <
unsigned n,
typename I>
282 template <
unsigned n,
typename I>
287 mln_precondition(this->has(p));
289 for (
unsigned i = 0; i < n; ++i)
290 this->data_->imas_[i].operator()(p) = v[i];
293 template <
unsigned n,
typename I>
298 return internal::helper_stack_image_lvalue_<n,I>::make(*
this, p);
303 template <
typename I>
308 mln_precondition(exact(ima1).domain() == exact(ima2).domain());
309 algebra::vec<2, const I> imas;
310 imas[0] = exact(ima1);
311 imas[1] = exact(ima2);
315 template <
typename I>
320 mln_precondition(exact(ima1).domain() == exact(ima2).domain());
321 algebra::vec<2, I> imas;
322 imas[0] = exact(ima1);
323 imas[1] = exact(ima2);
329 # endif // ! MLN_INCLUDE_ONLY
334 #endif // ! MLN_VALUE_STACK_HH