Milena (Olena)  User documentation 2.0a Id
 All Classes Namespaces Functions Variables Typedefs Enumerator Groups Pages
pw/image.hh
1 // Copyright (C) 2007, 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_PW_IMAGE_HH
27 # define MLN_PW_IMAGE_HH
28 
32 
33 # include <mln/pw/internal/image_base.hh>
34 # include <mln/core/concept/function.hh>
35 # include <mln/value/set.hh>
36 
37 
38 namespace mln
39 {
40 
41  // Forward declaration.
42  namespace pw { template <typename F, typename S> class image; }
43 
44 
45  // Properties
46 
47  namespace trait
48  {
49 
50  template <typename F, typename S>
51  struct image_< pw::image<F,S> >
52  : pw_image_<F,S, pw::image<F,S> >
53  {
54  };
55 
56  } // end of namespace mln::traits.
57 
58 
59  namespace internal
60  {
61 
63  template <typename F, typename S>
64  struct data< mln::pw::image<F,S> >
65  {
66  data(const F& f, const S& ps);
67  F f_;
68  S domain_;
69  };
70 
71  } // end of namespace mln::internal
72 
73 
76  template <typename F, typename S>
77  pw::image<F,S>
78  operator | (const Function_v2v<F>& f, const Site_Set<S>& ps);
79 
80 
81  namespace pw
82  {
83 
90  //
91  template <typename F, typename S>
92  class image :
93  public pw::internal::image_base< F, S, image<F,S> >
94  {
95  typedef pw::internal::image_base< F, S, image<F,S> > super_;
96 
97  public:
99  typedef image< tag::function_<F>, tag::domain_<S> > skeleton;
100 
102  image();
103 
105  image(const Function_v2v<F>& f, const Site_Set<S>& ps);
106 
107  };
108 
109  } // end of namespace mln::pw
110 
111 
113 
114  template <typename F, typename S, typename E, typename J>
115  void init_(tag::image_t, pw::image<F,S>& target, const Image<J>& model);
116 
117 
118 # ifndef MLN_INCLUDE_ONLY
119 
121 
122  template <typename F, typename S, typename E, typename J>
123  void init_(tag::image_t, pw::image<F,S>& target, const Image<J>& model)
124  {
125  F f;
126  init_(tag::function, f, exact(model));
127  S s;
128  init_(tag::domain, s, exact(model));
129  target.init_(f, s);
130  }
131 
132 
133  // Operator.
134 
135  template <typename F, typename S>
136  inline
137  pw::image<F,S>
138  operator | (const Function_v2v<F>& f, const Site_Set<S>& ps)
139  {
140  pw::image<F,S> tmp(f, ps);
141  return tmp;
142  }
143 
144 
145  // data< pw::image >
146 
147  namespace internal
148  {
149 
150  template <typename F, typename S>
151  inline
152  data< mln::pw::image<F,S> >::data(const F& f, const S& ps)
153  : f_(f),
154  domain_(ps)
155  {
156  }
157 
158  } // end of namespace mln::internal
159 
160 
161 
162  // pw::image<F,S>
163 
164  namespace pw
165  {
166 
167  template <typename F, typename S>
168  inline
170  {
171  }
172 
173  template <typename F, typename S>
174  inline
176  {
177  this->data_ = new mln::internal::data< image<F,S> >(exact(f), exact(ps));
178  }
179 
180 
181  } // end of namespace mln::pw
182 
183 # endif // ! MLN_INCLUDE_ONLY
184 
185 } // end of namespace mln
186 
187 
188 #endif // ! MLN_PW_IMAGE_HH