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

compare.hh

00001 // Copyright (C) 2007, 2009 EPITA Research and Development Laboratory
00002 // (LRDE)
00003 //
00004 // This file is part of Olena.
00005 //
00006 // Olena is free software: you can redistribute it and/or modify it under
00007 // the terms of the GNU General Public License as published by the Free
00008 // Software Foundation, version 2 of the License.
00009 //
00010 // Olena is distributed in the hope that it will be useful,
00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013 // General Public License for more details.
00014 //
00015 // You should have received a copy of the GNU General Public License
00016 // along with Olena.  If not, see <http://www.gnu.org/licenses/>.
00017 //
00018 // As a special exception, you may use this file as part of a free
00019 // software project without restriction.  Specifically, if other files
00020 // instantiate templates or use macros or inline functions from this
00021 // file, or you compile this file and link it with other files to produce
00022 // an executable, this file does not by itself cause the resulting
00023 // executable to be covered by the GNU General Public License.  This
00024 // exception does not however invalidate any other reasons why the
00025 // executable file might be covered by the GNU General Public License.
00026 
00027 #ifndef MLN_DATA_COMPARE_HH
00028 # define MLN_DATA_COMPARE_HH
00029 
00033 
00034 # include <mln/core/concept/image.hh>
00035 # include <mln/fun/vv2b/eq.hh>
00036 # include <mln/fun/vv2b/le.hh>
00037 # include <mln/fun/vv2b/lt.hh>
00038 # include <mln/test/predicate.hh>
00039 
00040 
00041 namespace mln
00042 {
00043 
00051   //
00052   template <typename L, typename R>
00053   bool operator == (const Image<L>& lhs, const Image<R>& rhs);
00054 
00055 
00063   //
00064   template <typename L, typename R>
00065   bool operator < (const Image<L>& lhs, const Image<R>& rhs);
00066 
00067 
00075   //
00076   template <typename L, typename R> // required!
00077   bool operator <= (const Image<L>& lhs, const Image<R>& rhs);
00078 
00079 
00080 
00081 # ifndef MLN_INCLUDE_ONLY
00082 
00083 
00084   template <typename L, typename R>
00085   inline
00086   bool operator == (const Image<L>& lhs_, const Image<R>& rhs_)
00087   {
00088     trace::entering("data::compare (==)");
00089 
00090     const L& lhs = exact(lhs_);
00091     const R& rhs = exact(rhs_);
00092 
00093     mln_precondition(lhs.is_valid());
00094     mln_precondition(rhs.is_valid());
00095     mln_precondition(lhs.domain() == rhs.domain());
00096 
00097     typedef fun::vv2b::eq<mln_value(L), mln_value(R)> F;
00098     bool res = test::predicate(lhs, rhs, F());
00099 
00100     trace::exiting("data::compare (==)");
00101     return res;
00102   }
00103 
00104 
00105   template <typename L, typename R>
00106   inline
00107   bool operator < (const Image<L>& lhs_, const Image<R>& rhs_)
00108   {
00109     trace::entering("data::compare (<)");
00110 
00111     const L& lhs = exact(lhs_);
00112     const R& rhs = exact(rhs_);
00113 
00114     mln_precondition(lhs.domain() == rhs.domain());
00115 
00116     typedef fun::vv2b::lt<mln_value(L), mln_value(R)> F;
00117     bool res = test::predicate(lhs_, rhs_, F());
00118 
00119     trace::exiting("data::compare (<)");
00120     return res;
00121   }
00122 
00123 
00124   template <typename L, typename R> // required!
00125   inline
00126   bool operator <= (const Image<L>& lhs_, const Image<R>& rhs_)
00127   {
00128     trace::entering("data::compare (<=)");
00129 
00130     const L& lhs = exact(lhs_);
00131     const R& rhs = exact(rhs_);
00132 
00133     mln_precondition(lhs.domain() == rhs.domain());
00134 
00135     typedef fun::vv2b::le<mln_value(L), mln_value(R)> F;
00136     bool res = test::predicate(lhs_, rhs_, F());
00137 
00138     trace::exiting("data::compare (<=)");
00139     return res;
00140   }
00141 
00142 # endif // ! MLN_INCLUDE_ONLY
00143 
00144 } // end of namespace mln
00145 
00146 
00147 #endif // ! MLN_DATA_COMPARE_HH

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