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

sup.hh

00001 // Copyright (C) 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_ACCU_MATH_SUP_HH
00027 # define MLN_ACCU_MATH_SUP_HH
00028 
00032 
00033 # include <mln/accu/internal/base.hh>
00034 # include <mln/core/concept/meta_accumulator.hh>
00035 # include <mln/trait/value_.hh>
00036 # include <mln/util/pix.hh>
00037 # include <mln/fun/math/sup.hh>
00038 
00039 namespace mln
00040 {
00041 
00042   namespace accu
00043   {
00044 
00045     namespace math
00046     {
00047 
00048 
00050 
00055       template <typename T>
00056       struct sup : public mln::accu::internal::base< const T&, sup<T> >
00057       {
00058         typedef T argument;
00059 
00060         sup();
00061 
00064         void init();
00065         void take_as_init_(const argument& t);
00066         void take(const argument& t);
00067         void take(const sup<T>& other);
00069 
00071         const T& to_result() const;
00072 
00075         bool is_valid() const;
00076 
00077       protected:
00078 
00079         T t_;
00080         typename mln::fun::sup::with<T, T>::ret fun_;
00081       };
00082 
00083 
00084       template <typename I> struct sup< util::pix<I> >;
00085 
00086 
00087     } // end of mln::accu::math
00088 
00089 
00090     namespace meta
00091     {
00092 
00093       namespace math
00094       {
00095 
00097 
00098         struct sup : public Meta_Accumulator< sup >
00099         {
00100           template <typename T>
00101           struct with
00102           {
00103             typedef accu::math::sup<T> ret;
00104           };
00105         };
00106 
00107       } // end of namespace mln::accu::meta::math
00108 
00109     } // end of namespace mln::accu::meta
00110 
00111 
00112 
00113 # ifndef MLN_INCLUDE_ONLY
00114 
00115     namespace math
00116     {
00117 
00118       template <typename T>
00119       inline
00120       sup<T>::sup()
00121       {
00122         init();
00123       }
00124 
00125       template <typename T>
00126       inline
00127       void
00128       sup<T>::init()
00129       {
00130         t_ = mln_min(T);
00131       }
00132 
00133       template <typename T>
00134       inline
00135       void sup<T>::take_as_init_(const argument& t)
00136       {
00137         t_ = t;
00138       }
00139 
00140       template <typename T>
00141       inline
00142       void sup<T>::take(const argument& t)
00143       {
00144         this->t_ = this->fun_(t_, t);
00145       }
00146 
00147       template <typename T>
00148       inline
00149       void
00150       sup<T>::take(const sup<T>& other)
00151       {
00152         this->t_ = this->fun_(t_, other.t_);
00153       }
00154 
00155       template <typename T>
00156       inline
00157       const T&
00158       sup<T>::to_result() const
00159       {
00160         return t_;
00161       }
00162 
00163       template <typename T>
00164       inline
00165       bool
00166       sup<T>::is_valid() const
00167       {
00168         return true;
00169       }
00170 
00171     } // end of namespace mln::accu::math
00172 
00173 # endif // ! MLN_INCLUDE_ONLY
00174 
00175   } // end of namespace mln::accu
00176 
00177 } // end of namespace mln
00178 
00179 
00180 #endif // ! MLN_ACCU_MATH_SUP_HH

Generated on Fri Sep 16 2011 16:34:04 for Milena (Olena) by  doxygen 1.7.1