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

init.hh

00001 // Copyright (C) 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_ACCU_IMAGE_INIT_HH
00027 # define MLN_ACCU_IMAGE_INIT_HH
00028 
00032 
00033 # include <mln/core/concept/accumulator.hh>
00034 # include <mln/core/concept/image.hh>
00035 
00036 
00037 namespace mln
00038 {
00039 
00040   namespace accu
00041   {
00042 
00043     namespace image
00044     {
00045 
00046       template <typename I>
00047       void
00048       init(Image<I>& input);
00049 
00050 
00051 
00052 # ifndef MLN_INCLUDE_ONLY
00053 
00054       namespace impl
00055       {
00056 
00057         // Generic version.
00058 
00059         namespace generic
00060         {
00061 
00062           template <typename I>
00063           void
00064           init(Image<I>& input_)
00065           {
00066             trace::entering("accu::impl::image::generic::init");
00067 
00068             mlc_is_a(mln_value(I), Accumulator)::check();
00069 
00070             I& input = exact(input_);
00071             mln_precondition(input.is_valid());
00072 
00073             mln_piter(I) p(input.domain());
00074             for_all(p)
00075               input(p).init();
00076 
00077             trace::exiting("accu::impl::image::generic::init");
00078           }
00079 
00080         } // end of namespace mln::accu::image::impl::generic
00081 
00082 
00083         // Fastest version.
00084 
00085         template <typename I>
00086         void
00087         init_fastest(Image<I>& input_)
00088         {
00089           trace::entering("accu::impl::image::init_fastest");
00090 
00091           mlc_is_a(mln_value(I), Accumulator)::check();
00092           
00093           I& input = exact(input_);
00094           mln_precondition(input.is_valid());
00095           
00096           mln_pixter(I) px(input);
00097           for_all(px)
00098             px.val().init();
00099 
00100           trace::exiting("accu::impl::image::init_fastest");
00101         }
00102 
00103       } // end of namespace mln::accu::image::impl
00104 
00105 
00106 
00107       // Dispatch.
00108 
00109       namespace internal
00110       {
00111 
00112         template <typename I>
00113         void
00114         init_dispatch(trait::image::speed::any,
00115                       Image<I>& input)
00116         {
00117           impl::generic::init(input);
00118         }
00119 
00120         template <typename I>
00121         void
00122         init_dispatch(trait::image::speed::fastest,
00123                       Image<I>& input)
00124         {
00125           impl::init_fastest(input);
00126         }
00127 
00128         template <typename I>
00129         void
00130         init_dispatch(Image<I>& input)
00131         {
00132           init_dispatch(mln_trait_image_speed(I)(),
00133                         input);
00134         }
00135 
00136       } // end of namespace mln::accu::image::internal
00137 
00138 
00139       // Facade.
00140 
00141       template <typename I>
00142       void
00143       init(Image<I>& input)
00144       {
00145         trace::entering("accu::image::init");
00146 
00147         mlc_is_a(mln_value(I), Accumulator)::check();
00148 
00149         mln_precondition(exact(input).is_valid());
00150         internal::init_dispatch(input);
00151 
00152         trace::exiting("accu::image::init");
00153       }
00154 
00155 # endif // ! MLN_INCLUDE_ONLY
00156 
00157     } // end of namespace mln::accu::image
00158 
00159   } // end of namespace mln::accu
00160 
00161 } // end of namespace mln
00162 
00163 
00164 #endif // ! MLN_ACCU_IMAGE_INIT_HH

Generated on Fri Sep 16 2011 16:33:38 for Milena (Olena) by  doxygen 1.7.1