Milena (Olena)
User documentation 2.0a Id
|
00001 // Copyright (C) 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_SET_COMPUTE_HH 00027 # define MLN_SET_COMPUTE_HH 00028 00032 00033 # include <mln/core/concept/meta_accumulator.hh> 00034 # include <mln/core/concept/image.hh> 00035 # include <mln/core/concept/site_set.hh> 00036 00037 00038 namespace mln 00039 { 00040 00041 namespace set 00042 { 00043 00049 // 00050 template <typename A, typename S> 00051 mln_result(A) 00052 compute(const Accumulator<A>& a, const Site_Set<S>& s); 00053 00054 00059 // \return The accumulator result. 00060 // 00061 template <typename A, typename S> 00062 mln_meta_accu_result(A, mln_site(S)) 00063 compute(const Meta_Accumulator<A>& a, const Site_Set<S>& s); 00064 00065 00066 00067 # ifndef MLN_INCLUDE_ONLY 00068 00069 00070 // Implementation. 00071 00072 00073 namespace impl 00074 { 00075 00076 namespace generic 00077 { 00078 00079 template <typename A, typename S> 00080 inline 00081 mln_result(A) 00082 compute(const Accumulator<A>& a_, const Site_Set<S>& s_) 00083 { 00084 trace::entering("set::impl::generic::compute"); 00085 00086 mlc_converts_to(mln_site(S), mln_argument(A))::check(); 00087 00088 A a = exact(a_); 00089 const S& s = exact(s_); 00090 00091 a.init(); 00092 mln_piter(S) p(s); 00093 for_all(p) 00094 a.take(p); 00095 00096 trace::exiting("set::impl::generic::compute"); 00097 return a.to_result(); 00098 } 00099 00100 } // end of namespace mln::set::impl::generic 00101 00102 } // end of namespace mln::set::impl 00103 00104 00105 00106 // Facades. 00107 00108 00109 template <typename A, typename S> 00110 inline 00111 mln_result(A) 00112 compute(const Accumulator<A>& a, const Site_Set<S>& s) 00113 { 00114 trace::entering("set::compute"); 00115 00116 mlc_converts_to(mln_site(S), mln_argument(A))::check(); 00117 00118 mln_result(A) r = impl::generic::compute(a, s); 00119 00120 trace::exiting("set::compute"); 00121 return r; 00122 } 00123 00124 00125 template <typename A, typename S> 00126 mln_meta_accu_result(A, mln_site(S)) 00127 compute(const Meta_Accumulator<A>& a, const Site_Set<S>& s) 00128 { 00129 trace::entering("set::compute"); 00130 00131 typedef mln_accu_with(A, mln_site(S)) A_; 00132 A_ a_ = accu::unmeta(exact(a), mln_site(S)()); 00133 00134 mln_result(A_) r = impl::generic::compute(a_, s); 00135 00136 trace::exiting("set::compute"); 00137 return r; 00138 } 00139 00140 # endif // ! MLN_INCLUDE_ONLY 00141 00142 } // end of namespace mln::set 00143 00144 } // end of namespace mln 00145 00146 00147 #endif // ! MLN_SET_COMPUTE_HH