$extrastylesheet
Olena  User documentation 2.1
An Image Processing Platform
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
lor_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_LOR_BASIC_HH
27 # define MLN_ACCU_LOGIC_LOR_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 lor_basic;
46  }
47  }
48 
49 
50  // Traits.
51 
52  namespace trait
53  {
54 
55  template <>
56  struct accumulator_< accu::logic::lor_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  {
76  struct lor_basic : public Meta_Accumulator< lor_basic >
77  {
78  template <typename T>
79  struct with
80  {
82  };
83  };
84 
85  } // end of namespace mln::accu::meta::logic
86  } // end of namespace mln::accu::meta
87 
88 
89  namespace logic
90  {
91 
97  //
98  struct lor_basic : public mln::accu::internal::base< bool, lor_basic >
99  {
100  typedef bool argument;
101 
102  lor_basic();
103 
106  void init();
107  void take_as_init_(const argument& t);
108 
109  void take(const argument& t);
110  void take(const lor_basic& other);
112 
114  bool to_result() const;
115 
118  bool is_valid() const;
119 
123  bool can_stop() const;
124 
125  protected:
126  bool res_;
127  };
128 
129 # ifndef MLN_INCLUDE_ONLY
130 
131  inline
133  {
134  init();
135  }
136 
137  inline
138  void
140  {
141  res_ = false;
142  }
143 
144  inline
145  void lor_basic::take_as_init_(const argument& t)
146  {
147  res_ = t;
148  }
149 
150  inline
151  void lor_basic::take(const argument& t)
152  {
153  if (res_ == false && t == true)
154  res_ = true;
155  }
156 
157  inline
158  void
159  lor_basic::take(const lor_basic& other)
160  {
161  res_ = res_ || other.res_;
162  }
163 
164  inline
165  bool
166  lor_basic::to_result() const
167  {
168  return res_;
169  }
170 
171  inline
172  bool
173  lor_basic::is_valid() const
174  {
175  return true;
176  }
177 
178  inline
179  bool
180  lor_basic::can_stop() const
181  {
182  return res_ == true;
183  }
184 
185 # endif // ! MLN_INCLUDE_ONLY
186 
187  } // end of namespace mln::accu::logic
188  } // end of namespace mln::accu
189 } // end of namespace mln
190 
191 
192 #endif // ! MLN_ACCU_LOGIC_LOR_BASIC_HH