$extrastylesheet
Olena  User documentation 2.1
An Image Processing Platform
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
v.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_V_HH
27 # define MLN_ACCU_V_HH
28 
32 
33 
34 # include <mln/core/concept/meta_accumulator.hh>
35 # include <mln/accu/internal/base.hh>
36 # include <mln/metal/is_a.hh>
37 # include <mln/util/pix.hh>
38 
39 
40 namespace mln
41 {
42 
43  namespace accu
44  {
45 
46 
47 
49  template <typename A>
50  struct val : public mln::accu::internal::base< const mln_result(A)& , val<A> >
51  {
52  typedef mln_argument(A) argument;
53 
54  val();
55  val(const A& a);
56 
59  void init();
60  void take_as_init_(const argument& t);
61  void take(const argument& t);
62  void take(const val<A>& other);
63  template <typename I>
64  void take_as_init_(const util::pix<I>& pix);
65  template <typename I>
66  void take(const util::pix<I>& pix);
68 
70  const mln_result(A)& to_result() const;
71 
74  bool is_valid() const;
75 
76  protected:
77  A a_;
78  };
79 
80 
81  namespace meta
82  {
83 
85 
86  template <typename mA>
87  struct val : public Meta_Accumulator< val<mA> >
88  {
89  template <typename V>
90  struct with
91  {
92  typedef mln_accu_with(mA, mln_value(V)) A;
93  typedef val<A> ret;
94  };
95  };
96 
97  }
98 
99 # ifndef MLN_INCLUDE_ONLY
100 
101  template <typename A>
102  inline
103  val<A>::val()
104  {
105  init();
106  }
107 
108  template <typename A>
109  inline
110  val<A>::val(const A& a)
111  : a_(a)
112  {
113  init();
114  }
115 
116  template <typename A>
117  inline
118  void
119  val<A>::init()
120  {
121  a_.init();
122  }
123 
124  template <typename A>
125  inline
126  void
127  val<A>::take_as_init_(const argument& t)
128  {
129  a_.take_as_init_(t);
130  }
131 
132  template <typename A>
133  inline
134  void
135  val<A>::take(const argument& t)
136  {
137  a_.take(t);
138  }
139 
140  template <typename A>
141  inline
142  void
143  val<A>::take(const val<A>& other)
144  {
145  a_.take(other.a_);
146  }
147 
148  template <typename A>
149  template <typename I>
150  inline
151  void
152  val<A>::take_as_init_(const util::pix<I>& pix)
153  {
154  a_.take_as_init_(pix.v()); // FIXME: Generalize with "value(pix)".
155  }
156 
157  template <typename A>
158  template <typename I>
159  inline
160  void
161  val<A>::take(const util::pix<I>& pix)
162  {
163  a_.take(pix.v());
164  }
165 
166  template <typename A>
167  inline
168  const mln_result(A)&
169  val<A>::to_result() const
170  {
171  return a_.to_result();
172  }
173 
174  template <typename A>
175  inline
176  bool
177  val<A>::is_valid() const
178  {
179  return a_.is_valid();
180  }
181 
182 
183 # endif // ! MLN_INCLUDE_ONLY
184 
185  } // end of namespace mln::accu
186 
187 } // end of namespace mln
188 
189 
190 #endif // ! MLN_ACCU_V_HH