$extrastylesheet
Olena  User documentation 2.1
An Image Processing Platform
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
function.hh
1 // Copyright (C) 2007, 2008, 2009, 2011, 2012, 2013 EPITA Research and
2 // Development Laboratory (LRDE)
3 //
4 // This file is part of Olena.
5 //
6 // Olena is free software: you can redistribute it and/or modify it under
7 // the terms of the GNU General Public License as published by the Free
8 // Software Foundation, version 2 of the License.
9 //
10 // Olena is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 // General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with Olena. If not, see <http://www.gnu.org/licenses/>.
17 //
18 // As a special exception, you may use this file as part of a free
19 // software project without restriction. Specifically, if other files
20 // instantiate templates or use macros or inline functions from this
21 // file, or you compile this file and link it with other files to produce
22 // an executable, this file does not by itself cause the resulting
23 // executable to be covered by the GNU General Public License. This
24 // exception does not however invalidate any other reasons why the
25 // executable file might be covered by the GNU General Public License.
26 
27 #ifndef MLN_CORE_CONCEPT_FUNCTION_HH
28 # define MLN_CORE_CONCEPT_FUNCTION_HH
29 
33 
34 # include <mln/core/concept/object.hh>
35 
36 
37 namespace mln
38 {
39 
40  // Forward declarations.
41  template <typename E> struct Function;
42  template <typename E> struct Function_n2v;
43  template <typename E> struct Function_v2v;
44  template <typename E> struct Function_v2b;
45  template <typename E> struct Function_vv2v;
46  template <typename E> struct Function_vv2b;
47 
48 
49 
52  template <>
53  struct Function<void>
54  {
56  };
58 
59 
67  template <typename E>
68  struct Function : public Object<E>
69  {
71 
74 
75  protected:
76  Function();
77  Function(const Function&);
78 
79  /* Workaround for Apple's llvm-gcc 4.2.1 (Mac OS X Lion 10.7.1)
80 
81  Apple's llvm-gcc has a bug causing memmove() errors if the copy
82  constructor is not declared along with operator=(). */
84  };
85 
86 
87  /*---------------.
88  | Nil -> Value. |
89  `---------------*/
90 
92  template <>
93  struct Function_n2v<void> { typedef Function<void> super; };
95 
96 
103  //
104  template <typename E>
105  struct Function_n2v : public Function<E>
106  {
108  protected:
109  Function_n2v();
110  Function_n2v(const Function_n2v&);
111  };
112 
113 
114  /*-----------------.
115  | Value -> Value. |
116  `-----------------*/
117 
119  template <>
120  struct Function_v2v<void> { typedef Function<void> super; };
122 
123 
130  //
131  template <typename E>
132  struct Function_v2v : public Function<E>
133  {
135  typedef void mutable_result; // Meaning: no mutable result by default.
136  protected:
137  Function_v2v();
138  Function_v2v(const Function_v2v&);
139  };
140 
141 
142  /*-------------------.
143  | Value -> Boolean. |
144  `-------------------*/
145 
147  template <>
148  struct Function_v2b<void> { typedef Function_v2v<void> super; };
150 
151 
158  //
159  template <typename E>
160  struct Function_v2b : public virtual Function_v2v<E>
161  {
163  typedef bool result;
164  protected:
165  Function_v2b();
166  Function_v2b(const Function_v2b&);
167  };
168 
169 
170 
171  /*--------------------------.
172  | (Value, Value) -> Value. |
173  `--------------------------*/
174 
176  template <>
177  struct Function_vv2v<void> { typedef Function<void> super; };
179 
180 
187  //
188  template <typename E>
189  struct Function_vv2v : public Function<E>
190  {
192  protected:
193  Function_vv2v();
195  };
196 
197 
198  /*----------------------------.
199  | (Value, Value) -> Boolean. |
200  `----------------------------*/
201 
203  template <>
204  struct Function_vv2b<void> { typedef Function<void> super; };
206 
207 
214  //
215  template <typename E>
216  struct Function_vv2b : public Function<E>
217  {
218  typedef bool result;
220  protected:
221  Function_vv2b();
223  };
224 
225 
226 
227 # ifndef MLN_INCLUDE_ONLY
228 
229  // Function.
230 
231  template <typename E>
232  inline
234  {
235  typedef mln_result(E) result;
236  }
237 
238  template <typename E>
239  inline
240  Function<E>::Function(const Function<E>& rhs)
241  : Object<E>(rhs)
242  {
243  }
244 
245  template <typename E>
246  inline
247  Function<E>&
248  Function<E>::operator=(const Function<E>&)
249  {
250  return *this;
251  }
252 
253  // Function_n2v.
254 
255  template <typename E>
256  inline
258  {
259  }
260 
261  template <typename E>
262  inline
263  Function_n2v<E>::Function_n2v(const Function_n2v<E>& rhs)
264  : Function<E>(rhs)
265  {
266  }
267 
268 
269  // Function_v2v.
270 
271  template <typename E>
272  inline
273  Function_v2v<E>::Function_v2v()
274  {
275  }
276 
277  template <typename E>
278  inline
279  Function_v2v<E>::Function_v2v(const Function_v2v<E>& rhs)
280  : Function<E>(rhs)
281  {
282  }
283 
284  // Function_v2b.
285 
286  template <typename E>
287  inline
288  Function_v2b<E>::Function_v2b()
289  {
290  }
291 
292  template <typename E>
293  inline
294  Function_v2b<E>::Function_v2b(const Function_v2b<E>& rhs)
295  : Function_v2v<E>(rhs)
296  {
297  }
298 
299  // Function_vv2v.
300 
301  template <typename E>
302  inline
303  Function_vv2v<E>::Function_vv2v()
304  {
305  }
306 
307  template <typename E>
308  inline
309  Function_vv2v<E>::Function_vv2v(const Function_vv2v<E>& rhs)
310  : Function<E>(rhs)
311  {
312  }
313 
314  // Function_vv2b.
315 
316  template <typename E>
317  inline
318  Function_vv2b<E>::Function_vv2b()
319  {
320  }
321 
322  template <typename E>
323  inline
324  Function_vv2b<E>::Function_vv2b(const Function_vv2b<E>& rhs)
325  : Function<E>(rhs)
326  {
327  }
328 
329 # endif // ! MLN_INCLUDE_ONLY
330 
331 } // end of namespace mln
332 
333 
334 #endif // ! MLN_CORE_CONCEPT_FUNCTION_HH