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_ACCU_V_HH
00027 # define MLN_ACCU_V_HH
00028 
00032 
00033 
00034 # include <mln/core/concept/meta_accumulator.hh>
00035 # include <mln/accu/internal/base.hh>
00036 # include <mln/metal/is_a.hh>
00037 # include <mln/util/pix.hh>
00038 
00039 
00040 namespace mln
00041 {
00042 
00043   namespace accu
00044   {
00045 
00046 
00047 
00049     template <typename A>
00050     struct val : public mln::accu::internal::base< const mln_result(A)& , val<A> >
00051     {
00052       typedef mln_argument(A)  argument;
00053 
00054       val();
00055       val(const A& a);
00056 
00059       void init();
00060       void take_as_init_(const argument& t);
00061       void take(const argument& t);
00062       void take(const val<A>& other);
00063       template <typename I>
00064       void take_as_init_(const util::pix<I>& pix);
00065       template <typename I>
00066       void take(const util::pix<I>& pix);
00068 
00070       const mln_result(A)& to_result() const;
00071 
00074       bool is_valid() const;
00075 
00076     protected:
00077       A a_;
00078     };
00079 
00080 
00081     namespace meta
00082     {
00083 
00085 
00086       template <typename mA>
00087       struct val : public Meta_Accumulator< val<mA> >
00088       {
00089         template <typename V>
00090         struct with
00091         {
00092           typedef mln_accu_with(mA, mln_value(V)) A;
00093           typedef val<A> ret;
00094         };
00095       };
00096 
00097     }
00098 
00099 # ifndef MLN_INCLUDE_ONLY
00100 
00101     template <typename A>
00102     inline
00103     val<A>::val()
00104     {
00105       init();
00106     }
00107 
00108     template <typename A>
00109     inline
00110     val<A>::val(const A& a)
00111       : a_(a)
00112     {
00113       init();
00114     }
00115 
00116     template <typename A>
00117     inline
00118     void
00119     val<A>::init()
00120     {
00121       a_.init();
00122     }
00123 
00124     template <typename A>
00125     inline
00126     void
00127     val<A>::take_as_init_(const argument& t)
00128     {
00129       a_.take_as_init_(t);
00130     }
00131 
00132     template <typename A>
00133     inline
00134     void
00135     val<A>::take(const argument& t)
00136     {
00137       a_.take(t);
00138     }
00139 
00140     template <typename A>
00141     inline
00142     void
00143     val<A>::take(const val<A>& other)
00144     {
00145       a_.take(other.a_);
00146     }
00147 
00148     template <typename A>
00149     template <typename I>
00150     inline
00151     void
00152     val<A>::take_as_init_(const util::pix<I>& pix)
00153     {
00154       a_.take_as_init_(pix.v()); 
00155     }
00156 
00157     template <typename A>
00158     template <typename I>
00159     inline
00160     void
00161     val<A>::take(const util::pix<I>& pix)
00162     {
00163       a_.take(pix.v());
00164     }
00165 
00166     template <typename A>
00167     inline
00168     const mln_result(A)&
00169     val<A>::to_result() const
00170     {
00171       return a_.to_result();
00172     }
00173 
00174     template <typename A>
00175     inline
00176     bool
00177     val<A>::is_valid() const
00178     {
00179       return a_.is_valid();
00180     }
00181 
00182 
00183 # endif // ! MLN_INCLUDE_ONLY
00184 
00185   } 
00186 
00187 } 
00188 
00189 
00190 #endif // ! MLN_ACCU_V_HH