$extrastylesheet
Olena  User documentation 2.1
An Image Processing Platform
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
ch_value.hh
1 // Copyright (C) 2007, 2008, 2009, 2013 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_TRAIT_CH_VALUE_HH
28 # define MLN_TRAIT_CH_VALUE_HH
29 
33 
34 # include <mln/tag/skeleton.hh>
35 # include <mln/trait/image_from_grid.hh>
36 # include <mln/trait/ch_function_value.hh>
37 
38 
43 # define mln_ch_value(I, V) typename mln::trait::ch_value< I, V >::ret
44 
49 # define mln_ch_value_(I, V) mln::trait::ch_value< I, V >::ret
50 
51 
52 
53 namespace mln
54 {
55 
56  // Forward declarations.
57  namespace algebra { template <unsigned n, typename T> class vec; }
58  template <typename G, typename F> class p_edges;
59  template <typename G, typename F> class p_vertices;
60  template <typename P, typename V, typename G> class vertex_image;
61  template <typename P, typename V, typename G> class edge_image;
62  template <typename I> class labeled_image;
63  namespace pw { template <typename F, typename S> class image; }
64 
65 
66 
67  namespace trait
68  {
69 
70  // Forward declaration.
71  template <typename I, typename V> struct ch_value;
72 
73 
74  namespace impl
75  {
76 
77  // Declaration.
78  template <typename I, typename V> struct ch_value_;
79 
80  template <typename I, typename V>
81  struct ch_value_< tag::image_<I>, V >
82  {
83  typedef mln_ch_value(I, V) ret;
84  };
85 
86  template < template <class> class M, typename T,
87  typename V >
88  struct ch_value_< M< tag::value_<T> >, V >
89  {
90  typedef M< V > ret;
91  };
92 
93  template < template <class> class M, typename I,
94  typename V >
95  struct ch_value_< M< tag::image_<I> >, V >
96  {
97  typedef M< mln_ch_value(I, V) > ret;
98  };
99 
100  template < template <class, class> class M, typename T, typename I,
101  typename V >
102  struct ch_value_< M< tag::value_<T>, tag::image_<I> >, V >
103  {
104  typedef mln_ch_value(I, V) ret;
105  };
106 
107  template < template <class, class> class M, typename P, typename T,
108  typename V >
109  struct ch_value_< M< tag::psite_<P>, tag::value_<T> >, V >
110  {
111  typedef M< P, V > ret;
112  };
113 
114  template < template <class, class> class M, typename I1, typename I2,
115  typename V >
116  struct ch_value_< M< tag::image_<I1>, tag::image_<I2> >, V >
117  {
118  typedef M< mln_ch_value(I1, V), mln_ch_value(I2, V) > ret;
119  };
120 
121  template < template <class, class> class M, typename I, typename E,
122  typename V >
123  struct ch_value_< M< tag::image_<I>, tag::ext_<E> >, V >
124  {
125  typedef M< mln_ch_value(I, V), E > ret;
126  };
127 
128  // For mln::complex_image<D, G, T>.
129  template < template <unsigned, class, class> class M,
130  unsigned D, typename G, typename T, typename V >
131  struct ch_value_< M< D, tag::psite_<G>, tag::value_<T> >, V >
132  {
133  typedef M< D, G, V > ret;
134  };
135 
136  // For mln::neighb::image<I, N>.
137  template < template <class, class> class M, typename I, typename N,
138  typename V >
139  struct ch_value_< M< tag::image_<I>, tag::neighb_<N> >, V >
140  {
141  typedef M < mln_ch_value(I, V), N > ret;
142  };
143 
144  template < template <class, class> class M, typename I, typename S,
145  typename V >
146  struct ch_value_< M< tag::image_<I>, tag::domain_<S> >, V >
147  {
148  typedef M< mln_ch_value(I, V), S > ret;
149  };
150 
151  template < template <class, class> class M, typename F, typename S,
152  typename V >
153  struct ch_value_< M< tag::function_<F>, tag::domain_<S> >, V >
154  {
155  // FIXME: what about S::site having no grid?
156  typedef mln_deduce(S, site, grid) grid;
157  typedef typename image_from_grid< grid, V >::ret ret;
158  };
159 
160 
161  // Graph image based on p_edges
162  template < typename F,
163  typename G, typename FP,
164  typename V >
165  struct ch_value_< pw::image< tag::function_<F>, tag::domain_<p_edges<G, FP> > >, V >
166  {
168  };
169 
170  // Graph image based on p_vertices
171  template < typename F,
172  typename G, typename FP,
173  typename V >
174  struct ch_value_< pw::image< tag::function_<F>, tag::domain_<p_vertices<G, FP> > >, V >
175 
176  {
178  };
179 
180  // Vertex Image
181  template < typename P, typename V1, typename G, typename V2>
182  struct ch_value_< vertex_image< tag::psite_<P>,
183  tag::value_<V1>,
184  tag::graph_<G> >,
185  V2 >
186  {
188  };
189 
190  // Edge Image
191  template < typename P, typename V1, typename G, typename V2>
192  struct ch_value_< edge_image< tag::psite_<P>,
193  tag::value_<V1>,
194  tag::graph_<G> >,
195  V2 >
196  {
197  typedef edge_image< P, V2, G > ret;
198  };
199 
200  // Labeled image
201  template < typename I, typename V>
202  struct ch_value_< labeled_image< tag::image_<I> >,
203  V >
204  {
205  typedef mln_ch_value(I,V) ret;
206  };
207 
208 
209  template < template <class, class> class M, typename T, typename S,
210  typename V >
211  struct ch_value_< M< tag::value_<T>, tag::domain_<S> >, V >
212  {
213  // FIXME: what about S::site having no grid?
214  typedef mln_deduce(S, site, grid) grid;
215  typedef typename image_from_grid< grid, V >::ret ret;
216  };
217 
218 
219  template < template <class, class> class M, typename I, typename F,
220  typename V >
221  struct ch_value_< M< tag::image_<I>, tag::function_<F> >, V >
222  {
223  typedef M< mln_ch_value(I, V), F > ret;
224  };
225 
226  } // end of namespace mln::trait::impl
227 
228 
229 
284  template <typename I, typename V>
285  struct ch_value
286  {
287  typedef typename I::skeleton skeleton;
288  typedef typename impl::ch_value_<skeleton, V>::ret ret;
289  };
290 
291  } // end of namespace mln::trait
292 
293 } // end of namespace mln
294 
295 
296 #endif // ! MLN_TRAIT_CH_VALUE_HH