$extrastylesheet
Olena  User documentation 2.1
An Image Processing Platform
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
image_identity.hh
1 // Copyright (C) 2007, 2008, 2009, 2012, 2013 EPITA Research and
2 // Development 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_CORE_INTERNAL_IMAGE_IDENTITY_HH
28 # define MLN_CORE_INTERNAL_IMAGE_IDENTITY_HH
29 
36 
37 # include <mln/core/internal/image_morpher.hh>
38 
39 
40 namespace mln
41 {
42 
43  namespace internal
44  {
45 
46 
47  // Fastest.
48 
49  template <typename trait_speed, typename I, typename E>
51  {
52  // Nothing.
53  };
54 
55  template <typename I, typename E>
56  struct image_identity_impl__fastest< mln::trait::image::speed::fastest, I, E >
57  {
58  private:
59 
60  mlc_const(I)& del_() const
61  {
62  return * internal::force_exact<const E>(*this).delegatee_();
63  }
64 
65  I& del_()
66  {
67  return * internal::force_exact<E>(*this).delegatee_();
68  }
69 
70  public:
71 
72  int delta_offset(const mln_deduce(I, psite, delta)& dp) const
73  {
74  return del_().delta_offset(dp);
75  }
76 
77  mln_site(I) point_at_offset(unsigned i) const
78  {
79  return del_().point_at_offset(i);
80  }
81 
82  unsigned border() const
83  {
84  return del_().border();
85  }
86 
87  mln_qlf_value(I)* buffer()
88  {
89  return del_().buffer();
90  }
91 
92  const mln_value(I)* buffer() const
93  {
94  return del_().buffer();
95  }
96 
97  mln_rvalue(I) element(unsigned i) const
98  {
99  return del_().element(i);
100  }
101 
102  mln_lvalue(I) element(unsigned i)
103  {
104  return del_().element(i);
105  }
106 
107  unsigned nelements() const
108  {
109  return del_().nelements();
110  }
111  };
112 
113  // Facade.
114 
115  template <typename I, typename E>
117  : image_identity_impl__fastest< mln_trait_image_speed(E), I, E >
118  {
119  };
120 
121 
122 
129  template <typename I, typename S, typename E>
131  : public image_identity_impl<I, E>,
132  public image_morpher<I, mln_value(I), S, E>
133  {
134  public:
135 
137  typedef mln_value(I) value;
138 
140  typedef mln_rvalue(I) rvalue;
141 
143  typedef mln_morpher_lvalue(I) lvalue;
144 
146  rvalue operator()(const mln_psite(S)& p) const;
147 
149  lvalue operator()(const mln_psite(S)& p);
150 
151  // FIXME Matthieu: Doc! Cf. core/concept/doc/image
152  const mln_domain(I)& domain() const;
153  bool has(const mln_psite(I)& p) const;
154 
155  protected:
156 
158  image_identity();
159  };
160 
161 
162 
163 # ifndef MLN_INCLUDE_ONLY
164 
165  template <typename I, typename S, typename E>
166  inline
168  {
169  }
170 
171  template <typename I, typename S, typename E>
172  inline
173  mln_rvalue(I)
174  image_identity<I, S, E>::operator()(const mln_psite(S)& p) const
175  {
176  mln_precondition(this->delegatee_() != 0);
177  return this->delegatee_()->operator()(p);
178  }
179 
180  template <typename I, typename S, typename E>
181  inline
182  typename image_identity<I, S, E>::lvalue
183  image_identity<I, S, E>::operator()(const mln_psite(S)& p)
184  {
185  mln_precondition(this->delegatee_() != 0);
186  return this->delegatee_()->operator()(p);
187  }
188 
189  template <typename I, typename S, typename E>
190  inline
191  const mln_domain(I)&
193  {
194  mln_precondition(this->delegatee_() != 0);
195  return this->delegatee_()->domain();
196  }
197 
198  template <typename I, typename S, typename E>
199  inline
200  bool
201  image_identity<I, S, E>::has(const mln_psite(I)& p) const
202  {
203  mln_precondition(this->delegatee_() != 0);
204  return this->delegatee_()->has(p);
205  }
206 
207 # endif // ! MLN_INCLUDE_ONLY
208 
209  } // end of namespace mln::internal
210 
211 } // end of namespace mln
212 
213 
214 #endif // ! MLN_CORE_INTERNAL_IMAGE_IDENTITY_HH