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

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

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