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

yes.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_YES_HH
00027 # define MLN_UTIL_YES_HH
00028 
00032 
00033 
00034 # include <mln/core/concept/object.hh>
00035 # include <mln/core/routine/ops.hh>
00036 
00037 
00038 namespace mln
00039 {
00040 
00041   // Forward declaration.
00042   namespace util { struct yes; }
00043 
00044 
00045   namespace trait
00046   {
00047 
00048     template <>
00049     struct set_precise_unary_< op::not_, util::yes >
00050     {
00051       typedef util::yes ret;
00052     };
00053 
00054     template <template<class, class> class Op>
00055     struct set_precise_binary_< Op, util::yes, bool >
00056     {
00057       typedef util::yes ret;
00058     };
00059 
00060     template <template<class, class> class Op>
00061     struct set_precise_binary_< Op, util::yes, util::yes >
00062     {
00063       typedef util::yes ret;
00064     };
00065 
00066   } // end of namespace mln::trait
00067 
00068 
00069   namespace util
00070   {
00071 
00075     //
00076     struct yes : public Object< yes >
00077     {
00078       yes();
00079       explicit yes(bool);
00080       operator bool() const;
00081     };
00082 
00083   } // end of namespace mln::util
00084 
00085 
00086   // Negate.
00087   util::yes operator ! (const util::yes& y);
00088 
00089   // Equal.
00090   util::yes operator == (const util::yes&, bool);
00091   util::yes operator == (const util::yes&, const util::yes&);
00092 
00093   // Not equal.
00094   util::yes operator != (const util::yes&, bool);
00095   util::yes operator != (const util::yes&, const util::yes&);
00096 
00097   // And.
00098   util::yes operator && (const util::yes&, bool);
00099 
00100   // Or.
00101   util::yes operator || (const util::yes&, bool);
00102 
00103 
00104   // FIXME: Is-it suffisiant?
00105 
00106 
00107 # ifndef MLN_INCLUDE_ONLY
00108 
00109   namespace util
00110   {
00111 
00112     // yes
00113 
00114     inline
00115     yes::yes()
00116     {
00117     }
00118 
00119     inline
00120     yes::yes(bool)
00121     {
00122     }
00123 
00124     inline
00125     yes::operator bool() const
00126     {
00127       return true;
00128     }
00129 
00130   } // end of namespace mln::util
00131 
00132   inline
00133   util::yes
00134   operator ! (const util::yes& y)
00135   {
00136     return y;
00137   }
00138 
00139   inline
00140   util::yes operator == (const util::yes&, bool)
00141   {
00142     return util::yes(true);
00143   }
00144 
00145   inline
00146   util::yes operator == (const util::yes&, const util::yes&)
00147   {
00148     return util::yes(true);
00149   }
00150 
00151   inline
00152   util::yes operator != (const util::yes&, bool)
00153   {
00154     return util::yes(true);
00155   }
00156 
00157   inline
00158   util::yes operator != (const util::yes&, const util::yes&)
00159   {
00160     return util::yes(true);
00161   }
00162 
00163   inline
00164   util::yes operator && (const util::yes&, bool)
00165   {
00166     return util::yes(true);
00167   }
00168 
00169   inline
00170   util::yes operator || (const util::yes&, bool)
00171   {
00172     return util::yes(true);
00173   }
00174 
00175 # endif // ! MLN_INCLUDE_ONLY
00176 
00177 } // end of namespace mln
00178 
00179 
00180 #endif // ! MLN_UTIL_YES_HH

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