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

compare.hh

00001 // Copyright (C) 2007, 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_COMPARE_HH
00027 # define MLN_DATA_COMPARE_HH
00028 
00032 
00033 # include <mln/core/concept/image.hh>
00034 # include <mln/fun/vv2b/eq.hh>
00035 # include <mln/fun/vv2b/le.hh>
00036 # include <mln/fun/vv2b/lt.hh>
00037 # include <mln/test/predicate.hh>
00038 
00039 
00040 namespace mln
00041 {
00042 
00050   //
00051   template <typename L, typename R>
00052   bool operator == (const Image<L>& lhs, const Image<R>& rhs);
00053 
00054 
00062   //
00063   template <typename L, typename R>
00064   bool operator < (const Image<L>& lhs, const Image<R>& rhs);
00065 
00066 
00074   //
00075   template <typename L, typename R> // required!
00076   bool operator <= (const Image<L>& lhs, const Image<R>& rhs);
00077 
00078 
00079 
00080 # ifndef MLN_INCLUDE_ONLY
00081 
00082 
00083   template <typename L, typename R>
00084   inline
00085   bool operator == (const Image<L>& lhs_, const Image<R>& rhs_)
00086   {
00087     trace::entering("data::compare (==)");
00088 
00089     const L& lhs = exact(lhs_);
00090     const R& rhs = exact(rhs_);
00091 
00092     mln_precondition(lhs.is_valid());
00093     mln_precondition(rhs.is_valid());
00094     mln_precondition(lhs.domain() == rhs.domain());
00095 
00096     typedef fun::vv2b::eq<mln_value(L), mln_value(R)> F;
00097     bool res = test::predicate(lhs_, rhs_, F());
00098 
00099     trace::exiting("data::compare (==)");
00100     return res;
00101   }
00102 
00103 
00104   template <typename L, typename R>
00105   inline
00106   bool operator < (const Image<L>& lhs_, const Image<R>& rhs_)
00107   {
00108     trace::entering("data::compare (<)");
00109 
00110     const L& lhs = exact(lhs_);
00111     const R& rhs = exact(rhs_);
00112 
00113     mln_precondition(lhs.domain() == rhs.domain());
00114 
00115     typedef fun::vv2b::lt<mln_value(L), mln_value(R)> F;
00116     bool res = test::predicate(lhs_, rhs_, F());
00117 
00118     trace::exiting("data::compare (<)");
00119     return res;
00120   }
00121 
00122 
00123   template <typename L, typename R> // required!
00124   inline
00125   bool operator <= (const Image<L>& lhs_, const Image<R>& rhs_)
00126   {
00127     trace::entering("data::compare (<=)");
00128 
00129     const L& lhs = exact(lhs_);
00130     const R& rhs = exact(rhs_);
00131 
00132     mln_precondition(lhs.domain() == rhs.domain());
00133 
00134     typedef fun::vv2b::le<mln_value(L), mln_value(R)> F;
00135     bool res = test::predicate(lhs_, rhs_, F());
00136 
00137     trace::exiting("data::compare (<=)");
00138     return res;
00139   }
00140 
00141 # endif // ! MLN_INCLUDE_ONLY
00142 
00143 } // end of namespace mln
00144 
00145 
00146 #endif // ! MLN_DATA_COMPARE_HH

Generated on Thu Sep 8 2011 18:31:41 for Milena (Olena) by  doxygen 1.7.1