• Main Page
  • Related Pages
  • Modules
  • Namespaces
  • Classes
  • Files
  • File List

update.hh

00001 // Copyright (C) 2007, 2008, 2009 EPITA Research and Development Laboratory (LRDE)
00002 //
00003 // This file is part of Olena.
00004 //
00005 // Olena is free software: you can redistribute it and/or modify it under
00006 // the terms of the GNU General Public License as published by the Free
00007 // Software Foundation, version 2 of the License.
00008 //
00009 // Olena is distributed in the hope that it will be useful,
00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012 // General Public License for more details.
00013 //
00014 // You should have received a copy of the GNU General Public License
00015 // along with Olena.  If not, see <http://www.gnu.org/licenses/>.
00016 //
00017 // As a special exception, you may use this file as part of a free
00018 // software project without restriction.  Specifically, if other files
00019 // instantiate templates or use macros or inline functions from this
00020 // file, or you compile this file and link it with other files to produce
00021 // an executable, this file does not by itself cause the resulting
00022 // executable to be covered by the GNU General Public License.  This
00023 // exception does not however invalidate any other reasons why the
00024 // executable file might be covered by the GNU General Public License.
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     // Tests.
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         // sizeof(a.take(mln_value(I)()));
00073 
00074         (void) a;
00075         (void) input;
00076       }
00077 
00078     } // end of namespace internal
00079 
00080 
00081 
00082     // Implementations.
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       } // end of namespace mln::data::impl::generic
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     } // end of namespace mln::data::impl
00147 
00148 
00149 
00150     // Dispatch.
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     } // end of namespace internal
00183 
00184 
00185 
00186     // Facades.
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   } // end of namespace mln::data
00205 
00206 } // end of namespace mln
00207 
00208 
00209 #endif // ! MLN_DATA_UPDATE_HH

Generated on Tue Oct 4 2011 15:25:04 for Milena (Olena) by  doxygen 1.7.1