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_LOGIC_LAND_BASIC_HH
00027 # define MLN_ACCU_LOGIC_LAND_BASIC_HH
00028
00034
00035 # include <mln/core/concept/meta_accumulator.hh>
00036 # include <mln/accu/internal/base.hh>
00037
00038
00039 namespace mln
00040 {
00041
00042
00043 namespace accu {
00044 namespace logic {
00045 struct land_basic;
00046 }
00047 }
00048
00049
00050
00051
00052 namespace trait
00053 {
00054
00055 template <>
00056 struct accumulator_< accu::logic::land_basic >
00057 {
00058 typedef accumulator::has_untake::no has_untake;
00059 typedef accumulator::has_set_value::no has_set_value;
00060 typedef accumulator::has_stop::yes has_stop;
00061 typedef accumulator::when_pix::use_v when_pix;
00062 };
00063
00064 }
00065
00066
00067 namespace accu
00068 {
00069
00070 namespace meta
00071 {
00072
00073 namespace logic
00074 {
00075
00077 struct land_basic : public Meta_Accumulator< land_basic >
00078 {
00079 template <typename T>
00080 struct with
00081 {
00082 typedef accu::logic::land_basic ret;
00083 };
00084 };
00085
00086 }
00087 }
00088
00089
00090 namespace logic
00091 {
00092
00098
00099 struct land_basic : public mln::accu::internal::base< bool, land_basic >
00100 {
00101 typedef bool argument;
00102
00103 land_basic();
00104
00107 void init();
00108 void take_as_init_(const argument& t);
00109
00110 void take(const argument& t);
00111 void take(const land_basic& other);
00113
00115 bool to_result() const;
00116
00119 bool is_valid() const;
00120
00124 bool can_stop() const;
00125
00126 protected:
00127 bool res_;
00128 };
00129
00130 # ifndef MLN_INCLUDE_ONLY
00131
00132 inline
00133 land_basic::land_basic()
00134 {
00135 init();
00136 }
00137
00138 inline
00139 void
00140 land_basic::init()
00141 {
00142 res_ = true;
00143 }
00144
00145 inline
00146 void land_basic::take_as_init_(const argument& t)
00147 {
00148 res_ = t;
00149 }
00150
00151 inline
00152 void land_basic::take(const argument& t)
00153 {
00154 if (res_ == true && t == false)
00155 res_ = false;
00156 }
00157
00158 inline
00159 void
00160 land_basic::take(const land_basic& other)
00161 {
00162 res_ = res_ && other.res_;
00163 }
00164
00165 inline
00166 bool
00167 land_basic::to_result() const
00168 {
00169 return res_;
00170 }
00171
00172 inline
00173 bool
00174 land_basic::is_valid() const
00175 {
00176 return true;
00177 }
00178
00179 inline
00180 bool
00181 land_basic::can_stop() const
00182 {
00183 return res_ == false;
00184 }
00185
00186 # endif // ! MLN_INCLUDE_ONLY
00187
00188 }
00189 }
00190 }
00191
00192
00193 #endif // ! MLN_ACCU_LOGIC_LAND_BASIC_HH