$extrastylesheet
Olena  User documentation 2.1
An Image Processing Platform
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
land_basic.hh
1 // Copyright (C) 2007, 2008, 2009 EPITA Research and Development Laboratory (LRDE)
2 //
3 // This file is part of Olena.
4 //
5 // Olena is free software: you can redistribute it and/or modify it under
6 // the terms of the GNU General Public License as published by the Free
7 // Software Foundation, version 2 of the License.
8 //
9 // Olena is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with Olena. If not, see <http://www.gnu.org/licenses/>.
16 //
17 // As a special exception, you may use this file as part of a free
18 // software project without restriction. Specifically, if other files
19 // instantiate templates or use macros or inline functions from this
20 // file, or you compile this file and link it with other files to produce
21 // an executable, this file does not by itself cause the resulting
22 // executable to be covered by the GNU General Public License. This
23 // exception does not however invalidate any other reasons why the
24 // executable file might be covered by the GNU General Public License.
25 
26 #ifndef MLN_ACCU_LOGIC_LAND_BASIC_HH
27 # define MLN_ACCU_LOGIC_LAND_BASIC_HH
28 
34 
35 # include <mln/core/concept/meta_accumulator.hh>
36 # include <mln/accu/internal/base.hh>
37 
38 
39 namespace mln
40 {
41 
42  // Forward declaration.
43  namespace accu {
44  namespace logic {
45  struct land_basic;
46  }
47  }
48 
49 
50  // Traits.
51 
52  namespace trait
53  {
54 
55  template <>
56  struct accumulator_< accu::logic::land_basic >
57  {
58  typedef accumulator::has_untake::no has_untake;
59  typedef accumulator::has_set_value::no has_set_value;
60  typedef accumulator::has_stop::yes has_stop;
61  typedef accumulator::when_pix::use_v when_pix;
62  };
63 
64  } // end of namespace mln::trait
65 
66 
67  namespace accu
68  {
69 
70  namespace meta
71  {
72 
73  namespace logic
74  {
75 
77  struct land_basic : public Meta_Accumulator< land_basic >
78  {
79  template <typename T>
80  struct with
81  {
83  };
84  };
85 
86  } // end of namespace mln::accu::meta::logic
87  } // end of namespace mln::accu::meta
88 
89 
90  namespace logic
91  {
92 
98  //
99  struct land_basic : public mln::accu::internal::base< bool, land_basic >
100  {
101  typedef bool argument;
102 
103  land_basic();
104 
107  void init();
108  void take_as_init_(const argument& t);
109 
110  void take(const argument& t);
111  void take(const land_basic& other);
113 
115  bool to_result() const;
116 
119  bool is_valid() const;
120 
124  bool can_stop() const;
125 
126  protected:
127  bool res_;
128  };
129 
130 # ifndef MLN_INCLUDE_ONLY
131 
132  inline
134  {
135  init();
136  }
137 
138  inline
139  void
141  {
142  res_ = true;
143  }
144 
145  inline
146  void land_basic::take_as_init_(const argument& t)
147  {
148  res_ = t;
149  }
150 
151  inline
152  void land_basic::take(const argument& t)
153  {
154  if (res_ == true && t == false)
155  res_ = false;
156  }
157 
158  inline
159  void
160  land_basic::take(const land_basic& other)
161  {
162  res_ = res_ && other.res_;
163  }
164 
165  inline
166  bool
167  land_basic::to_result() const
168  {
169  return res_;
170  }
171 
172  inline
173  bool
174  land_basic::is_valid() const
175  {
176  return true;
177  }
178 
179  inline
180  bool
181  land_basic::can_stop() const
182  {
183  return res_ == false;
184  }
185 
186 # endif // ! MLN_INCLUDE_ONLY
187 
188  } // end of namespace mln::accu::logic
189  } // end of namespace mln::accu
190 } // end of namespace mln
191 
192 
193 #endif // ! MLN_ACCU_LOGIC_LAND_BASIC_HH