26 #ifndef MLN_CORE_INTERNAL_IMAGE_MORPHER_HH
27 # define MLN_CORE_INTERNAL_IMAGE_MORPHER_HH
35 # include <mln/core/internal/image_base.hh>
36 # include <mln/metal/const.hh>
37 # include <mln/metal/is_const.hh>
38 # include <mln/metal/is_not_const.hh>
51 template <
typename I,
typename T,
typename S,
typename E>
52 class image_morpher :
public image_base<T, S, E>
60 mlc_const(I)* delegatee_()
const;
74 mlc_const(I)& unmorph_()
const;
83 bool is_valid()
const;
112 template <
typename Subject,
typename T,
114 void init_(Subject s, T& target,
const Image<J>& model);
120 # ifndef MLN_INCLUDE_ONLY
125 template <
typename I,
typename T,
typename S,
typename E>
127 image_morpher<I, T, S, E>::image_morpher()
131 template <
typename I,
typename T,
typename S,
typename E>
134 image_morpher<I, T, S, E>::delegatee_()
const
136 return this->data_ == 0 ? 0 : & this->data_->ima_;
139 template <
typename I,
typename T,
typename S,
typename E>
142 image_morpher<I, T, S, E>::delegatee_()
144 return this->data_ == 0 ? 0 : & this->data_->ima_;
147 template <
typename I,
typename T,
typename S,
typename E>
150 image_morpher<I, T, S, E>::unmorph_()
152 I* ptr = delegatee_();
153 mln_assertion(ptr != 0);
157 template <
typename I,
typename T,
typename S,
typename E>
160 image_morpher<I, T, S, E>::unmorph_()
const
162 mlc_const(I)* ptr = delegatee_();
163 mln_assertion(ptr != 0);
167 template <
typename I,
typename T,
typename S,
typename E>
170 image_morpher<I, T, S, E>::is_valid()
const
174 this->delegatee_() != 0 &&
175 this->delegatee_()->is_valid();
178 template <
typename I,
typename T,
typename S,
typename E>
181 image_morpher<I, T, S, E>::rw()
183 mlc_is_not_const(I)::check();
184 mlc_equal(mln_trait_image_value_io(I),
185 mln::trait::image::value_io::read_write)::check();
204 template <
typename Subject,
typename T,
207 void init_(Subject s, T& target,
const Image<J>& model_)
209 mlc_is(mln_trait_image_category(J),
210 trait::image::category::morpher)::check();
211 const J& model = exact(model_);
212 init_(s, target, * model.delegatee_());
215 # endif // ! MLN_INCLUDE_ONLY
220 #endif // ! MLN_CORE_INTERNAL_IMAGE_MORPHER_HH