Milena (Olena)
User documentation 2.0a Id
|
00001 // Copyright (C) 2008, 2009 EPITA Research and Development Laboratory (LRDE) 00002 // 00003 // This file is part of Olena. 00004 // 00005 // Olena is free software: you can redistribute it and/or modify it under 00006 // the terms of the GNU General Public License as published by the Free 00007 // Software Foundation, version 2 of the License. 00008 // 00009 // Olena is distributed in the hope that it will be useful, 00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00012 // General Public License for more details. 00013 // 00014 // You should have received a copy of the GNU General Public License 00015 // along with Olena. If not, see <http://www.gnu.org/licenses/>. 00016 // 00017 // As a special exception, you may use this file as part of a free 00018 // software project without restriction. Specifically, if other files 00019 // instantiate templates or use macros or inline functions from this 00020 // file, or you compile this file and link it with other files to produce 00021 // an executable, this file does not by itself cause the resulting 00022 // executable to be covered by the GNU General Public License. This 00023 // exception does not however invalidate any other reasons why the 00024 // executable file might be covered by the GNU General Public License. 00025 00026 #ifndef MLN_CONVERT_IMPL_FROM_VALUE_TO_VALUE_HH 00027 # define MLN_CONVERT_IMPL_FROM_VALUE_TO_VALUE_HH 00028 00034 00035 00036 # include <utility> 00037 # include <mln/core/concept/image.hh> 00038 # include <mln/core/concept/site_set.hh> 00039 # include <mln/value/concept/all.hh> 00040 00041 # include <mln/core/site_set/p_run.hh> 00042 # include <mln/metal/converts_to.hh> 00043 00044 # include <mln/convert/from_to.hxx> 00045 00046 namespace mln 00047 { 00048 00049 namespace convert 00050 { 00051 00052 namespace impl 00053 { 00054 00056 template <typename V, typename W> 00057 void 00058 from_value_to_value(const Value<V>& from, Value<W>& to); 00059 00061 template <typename V> 00062 void 00063 from_value_to_value(const Value<V>& from, Value<V>& to); 00064 00065 00066 00067 # ifndef MLN_INCLUDE_ONLY 00068 00069 // Case 1: 00070 00071 template <typename V, typename W> 00072 void 00073 from_value_to_value_(const mln::value::Vectorial<V>& from, 00074 mln::value::Vectorial<W>& to) 00075 { 00076 exact(to) = exact(from).to_equiv(); 00077 } 00078 00079 // Case 2: 00080 00081 template <typename V, typename W> 00082 void 00083 from_value_to_value_(const mln::value::Scalar<V>& from, 00084 mln::value::Scalar<W>& to) 00085 { 00086 exact(to) = exact(from).to_equiv(); 00087 } 00088 00089 template <typename V, typename W> 00090 inline 00091 void 00092 from_value_to_value_(const Value<V>& from, Value<W>& to) 00093 { 00094 // No concept based conversion. Trying to find more specific 00095 // conversion with other from_to overloads. 00096 convert::over_load::from_to_(exact(from), exact(to)); 00097 } 00098 00099 00100 // Facades. 00101 00102 template <typename V, typename W> 00103 inline 00104 void 00105 from_value_to_value(const Value<V>& from, Value<W>& to) 00106 { 00107 from_value_to_value_(exact(from), exact(to)); 00108 } 00109 00110 template <typename V> 00111 inline 00112 void 00113 from_value_to_value(const Value<V>& from, Value<V>& to) 00114 { 00115 exact(to) = exact(from); 00116 } 00117 00118 # endif // ! MLN_INCLUDE_ONLY 00119 00120 } // end of namespace mln::convert::impl 00121 00122 } // end of namespace mln::convert 00123 00124 } // end of namespace mln 00125 00126 00127 #endif // ! MLN_CONVERT_IMPL_FROM_VALUE_TO_VALUE_HH