Milena (Olena)  User documentation 2.0a Id
 All Classes Namespaces Functions Variables Typedefs Enumerator Groups Pages
from_to.hxx
1 // Copyright (C) 2008, 2009, 2010, 2011 EPITA Research and Development
2 // 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_CONVERT_FROM_TO_HXX
28 # define MLN_CONVERT_FROM_TO_HXX
29 
31 
32 // All overloaded "convert::from_to" routines have to be declared in
33 // the present file. It allows for *deferred* use of these routines.
34 
35 # include <mln/core/def/all.hh>
36 # include <mln/core/grids.hh>
37 # include <mln/util/couple.hh>
38 
39 //FIXME: have a forward declaration.
40 # include <vector>
41 # include <set>
42 
43 
44 namespace mln
45 {
46 
47 
48  // Forward declarations.
49 
50  template <typename E> struct Accumulator;
51  template <typename E> struct Gdpoint;
52  template <typename E> struct Gpoint;
53  template <typename E> struct Image;
54  template <typename E> struct Object;
55  template <typename E> struct Proxy;
56  template <typename E> struct Site_Set;
57  template <typename E> struct Value;
58  template <typename E> struct Weighted_Window;
59  template <typename E> struct Window;
60 
61  template <typename G, typename C> struct dpoint;
62  template <typename G, typename C> struct point;
63 
64  template <typename D> class neighb;
65  template <typename D> class window;
66  template <typename D, typename W> struct w_window;
67 
68  template <typename T> struct image1d;
69 
70  namespace algebra {
71  template <unsigned n, typename T> class vec;
72  template <unsigned d, typename C> class h_vec;
73  }
74 
75  namespace fun {
76  namespace i2v {
77  template <typename T> class array;
78  }
79  }
80 
81  namespace histo {
82  template <typename T> struct array;
83  }
84 
85  namespace util {
86  template <typename T> class array;
87  template <typename Tag, typename V> class object_id;
88  }
89 
90  namespace value {
91  namespace qt { struct rgb32; }
92  template <unsigned n> struct rgb;
93  template <typename H, typename S, typename L> class hsl_;
94  template <unsigned n> struct int_u;
95  template <unsigned n> struct label;
96  }
97 
98  // end of Forward declarations.
99 
100 
101 
102  // convert::to
103 
104  namespace convert
105  {
106 
107  template <typename T, typename O>
108  T
109  to(const O& from);
110 
111  } // end of namespace mln::convert
112 
113 
114 
115  // convert::from_to
116 
117  namespace convert
118  {
119 
120  // Facade
121 
122  template <typename F, typename T>
123  void
124  from_to(const F& from, T& to);
125 
126 
127  namespace over_load
128  {
129 
130  // Guard.
131  template <typename F, typename T>
132  void
133  from_to_(const Object<F>&, Object<T>&);
134  // end of Guard.
135 
136  // Object -> Object
137  template <typename T>
138  void
139  from_to_(const Object<T>& from, Object<T>& to);
140 
141  // Object -> Object
142  template <typename T>
143  void
144  from_to_(const T& from, T& to);
145 
146  // point -> point.
147  template <typename G, typename C1, typename C2>
148  inline
149  void
150  from_to_(const point<G,C1>& from, point<G,C2>& to);
151 
152  // algebra::vec -> point
153  template <unsigned n, typename C1, typename G, typename C2>
154  void
155  from_to_(const algebra::vec<n,C1>& from, point<G,C2>& to);
156 
157  // algebra::vec -> point
158  template <unsigned n, typename C1, typename G>
159  void
160  from_to_(const algebra::vec<n,C1>& from, point<G,C1>& to);
161 
162  // algebra::vec -> Gpoint.
163  template <unsigned n, typename T, typename P>
164  void
165  from_to_(const algebra::vec<n,T>& from, Gpoint<P>& to_);
166 
167  // algebra::vec -> rgb.
168  template <typename T, unsigned m>
169  void
170  from_to_(const algebra::vec<3,T>& from, value::rgb<m>& to);
171 
172 
173  // bool -> rgb.
174  template <unsigned m>
175  void
176  from_to_(bool from, value::rgb<m>& to);
177 
178  // rgb32 -> bool
179  void
180  from_to_(const value::qt::rgb32& from, bool& to);
181 
182  // bool -> rgb32
183  void
184  from_to_(const bool& from, value::qt::rgb32& to);
185 
186  // int_u -> rgb.
187  template <unsigned m>
188  void from_to_(const value::int_u<m>& from, value::rgb<m>& to);
189 
190  // int_u -> qt::rgb32.
191  template <unsigned m>
192  void from_to_(const value::int_u<m>& from, value::qt::rgb32& to);
193 
194  // int_u -> label
195  template <unsigned n>
196  void from_to_(const value::int_u<n>& from, value::label<n>& to_);
197 
198  // int_u -> unsigned
199  template <unsigned n>
200  void from_to_(const value::int_u<n>& from, unsigned& to_);
201 
202  // int_u -> bool.
203  template <unsigned n>
204  void
205  from_to_(const value::int_u<n>& from, bool& to_);
206 
207  // int_u -> float
208  template <unsigned n>
209  void from_to_(const value::int_u<n>& from, float& to_);
210 
211  // int_u -> double
212  template <unsigned n>
213  void from_to_(const value::int_u<n>& from, double& to_);
214 
215  // label -> int_u.
216  template <unsigned n>
217  void
218  from_to_(const value::label<n>& from, value::int_u<n>& to_);
219 
220  // label -> bool
221  template <unsigned n>
222  void from_to_(const value::label<n>& from, bool& to_);
223 
224  // int_u<n> -> label<m> with n < m
225  template <unsigned n, unsigned m>
226  void
227  from_to_(const value::int_u<n>& from, value::label<m>& to_);
228 
229  // hsl -> rgb8.
230  template <typename H, typename S, typename L>
231  void from_to_(const value::hsl_<H,S,L>&, value::rgb<8>& to);
232 
233  // hsl -> rgb16.
234  template <typename H, typename S, typename L>
235  void from_to_(const value::hsl_<H,S,L>&, value::rgb<16>& to);
236 
237  // hsl -> qt::rgb32.
238  template <typename H, typename S, typename L>
239  void from_to_(const value::hsl_<H,S,L>&, value::qt::rgb32& to);
240 
241  // rgb to hsl
242  void
243  from_to_(const value::rgb<16>& from, value::hsl_<float,float,float>& to);
244 
245  // rgb to hsl
246  void
247  from_to_(const value::rgb<8>& from, value::hsl_<float,float,float>& to);
248 
249  // rgb -> bool.
250  template <unsigned m>
251  void from_to_(const value::rgb<m>& from, bool& to);
252 
253 
254  // C-array -> Image.
255  template <typename V, unsigned S, typename I>
256  void
257  from_to_(const V (&values)[S], Image<I>& to);
258 
259  // C-array -> w_window
260  template <typename V, unsigned S, typename D, typename W>
261  void
262  from_to_(const V (&weight)[S], w_window<D,W>& to);
263 
264 
265  // C-array -> window2d
266  template <unsigned S>
267  void
268  from_to_(const bool (&values)[S],
269  window< dpoint<grid::square, def::coord> >& win);
270 
271  template <unsigned R, unsigned C>
272  void
273  from_to_(const bool (&values)[R][C],
274  window< dpoint<grid::square, def::coord> >& win);
275 
276 
277  // C-array -> window3d
278  template <unsigned S>
279  void
280  from_to_(const bool (&values)[S],
281  window< dpoint<grid::cube, def::coord> >& win);
282 
283 
284  // C-array -> neighb2d
285  template <unsigned S>
286  void
287  from_to_(const bool (&values)[S],
288  neighb< window< dpoint<grid::square, def::coord> > >& nbh);
289 
290  template <unsigned R, unsigned C>
291  void
292  from_to_(bool const (&values)[R][C],
293  neighb< window< dpoint<grid::square, def::coord> > >& nbh);
294 
295 
296  // C-array -> neighb3d
297  template <unsigned S>
298  void
299  from_to_(const bool (&values)[S],
300  neighb< window< dpoint<grid::cube, def::coord> > >& nbh);
301 
302 
303 
304  // Gdpoint -> point
305  template <typename D>
306  void
307  from_to_(const Gdpoint<D>& from, mln_site(D)& to);
308 
309 
310  // Value -> Value
311  template <typename F, typename T>
312  void
313  from_to_(const Value<F>& from, Value<T>& to);
314 
315  // double-> Value
316  template <typename V>
317  void
318  from_to_(const double& from, Value<V>& to);
319 
320  // double-> unsigned
321  void
322  from_to_(const double& from, unsigned& to);
323 
324  // double-> int
325  void
326  from_to_(const double& from, int& to);
327 
328  // float -> Value
329  template <typename V>
330  void
331  from_to_(const float& from, Value<V>& to);
332 
333  // float -> unsigned
334  void
335  from_to_(const float& from, unsigned& to);
336 
337  // float -> int
338  void
339  from_to_(const float& from, int& to);
340 
341  // int -> Value
342  template <typename T>
343  void
344  from_to_(const int& from, Value<T>& to);
345 
346  // Proxy -> T
347  template <typename P, typename T>
348  void
349  from_to_(const Proxy<P>& from, T& to);
350 
351 
352  // Gpoint -> algebra::vec.
353  template <typename P, unsigned n, typename T>
354  void
355  from_to_(const Gpoint<P>& from, algebra::vec<n,T>& to);
356 
357  // Gpoint -> delta-point
358  template <typename P>
359  void
360  from_to_(const Gpoint<P>& from, mln_delta(P)& to);
361 
362 
363  // Image -> Site_Set.
364  template <typename I, typename S>
365  void
366  from_to_(const Image<I>& from, Site_Set<S>& to);
367 
368  // Image -> w_window
369  template <typename I, typename D, typename W>
370  void
371  from_to_(const Image<I>& from, w_window<D,W>& to);
372 
373 
374  // neighb<W> -> W
375  template <typename W>
376  void
377  from_to_(const mln::neighb<W>& from, W& to);
378 
379  // W -> neighb<W>
380  template <typename W>
381  void
382  from_to_(const W& from, mln::neighb<W>& to);
383 
384 
385  // Window -> Image
386  template <typename W, typename I>
387  void
388  from_to_(const Window<W>& from, Image<I>& to);
389 
390 
391  // w_window -> Image
392  template <typename D, typename W, typename I>
393  void
394  from_to_(const w_window<D,W>& from, Image<I>& to);
395 
396 
397 
398  // util::array<T> -> fun::i2v::array<T>
399  template <typename T>
400  void
401  from_to_(const util::array<T>& from, fun::i2v::array<T>& to);
402 
403  // util::array<T> -> fun::i2v::array<U>
404  template <typename T, typename U>
405  void
406  from_to_(const util::array<T>& from, fun::i2v::array<U>& to);
407 
408  // std::vector<T> -> fun::i2v::array<T>
409  template <typename T>
410  void
411  from_to_(const std::vector<T>& from, fun::i2v::array<T>& to);
412 
413  // std::vector<T> -> fun::i2v::array<U>
414  template <typename T, typename U>
415  void
416  from_to_(const std::vector<T>& from, fun::i2v::array<U>& to);
417 
418  // util::array<T1> -> util::array<T2>
419  template <typename T1, typename T2>
420  void
421  from_to_(const util::array<T1>& from, util::array<T2>& to);
422 
423 
424 
425  // util::array<T1> -> util::array<T2>
426  template <typename T1, typename T2>
427  void
428  from_to_(const util::array<T1>& from, util::array<T2>& to);
429 
430  // fun::i2v::array<T1> -> util::array<T2>
431  template <typename T1, typename T2>
432  void
433  from_to_(const fun::i2v::array<T1>& from, util::array<T2>& to);
434 
435 
436  // Accumulator<A> -> mln_result(A)
437  template <typename A>
438  void
439  from_to_(const Accumulator<A>& from, mln_result(A)& to);
440 
441 
442 
443  // Site_Set -> Image.
444  template <typename S, typename I>
445  void
446  from_to_(const Site_Set<S>& from, Image<I>& to);
447 
448  // Site_Set -> std::set
449  template <typename S, typename P, typename C_>
450  void
451  from_to_(const Site_Set<S>& from, std::set<P,C_>& to);
452 
453  // std::set -> Site_Set
454  template <typename P, typename C_, typename S>
455  void
456  from_to_(const std::set<P,C_>& from, Site_Set<S>& to);
457 
458  // histo::array -> image1d
459  template <typename V, typename T>
460  void
461  from_to_(const histo::array<V>& from, image1d<T>& to);
462 
463  // util::array -> image1d
464  template <typename V, typename T>
465  void
466  from_to_(const util::array<V>& from, image1d<T>& to);
467 
468  // util::couple<T, U> -> util::couple<V, W>
469  template <typename T, typename U, typename V, typename W>
470  void
471  from_to_(const util::couple<T, U>& from, util::couple<V, W>& to)
472  {
473  from_to(from.first(), to.first());
474  from_to(from.second(), to.second());
475  }
476 
477  // util::object_id<Tag,V> -> V.
478  template <typename Tag, typename V>
479  void from_to_(const util::object_id<Tag,V>& from, V& to_);
480 
481  } // end of namespace mln::convert::over_load
482 
483  } // end of namespace mln::convert
484 
485 } // end of namespace mln
486 
487 
488 #endif // ! MLN_CONVERT_FROM_TO_HXX