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_P_HH
00027 # define MLN_ACCU_P_HH
00028
00032
00033 # include <mln/core/concept/meta_accumulator.hh>
00034
00035 # include <mln/accu/internal/base.hh>
00036 # include <mln/metal/is_a.hh>
00037
00038
00039 namespace mln
00040 {
00041
00042 namespace accu
00043 {
00044
00045
00049 template <typename A>
00050 struct p : public mln::accu::internal::base< const mln_result(A)& , p<A> >
00051 {
00052 typedef mln_argument(A) argument;
00053
00054 p();
00055 p(const A& a);
00056
00059 void init();
00060 void take_as_init_(const argument& t);
00061 void take(const argument& t);
00062 void take(const p<A>& other);
00064
00066 const mln_result(A)& to_result() const;
00067
00070 bool is_valid() const;
00071
00072 protected:
00073 A a_;
00074 };
00075
00076
00077 namespace meta
00078 {
00079
00081
00082 template <typename mA>
00083 struct p : public Meta_Accumulator< p<mA> >
00084 {
00085 template <typename V>
00086 struct with
00087 {
00088 typedef p<V> ret;
00089 };
00090 };
00091
00092 }
00093
00094
00095 # ifndef MLN_INCLUDE_ONLY
00096
00097 template <typename A>
00098 inline
00099 p<A>::p()
00100 {
00101 init();
00102 }
00103
00104 template <typename A>
00105 inline
00106 p<A>::p(const A& a)
00107 : a_(a)
00108 {
00109 init();
00110 }
00111
00112 template <typename A>
00113 inline
00114 void
00115 p<A>::init()
00116 {
00117 a_.init();
00118 }
00119
00120 template <typename A>
00121 inline
00122 void
00123 p<A>::take_as_init_(const argument& t)
00124 {
00125 a_.take_as_init_(t.p());
00126 }
00127
00128 template <typename A>
00129 inline
00130 void
00131 p<A>::take(const argument& t)
00132 {
00133 a_.take(t.p());
00134 }
00135
00136 template <typename A>
00137 inline
00138 void
00139 p<A>::take(const p<A>& other)
00140 {
00141 a_.take(other.a_);
00142 }
00143
00144 template <typename A>
00145 inline
00146 const mln_result(A)&
00147 p<A>::to_result() const
00148 {
00149 return a_.to_result();
00150 }
00151
00152 template <typename A>
00153 inline
00154 bool
00155 p<A>::is_valid() const
00156 {
00157 return a_.is_valid();
00158 }
00159
00160 # endif // ! MLN_INCLUDE_ONLY
00161
00162 }
00163
00164 }
00165
00166
00167 #endif // ! MLN_ACCU_P_HH