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_DATA_UPDATE_HH
00027 # define MLN_DATA_UPDATE_HH
00028
00032
00033 # include <mln/core/concept/accumulator.hh>
00034 # include <mln/core/concept/image.hh>
00035
00036
00037
00038 namespace mln
00039 {
00040
00041 namespace data
00042 {
00043
00050 template <typename A, typename I>
00051 mln_result(A)
00052 update(Accumulator<A>& a, const Image<I>& input);
00053
00054
00055
00056 # ifndef MLN_INCLUDE_ONLY
00057
00058
00059
00060
00061 namespace internal
00062 {
00063
00064 template <typename A, typename I>
00065 inline
00066 void
00067 update_tests(Accumulator<A>& a_, const Image<I>& input_)
00068 {
00069 A& a = exact(a_);
00070 const I& input = exact(input_);
00071 mln_precondition(input.is_valid());
00072
00073
00074 (void) a;
00075 (void) input;
00076 }
00077
00078 }
00079
00080
00081
00082
00083
00084 namespace impl
00085 {
00086
00087 namespace generic
00088 {
00089
00096
00097 template <typename A, typename I>
00098 inline
00099 mln_result(A)
00100 update(Accumulator<A>& a_, const Image<I>& input_)
00101 {
00102 trace::entering("data::impl::generic::update");
00103
00104 A& a = exact(a_);
00105 const I& input = exact(input_);
00106 data::internal::update_tests(a, input);
00107
00108 mln_piter(I) p(input.domain());
00109 for_all(p)
00110 a.take(input(p));
00111
00112 trace::exiting("data::impl::generic::update");
00113 return a.to_result();
00114 }
00115
00116 }
00117
00118
00125
00126 template <typename A, typename I>
00127 inline
00128 mln_result(A)
00129 update_fastest(Accumulator<A>& a_, const Image<I>& input_)
00130 {
00131 trace::entering("data::impl::update_fastest");
00132
00133 A& a = exact(a_);
00134 const I& input = exact(input_);
00135 data::internal::update_tests(a, input);
00136
00137 mln_pixter(const I) pxl(input);
00138 for_all(pxl)
00139 a.take(pxl.val());
00140
00141 trace::exiting("data::impl::update_fastest");
00142 return a.to_result();
00143 }
00144
00145
00146 }
00147
00148
00149
00150
00151
00152 namespace internal
00153 {
00154
00155 template <typename A, typename I>
00156 inline
00157 mln_result(A)
00158 update_dispatch(trait::image::speed::any,
00159 Accumulator<A>& a, const Image<I>& input)
00160 {
00161 return impl::generic::update(a, input);
00162 }
00163
00164 template <typename A, typename I>
00165 inline
00166 mln_result(A)
00167 update_dispatch(trait::image::speed::fastest,
00168 Accumulator<A>& a, const Image<I>& input)
00169 {
00170 return impl::update_fastest(a, input);
00171 }
00172
00173 template <typename A, typename I>
00174 inline
00175 mln_result(A)
00176 update_dispatch(Accumulator<A>& a, const Image<I>& input)
00177 {
00178 return update_dispatch(mln_trait_image_speed(I)(),
00179 a, input);
00180 }
00181
00182 }
00183
00184
00185
00186
00187
00188 template <typename A, typename I>
00189 inline
00190 mln_result(A)
00191 update(Accumulator<A>& a, const Image<I>& input)
00192 {
00193 trace::entering("data::update");
00194
00195 data::internal::update_tests(a, input);
00196 mln_result(A) r = internal::update_dispatch(a, input);
00197
00198 trace::exiting("data::update");
00199 return r;
00200 }
00201
00202 # endif // ! MLN_INCLUDE_ONLY
00203
00204 }
00205
00206 }
00207
00208
00209 #endif // ! MLN_DATA_UPDATE_HH