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

ord.hh

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_UTIL_ORD_HH
00027 # define MLN_UTIL_ORD_HH
00028 
00032 
00033 
00034 # include <mln/core/concept/object.hh>
00035 # include <mln/trait/op/ord.hh>
00036 
00037 
00038 
00039 namespace mln
00040 {
00041 
00042   namespace util
00043   {
00044 
00047     template <typename T>
00048     struct ord
00049     {
00050       bool operator()(const T& lhs, const T& rhs) const;
00051     };
00052 
00053 
00054 
00056     template <typename T>
00057     bool ord_strict(const T& lhs, const T& rhs);
00058 
00059 
00061     template <typename T>
00062     bool ord_weak(const T& lhs, const T& rhs);
00063 
00064 
00065     template <typename T1, typename T2>
00066     bool ord_lexi_strict(const T1& lhs_1, const T2& lhs_2,
00067                          const T1& rhs_1, const T2& rhs_2);
00068 
00069 
00070 
00071 # ifndef MLN_INCLUDE_ONLY
00072 
00073     // ord<T>
00074 
00075     template <typename T>
00076     inline
00077     bool
00078     ord<T>::operator()(const T& lhs, const T& rhs) const
00079     {
00080       typedef typename mln::trait::op::ord<T>::ret F;
00081       static const F f_ord = F();
00082       return f_ord.strict(lhs, rhs);
00083     }
00084 
00085     // ord_strict
00086 
00087     template <typename T>
00088     inline
00089     bool
00090     ord_strict(const T& lhs, const T& rhs)
00091     {
00092       typedef typename mln::trait::op::ord<T>::ret F;
00093       static const F f_ord = F();
00094       return f_ord.strict(lhs, rhs);
00095     }
00096 
00097     // ord_weak
00098 
00099     template <typename T>
00100     inline
00101     bool ord_weak(const T& lhs, const T& rhs)
00102     {
00103       typedef typename mln::trait::op::ord<T>::ret F;
00104       static const F f_ord = F();
00105       return f_ord.weak(lhs, rhs);
00106     }
00107 
00108     // ord_lex_strict
00109 
00110     template <typename T1, typename T2>
00111     inline
00112     bool
00113     ord_lexi_strict(const T1& lhs_1, const T2& lhs_2,
00114                     const T1& rhs_1, const T2& rhs_2)
00115     {
00116       return
00117         util::ord_strict(lhs_1, rhs_1) ||
00118         (lhs_1 == rhs_1 && util::ord_strict(lhs_2, rhs_2));
00119     }
00120 
00121 # endif // ! MLN_INCLUDE_ONLY
00122 
00123   } // end of namespace mln::util
00124 
00125 } // end of namespace mln
00126 
00127 
00128 #endif // ! MLN_UTIL_ORD_HH

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