$extrastylesheet
Olena  User documentation 2.1
An Image Processing Platform
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
functions.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_TRAIT_FUNCTIONS_HH
27 # define MLN_TRAIT_FUNCTIONS_HH
28 
29 # include <mln/metal/bexpr.hh>
30 # include <mln/metal/if.hh>
31 # include <mln/fun/param.hh>
32 # include <mln/trait/next/solve.hh>
33 
34 # define mln_trait_fun_is_assignable(Fun) typename mln::trait::function::is_assignable< Fun >::ret
35 # define mln_trait_fun_is_assignable_(Fun) mln::trait::function::is_assignable< Fun >::ret
36 # define mln_trait_fun_is_assignable__1comma(A, B) typename mln::trait::function::is_assignable< A, B >::ret
37 # define mln_trait_fun_is_assignable__1comma_(A, B) mln::trait::function::is_assignable< A, B >::ret
38 
39 # define mln_trait_fun_is_parametrable(Fun) typename mln::trait::function::is_parametrable< Fun >::ret
40 # define mln_trait_fun_is_parametrable_(Fun) mln::trait::function::is_parametrable< Fun >::ret
41 
42 # define mln_trait_fun_lvalue(Fun) typename mln::trait::function::get_lvalue< Fun >::ret
43 # define mln_trait_fun_param(Fun) typename mln::trait::function::get_param< Fun >::ret
44 # define mln_trait_fun_storage(Fun) typename mln::trait::function::get_storage< Fun >::ret
45 
46 namespace mln
47 {
48 
49  namespace trait
50  {
51 
52  namespace function
53  {
54 
55  namespace internal
56  {
57 
58  namespace introspect
59  {
60 
61  template <typename T>
63  {
64  typedef void ret;
65  };
66 
67  template <>
68  struct except_void_t<void>;
69 
70  // Lvalue solver
71 
72  template <typename T, typename V>
73  struct has_lvalue_t
74  {
75  typedef metal::false_ ret;
76  typedef void type;
77  };
78 
79  template <typename T>
80  struct has_lvalue_t<T, typename except_void_t<typename T::lvalue>::ret>
81  {
82  typedef metal::true_ ret;
83  typedef typename T::lvalue type;
84  };
85 
86  // Parameter solver
87  template <typename T, typename V>
88  struct param_solver;
89 
90  template <typename T, typename V>
92  {
93  typedef typename mln::fun::parameter<T> ret;
94  };
95 
96  template <typename T>
97  struct param_flag_solver<T, typename except_void_t<typename mln::fun::parameter<typename T::flag>::param>::ret>
98  {
100  };
101 
102  template <typename T, typename V>
104  {
106  };
107 
108  template <typename T>
109  struct param_def_solver<T, typename except_void_t<typename mln::fun::parameter<typename T::def>::param>::ret>
110  {
112  };
113 
114  template <typename T, typename V>
116  {
117  };
118 
119  template <typename T>
120  struct param_solver<T, typename except_void_t<typename T::param>::ret>
121  {
122  typedef T ret;
123  };
124 
125  template <typename T, typename V>
126  struct has_param_t
127  {
129  typedef void type;
130  };
131 
132  template <typename T>
133  struct has_param_t<T, typename except_void_t<typename param_solver<T,void>::ret::param>::ret>
134  {
135  typedef metal::true_ ret;
137  };
138 
139  template <typename T, typename V>
140  struct storage_solver;
141 
142  template <typename T, typename V>
144  {
145  typedef typename mln::fun::parameter<T> ret;
146  };
147 
148  template <typename T>
149  struct storage_flag_solver<T, typename except_void_t<typename mln::fun::parameter<typename T::flag>::storage>::ret>
150  {
152  };
153 
154  template <typename T, typename V>
156  {
158  };
159 
160  template <typename T>
161  struct storage_def_solver<T, typename except_void_t<typename mln::fun::parameter<typename T::def>::storage>::ret>
162  {
164  };
165 
166  template <typename T, typename V>
168  {
169  };
170 
171  template <typename T>
172  struct storage_solver<T, typename except_void_t<typename T::storage>::ret>
173  {
174  typedef T ret;
175  };
176 
177  template <typename T, typename V>
179  {
181 
183  typedef typename has_param::type type;
184 
185  template <typename U>
186  static inline
187  const U& compute(const U& t)
188  {
189  return t;
190  }
191 
192  };
193 
194  template <typename T>
195  struct has_storage_t<T, typename except_void_t<typename param_solver<T,void>::ret::storage>::ret>
196  {
197  typedef metal::true_ ret;
198  typedef typename param_solver<T,void>::ret def;
199 
200  typedef typename def::storage type;
201 
202  template <typename U>
203  static inline
204  type compute(const U& p)
205  {
206  return def::compute(p);
207  }
208 
209  };
210 
211  } // end of namespace mln::trait::fun::internal::introspect
212 
213  } // end of namespace mln::trait::fun::internal
214 
215  template <typename F>
217  {
219  };
220 
221  template <typename F>
223  {
225  };
226 
227  template <typename F>
228  struct get_lvalue
229  {
231  };
232 
233  template <typename F>
234  struct get_param
235  {
237  };
238 
239  template <typename F>
240  struct get_storage
241  {
243  };
244 
245  } // end of namespace mln::trait::fun
246 
247  } // end of namespace mln::trait
248 
249 } // end of namespace mln
250 
251 #endif // ! MLN_TRAIT_FUNCTIONS_HH