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 #ifndef MLN_VALUE_SHELL_HH
00027 # define MLN_VALUE_SHELL_HH
00028 
00032 
00033 # include <mln/core/concept/proxy.hh>
00034 # include <mln/core/concept/function.hh>
00035 # include <mln/core/concept/image.hh>
00036 
00037 
00038 namespace mln
00039 {
00040 
00041   
00042   namespace value {
00043     template <typename F, typename I> struct shell;
00044   }
00045 
00046   namespace value
00047   {
00048 
00049     namespace impl
00050     {
00051 
00052       template <typename F, typename I, class C>
00053       struct shell_ { };
00054 
00055 
00056       template <typename F, typename I>
00057       struct shell_<F, I, Function_v2v<void> >
00058       {
00059         const mln_value(I)&
00060         set_(I& ima, const mln_site(I)& s, mln_result(F) v);
00061       };
00062 
00063     } 
00064 
00065 
00066     template <typename F, typename I>
00067     struct shell
00068       : public Proxy< shell<F,I> >,
00069         public mln::internal::proxy_impl< mln_result(F), shell<F,I> >,
00070         public impl::shell_<F, I, typename F::category>
00071     {
00072       typedef mln_result(F) value;
00073 
00074       
00075       shell(Image<I> &ima, const mln_site(I) &s);
00076 
00077       
00078       value operator=(value);
00079 
00080       
00081       typedef void enc; 
00082 
00083       
00084       typedef value equiv;
00085 
00086       mln_result(F) subj_();
00087 
00088       
00089       
00090 
00091       
00092       
00093 
00094 
00095     protected:
00096       I& ima_;
00097       mln_site(I) s_;
00098       mln_result(F) v_;
00099     };
00100 
00101 
00102 # ifndef MLN_INCLUDE_ONLY
00103 
00104     
00105     template <typename F, typename I>
00106     shell<F,I>::shell(Image<I>& ima, const mln_site(I)& s)
00107       :
00108       ima_(exact(ima)),
00109       s_(s),
00110       v_(F()(exact(ima)(s)))
00111     {
00112     }
00113 
00114     
00115     template <typename F, typename I>
00116     typename F::result
00117     shell<F,I>::operator=(mln_result(F) v)
00118     {
00119       v_ = F()(set_(ima_, s_, v));
00120       return v_;
00121     }
00122 
00123     template <typename F, typename I>
00124     mln_result(F)
00125     shell<F,I>::subj_()
00126     {
00127       return v_;
00128     }
00129 
00130 
00131     namespace impl
00132     {
00133 
00134 
00135 
00136 
00137 
00138 
00139 
00140 
00141 
00142 
00143 
00144       template <typename F, typename I>
00145       const mln_value(I)&
00146       shell_<F, I, Function_v2v<void> >::set_(I& ima,
00147                                                   const mln_site(I)& s,
00148                                                   mln_result(F) v)
00149       {
00150         ima(s) = F().f_1(v, ima(s));
00151         return ima(s);
00152       }
00153 
00154     } 
00155 
00156 
00157 # endif // MLN_INCLUDE_ONLY
00158 
00159 
00160   } 
00161 
00162 } 
00163 
00164 #endif // ! MLN_VALUE_SHELL_HH