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

compute.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_ACCU_COMPUTE_HH
00027 # define MLN_ACCU_COMPUTE_HH
00028 
00035 
00036 # include <mln/core/concept/meta_accumulator.hh>
00037 # include <mln/core/concept/image.hh>
00038 # include <mln/util/pix.hh>
00039 
00040 
00041 namespace mln
00042 {
00043 
00044   namespace accu
00045   {
00046 
00058     template <typename A, typename I>
00059     mln_result(A)
00060     compute(const Accumulator<A>& a, const Image<I>& input);
00061 
00062 
00074     template <typename A, typename I>
00075     mln_meta_accu_result(A, util::pix<I>)
00076     compute(const Meta_Accumulator<A>& a, const Image<I>& input);
00077 
00078 
00079 
00080 # ifndef MLN_INCLUDE_ONLY
00081 
00082 
00083     namespace impl
00084     {
00085 
00086       namespace generic
00087       {
00088 
00089         template <typename A, typename I>
00090         mln_result(A)
00091         compute(const Accumulator<A>&, const Image<I>& input_)
00092         {
00093           trace::entering("accu::impl::generic::compute");
00094 
00095           const I& input = exact(input_);
00096           mln_precondition(input.is_valid());
00097 
00098           A a;
00099           mln_piter(I) p(input.domain());
00100           for_all(p)
00101             a.take(make::pix(input, p));
00102 
00103           trace::exiting("accu::impl::generic::compute");
00104           return a.to_result();
00105         }
00106 
00107       } // end of namespace mln::accu::impl::generic
00108 
00109     } // end of namespace mln::accu::impl
00110 
00111 
00112     namespace internal
00113     {
00114 
00115       template <typename A, typename I>
00116       inline
00117       mln_result(A)
00118       compute_dispatch(const Accumulator<A>& a, const Image<I>& input)
00119       {
00120         return impl::generic::compute(a, input);
00121       }
00122 
00123     } // end of namespace mln::accu::internal
00124 
00125 
00126 
00127     template <typename A, typename I>
00128     inline
00129     mln_result(A)
00130     compute(const Accumulator<A>& a, const Image<I>& input)
00131     {
00132       trace::entering("accu::compute");
00133 
00134       mln_precondition(exact(input).is_valid());
00135       mln_result(A) output = internal::compute_dispatch(a, input);
00136 
00137       trace::exiting("accu::compute");
00138       return output;
00139     }
00140 
00141     template <typename A, typename I>
00142     inline
00143     mln_meta_accu_result(A, util::pix<I>)
00144     compute(const Meta_Accumulator<A>& a, const Image<I>& input)
00145     {
00146       trace::entering("accu::compute");
00147 
00148       mln_precondition(exact(input).is_valid());
00149 
00150       typedef mln_accu_with(A, util::pix<I>) A_;
00151       util::pix<I> pix_(exact(input), mln_psite(I)());
00152       A_ a_ = accu::unmeta(exact(a), pix_);
00153 
00154       mln_result(A_) output = internal::compute_dispatch(a_, input);
00155 
00156       trace::exiting("accu::compute");
00157       return output;
00158     }
00159 
00160 # endif // ! MLN_INCLUDE_ONLY
00161 
00162   } // end of namespace mln::accu
00163 
00164 } // end of namespace mln
00165 
00166 
00167 #endif // ! MLN_ACCU_COMPUTE_HH

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