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