Milena (Olena)  User documentation 2.0a Id
 All Classes Namespaces Functions Variables Typedefs Enumerator Groups Pages
from_value_to_value.hh
1 // Copyright (C) 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_CONVERT_IMPL_FROM_VALUE_TO_VALUE_HH
27 # define MLN_CONVERT_IMPL_FROM_VALUE_TO_VALUE_HH
28 
34 
35 
36 # include <utility>
37 # include <mln/core/concept/image.hh>
38 # include <mln/core/concept/site_set.hh>
39 # include <mln/value/concept/all.hh>
40 
41 # include <mln/core/site_set/p_run.hh>
42 # include <mln/metal/converts_to.hh>
43 
44 # include <mln/convert/from_to.hxx>
45 
46 namespace mln
47 {
48 
49  namespace convert
50  {
51 
52  namespace impl
53  {
54 
56  template <typename V, typename W>
57  void
58  from_value_to_value(const Value<V>& from, Value<W>& to);
59 
61  template <typename V>
62  void
63  from_value_to_value(const Value<V>& from, Value<V>& to);
64 
65 
66 
67 # ifndef MLN_INCLUDE_ONLY
68 
69  // Case 1:
70 
71  template <typename V, typename W>
72  void
73  from_value_to_value_(const mln::value::Vectorial<V>& from,
74  mln::value::Vectorial<W>& to)
75  {
76  exact(to) = exact(from).to_equiv();
77  }
78 
79  // Case 2:
80 
81  template <typename V, typename W>
82  void
83  from_value_to_value_(const mln::value::Scalar<V>& from,
84  mln::value::Scalar<W>& to)
85  {
86  exact(to) = exact(from).to_equiv();
87  }
88 
89  template <typename V, typename W>
90  inline
91  void
92  from_value_to_value_(const Value<V>& from, Value<W>& to)
93  {
94  // No concept based conversion. Trying to find more specific
95  // conversion with other from_to overloads.
96  convert::over_load::from_to_(exact(from), exact(to));
97  }
98 
99 
100  // Facades.
101 
102  template <typename V, typename W>
103  inline
104  void
105  from_value_to_value(const Value<V>& from, Value<W>& to)
106  {
107  from_value_to_value_(exact(from), exact(to));
108  }
109 
110  template <typename V>
111  inline
112  void
113  from_value_to_value(const Value<V>& from, Value<V>& to)
114  {
115  exact(to) = exact(from);
116  }
117 
118 # endif // ! MLN_INCLUDE_ONLY
119 
120  } // end of namespace mln::convert::impl
121 
122  } // end of namespace mln::convert
123 
124 } // end of namespace mln
125 
126 
127 #endif // ! MLN_CONVERT_IMPL_FROM_VALUE_TO_VALUE_HH