00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
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 }
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 }
00108
00109 }
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 }
00172
00173 # endif // ! MLN_INCLUDE_ONLY
00174
00175 }
00176
00177 }
00178
00179
00180 #endif // ! MLN_ACCU_MATH_SUP_HH