Milena (Olena)
User documentation 2.0a Id
|
00001 // Copyright (C) 2007, 2008, 2009 EPITA Research and Development 00002 // Laboratory (LRDE) 00003 // 00004 // This file is part of Olena. 00005 // 00006 // Olena is free software: you can redistribute it and/or modify it under 00007 // the terms of the GNU General Public License as published by the Free 00008 // Software Foundation, version 2 of the License. 00009 // 00010 // Olena is distributed in the hope that it will be useful, 00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 // General Public License for more details. 00014 // 00015 // You should have received a copy of the GNU General Public License 00016 // along with Olena. If not, see <http://www.gnu.org/licenses/>. 00017 // 00018 // As a special exception, you may use this file as part of a free 00019 // software project without restriction. Specifically, if other files 00020 // instantiate templates or use macros or inline functions from this 00021 // file, or you compile this file and link it with other files to produce 00022 // an executable, this file does not by itself cause the resulting 00023 // executable to be covered by the GNU General Public License. This 00024 // exception does not however invalidate any other reasons why the 00025 // executable file might be covered by the GNU General Public License. 00026 00027 #ifndef MLN_TRAIT_CH_VALUE_HH 00028 # define MLN_TRAIT_CH_VALUE_HH 00029 00033 00034 # include <mln/tag/skeleton.hh> 00035 # include <mln/trait/image_from_grid.hh> 00036 # include <mln/trait/ch_function_value.hh> 00037 00038 00039 # define mln_ch_value(I, V) typename mln::trait::ch_value< I, V >::ret 00040 # define mln_ch_value_(I, V) mln::trait::ch_value< I, V >::ret 00041 00042 00043 00044 namespace mln 00045 { 00046 00047 // Forward declarations. 00048 namespace algebra { template <unsigned n, typename T> class vec; } 00049 template <typename G, typename F> class p_edges; 00050 template <typename G, typename F> class p_vertices; 00051 template <typename P, typename V, typename G> class vertex_image; 00052 template <typename P, typename V, typename G> class edge_image; 00053 template <typename I> class labeled_image; 00054 namespace pw { template <typename F, typename S> class image; } 00055 00056 00057 00058 namespace trait 00059 { 00060 00061 // Forward declaration. 00062 template <typename I, typename V> struct ch_value; 00063 00064 00065 namespace impl 00066 { 00067 00068 // Declaration. 00069 template <typename I, typename V> struct ch_value_; 00070 00071 template <typename I, typename V> 00072 struct ch_value_< tag::image_<I>, V > 00073 { 00074 typedef mln_ch_value(I, V) ret; 00075 }; 00076 00077 template < template <class> class M, typename T, 00078 typename V > 00079 struct ch_value_< M< tag::value_<T> >, V > 00080 { 00081 typedef M< V > ret; 00082 }; 00083 00084 template < template <class> class M, typename I, 00085 typename V > 00086 struct ch_value_< M< tag::image_<I> >, V > 00087 { 00088 typedef M< mln_ch_value(I, V) > ret; 00089 }; 00090 00091 template < template <class, class> class M, typename T, typename I, 00092 typename V > 00093 struct ch_value_< M< tag::value_<T>, tag::image_<I> >, V > 00094 { 00095 typedef mln_ch_value(I, V) ret; 00096 }; 00097 00098 template < template <class, class> class M, typename P, typename T, 00099 typename V > 00100 struct ch_value_< M< tag::psite_<P>, tag::value_<T> >, V > 00101 { 00102 typedef M< P, V > ret; 00103 }; 00104 00105 template < template <class, class> class M, typename I1, typename I2, 00106 typename V > 00107 struct ch_value_< M< tag::image_<I1>, tag::image_<I2> >, V > 00108 { 00109 typedef M< mln_ch_value(I1, V), mln_ch_value(I2, V) > ret; 00110 }; 00111 00112 template < template <class, class> class M, typename I, typename E, 00113 typename V > 00114 struct ch_value_< M< tag::image_<I>, tag::ext_<E> >, V > 00115 { 00116 typedef M< mln_ch_value(I, V), E > ret; 00117 }; 00118 00119 // For mln::complex_image<D, G, T>. 00120 template < template <unsigned, class, class> class M, 00121 unsigned D, typename G, typename T, typename V > 00122 struct ch_value_< M< D, tag::psite_<G>, tag::value_<T> >, V > 00123 { 00124 typedef M< D, G, V > ret; 00125 }; 00126 00127 // For mln::neighb::image<I, N>. 00128 template < template <class, class> class M, typename I, typename N, 00129 typename V > 00130 struct ch_value_< M< tag::image_<I>, tag::neighb_<N> >, V > 00131 { 00132 typedef M < mln_ch_value(I, V), N > ret; 00133 }; 00134 00135 template < template <class, class> class M, typename I, typename S, 00136 typename V > 00137 struct ch_value_< M< tag::image_<I>, tag::domain_<S> >, V > 00138 { 00139 typedef M< mln_ch_value(I, V), S > ret; 00140 }; 00141 00142 template < template <class, class> class M, typename F, typename S, 00143 typename V > 00144 struct ch_value_< M< tag::function_<F>, tag::domain_<S> >, V > 00145 { 00146 // FIXME: what about S::site having no grid? 00147 typedef mln_deduce(S, site, grid) grid; 00148 typedef typename image_from_grid< grid, V >::ret ret; 00149 }; 00150 00151 00152 // Graph image based on p_edges 00153 template < typename F, 00154 typename G, typename FP, 00155 typename V > 00156 struct ch_value_< pw::image< tag::function_<F>, tag::domain_<p_edges<G, FP> > >, V > 00157 { 00158 typedef pw::image< mln_ch_function_value(F, V), p_edges<G, FP> > ret; 00159 }; 00160 00161 // Graph image based on p_vertices 00162 template < typename F, 00163 typename G, typename FP, 00164 typename V > 00165 struct ch_value_< pw::image< tag::function_<F>, tag::domain_<p_vertices<G, FP> > >, V > 00166 00167 { 00168 typedef pw::image< mln_ch_function_value(F, V), p_vertices<G, FP> > ret; 00169 }; 00170 00171 // Vertex Image 00172 template < typename P, typename V1, typename G, typename V2> 00173 struct ch_value_< vertex_image< tag::psite_<P>, 00174 tag::value_<V1>, 00175 tag::graph_<G> >, 00176 V2 > 00177 { 00178 typedef vertex_image< P, V2, G > ret; 00179 }; 00180 00181 // Edge Image 00182 template < typename P, typename V1, typename G, typename V2> 00183 struct ch_value_< edge_image< tag::psite_<P>, 00184 tag::value_<V1>, 00185 tag::graph_<G> >, 00186 V2 > 00187 { 00188 typedef edge_image< P, V2, G > ret; 00189 }; 00190 00191 // Labeled image 00192 template < typename I, typename V> 00193 struct ch_value_< labeled_image< tag::image_<I> >, 00194 V > 00195 { 00196 typedef mln_ch_value(I,V) ret; 00197 }; 00198 00199 00200 template < template <class, class> class M, typename T, typename S, 00201 typename V > 00202 struct ch_value_< M< tag::value_<T>, tag::domain_<S> >, V > 00203 { 00204 // FIXME: what about S::site having no grid? 00205 typedef mln_deduce(S, site, grid) grid; 00206 typedef typename image_from_grid< grid, V >::ret ret; 00207 }; 00208 00209 00210 template < template <class, class> class M, typename I, typename F, 00211 typename V > 00212 struct ch_value_< M< tag::image_<I>, tag::function_<F> >, V > 00213 { 00214 typedef M< mln_ch_value(I, V), F > ret; 00215 }; 00216 00217 } // end of namespace mln::trait::impl 00218 00219 00220 template <typename I, typename V> 00221 struct ch_value 00222 { 00223 typedef typename I::skeleton skeleton; 00224 typedef typename impl::ch_value_<skeleton, V>::ret ret; 00225 }; 00226 00227 } // end of namespace mln::trait 00228 00229 } // end of namespace mln 00230 00231 00232 #endif // ! MLN_TRAIT_CH_VALUE_HH