00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #ifndef MLN_CORE_IMAGE_DMORPH_SUB_IMAGE_IF_HH
00028 # define MLN_CORE_IMAGE_DMORPH_SUB_IMAGE_IF_HH
00029
00030
00036
00037
00038 # include <mln/core/internal/image_domain_morpher.hh>
00039 # include <mln/core/site_set/p_if.hh>
00040 # include <mln/fun/p2b/has.hh>
00041
00042 # include <mln/debug/println.hh>
00043
00044
00045 namespace mln
00046 {
00047
00048
00049
00050 template <typename I, typename S> struct sub_image_if;
00051
00052
00053 namespace internal
00054 {
00055
00057 template <typename I, typename S>
00058 struct data< sub_image_if<I,S> >
00059 {
00060 data(I& ima, const S& s);
00061
00062 I ima_;
00063 p_if< S, fun::p2b::has<I> > s_;
00064 };
00065
00066 }
00067
00068
00069
00070 namespace trait
00071 {
00072
00073 template <typename I, typename S>
00074 struct image_< sub_image_if<I,S> > : default_image_morpher< I,
00075 mln_value(I),
00076 sub_image_if<I,S> >
00077 {
00078
00079
00080
00081
00082
00083 typedef trait::image::category::domain_morpher category;
00084
00085 typedef trait::image::ext_domain::none ext_domain;
00086 typedef trait::image::ext_value::irrelevant ext_value;
00087 typedef trait::image::ext_io::irrelevant ext_io;
00088
00089 typedef trait::image::value_storage::disrupted value_storage;
00090
00091 };
00092
00093 }
00094
00095
00096
00100
00101 template <typename I, typename S>
00102 struct sub_image_if : public internal::image_domain_morpher< I,
00103 p_if< S, fun::p2b::has<I> >,
00104 sub_image_if<I,S> >
00105 {
00107 typedef sub_image_if< tag::image_<I>, tag::domain_<S> > skeleton;
00108
00110 sub_image_if();
00111
00113 sub_image_if(I& ima, const S& s);
00114
00116 void init_(I& ima, const S& s);
00117
00119 const p_if< S, fun::p2b::has<I> >& domain() const;
00120
00121
00122
00123 };
00124
00125
00126
00127
00128
00129 template <typename I, typename S>
00130 sub_image_if<const I, S>
00131 operator / (const Image<I>& ima, const Site_Set<S>& s);
00132
00133
00134 template <typename I, typename S>
00135 sub_image_if<I, S>
00136 operator / (Image<I>& ima, const Site_Set<S>& s);
00137
00138
00139 template <typename I, typename S, typename J>
00140 void init_(tag::image_t, sub_image_if<I,S>& target, const J& model);
00141
00142
00143
00144 # ifndef MLN_INCLUDE_ONLY
00145
00146
00147
00148 template <typename I, typename S, typename J>
00149 inline
00150 void init_(tag::image_t, sub_image_if<I,S>& target, const J& model)
00151 {
00152 I ima;
00153 init_(tag::image, ima, model);
00154 S s;
00155 init_(tag::domain, s, model);
00156 target.init_(ima, s);
00157 }
00158
00159
00160
00161
00162 namespace internal
00163 {
00164
00165 template <typename I, typename S>
00166 inline
00167 data< sub_image_if<I,S> >::data(I& ima, const S& s)
00168 : ima_(ima)
00169 {
00170 typedef fun::p2b::has<I> F;
00171 F f(ima);
00172 s_ = p_if<S,F>(s, f);
00173 }
00174
00175 }
00176
00177
00178
00179
00180 template <typename I, typename S>
00181 inline
00182 sub_image_if<I,S>::sub_image_if()
00183 {
00184 }
00185
00186 template <typename I, typename S>
00187 inline
00188 sub_image_if<I,S>::sub_image_if(I& ima, const S& s)
00189 {
00190 init_(ima, s);
00191 }
00192
00193 template <typename I, typename S>
00194 inline
00195 void
00196 sub_image_if<I,S>::init_(I& ima, const S& s)
00197 {
00198 mln_precondition(! this->is_valid());
00199 this->data_ = new internal::data< sub_image_if<I,S> >(ima, s);
00200 }
00201
00202 template <typename I, typename S>
00203 inline
00204 const p_if< S, fun::p2b::has<I> >&
00205 sub_image_if<I,S>::domain() const
00206 {
00207 return this->data_->s_;
00208 }
00209
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222 template <typename I, typename S>
00223 inline
00224 sub_image_if<const I, S>
00225 operator / (const Image<I>& ima, const Site_Set<S>& s)
00226 {
00227
00228 sub_image_if<const I, S> tmp(exact(ima), exact(s));
00229 return tmp;
00230 }
00231
00232 template <typename I, typename S>
00233 inline
00234 sub_image_if<I, S>
00235 operator / (Image<I>& ima, const Site_Set<S>& s)
00236 {
00237
00238 sub_image_if<I, S> tmp(exact(ima), exact(s));
00239 return tmp;
00240 }
00241
00242 # endif // ! MLN_INCLUDE_ONLY
00243
00244 }
00245
00246
00247 #endif // ! MLN_CORE_IMAGE_DMORPH_SUB_IMAGE_IF_HH