Milena (Olena)  User documentation 2.0a Id
 All Classes Namespaces Functions Variables Typedefs Enumerator Groups Pages
coord_impl.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_CORE_INTERNAL_COORD_IMPL_HH
27 # define MLN_CORE_INTERNAL_COORD_IMPL_HH
28 
34 # include <mln/core/internal/force_exact.hh>
35 
36 
37 namespace mln
38 {
39 
40  namespace internal
41  {
42 
43 
45 
46 
47  /* Implementation class to equip generalized points with
48  * explicit access to their coordinates.
49  *
50  */
51  template <unsigned n, typename C, typename E>
52  struct coord_impl_;
53 
54  template <typename C, typename E>
55  struct coord_impl_<1, C, E>
56  {
57  const C& ind() const;
58  private:
59  typedef coord_impl_<1, C, E> self_;
60 
61  };
62 
63  template <typename C, typename E>
64  struct coord_impl_<2, C, E>
65  {
66  const C&row() const;
67  const C&col() const;
68  };
69 
70  template <typename C, typename E>
71  struct coord_impl_<3, C, E>
72  {
73  const C&sli() const;
74  const C&row() const;
75  const C&col() const;
76  };
77 
78 
79  // mutable_coord_impl
80 
81  template <unsigned n, typename C, typename E>
82  struct mutable_coord_impl_;
83 
84  template <typename C, typename E>
85  struct mutable_coord_impl_<1, C, E>
86  {
87  const C& ind() const;
88  C& ind();
89  };
90 
91  template <typename C, typename E>
92  struct mutable_coord_impl_<2, C, E>
93  {
94  const C& row() const;
95  C& row();
96  const C& col() const;
97  C& col();
98  };
99 
100  template <typename C, typename E>
101  struct mutable_coord_impl_<3, C, E>
102  {
103  const C& sli() const;
104  C& sli();
105  const C& row() const;
106  C& row();
107  const C& col() const;
108  C& col();
109  };
110 
111 
112 # ifndef MLN_INCLUDE_ONLY
113 
114  // coord_impl
115 
116  // 1
117 
118  template <typename C, typename E>
119  inline
120  const C& coord_impl_<1, C, E>::ind() const
121  {
122  return internal::force_exact<E>(*this)[0];
123  }
124 
125  // 2
126 
127  template <typename C, typename E>
128  inline
129  const C& coord_impl_<2, C, E>::row() const
130  {
131  return internal::force_exact<E>(*this)[0];
132  }
133 
134  template <typename C, typename E>
135  inline
136  const C& coord_impl_<2, C, E>::col() const
137  {
138  return internal::force_exact<E>(*this)[1];
139  }
140 
141  // 3
142 
143  template <typename C, typename E>
144  inline
145  const C& coord_impl_<3, C, E>::sli() const
146  {
147  return internal::force_exact<E>(*this)[0];
148  }
149 
150  template <typename C, typename E>
151  inline
152  const C& coord_impl_<3, C, E>::row() const
153  {
154  return internal::force_exact<E>(*this)[1];
155  }
156 
157  template <typename C, typename E>
158  inline
159  const C& coord_impl_<3, C, E>::col() const
160  {
161  return internal::force_exact<E>(*this)[2];
162  }
163 
164 
165  // mutable_coord_impl
166 
167  // 1
168 
169  template <typename C, typename E>
170  inline
171  const C& mutable_coord_impl_<1, C, E>::ind() const
172  {
173  return internal::force_exact<E>(*this)[0];
174  }
175 
176  template <typename C, typename E>
177  inline
178  C& mutable_coord_impl_<1, C, E>::ind()
179  {
180  return internal::force_exact<E>(*this)[0];
181  }
182 
183  // 2
184 
185  template <typename C, typename E>
186  inline
187  const C& mutable_coord_impl_<2, C, E>::row() const
188  {
189  return internal::force_exact<E>(*this)[0];
190  }
191 
192  template <typename C, typename E>
193  inline
194  C& mutable_coord_impl_<2, C, E>::row()
195  {
196  return internal::force_exact<E>(*this)[0];
197  }
198 
199  template <typename C, typename E>
200  inline
201  const C& mutable_coord_impl_<2, C, E>::col() const
202  {
203  return internal::force_exact<E>(*this)[1];
204  }
205 
206  template <typename C, typename E>
207  inline
208  C& mutable_coord_impl_<2, C, E>::col()
209  {
210  return internal::force_exact<E>(*this)[1];
211  }
212 
213  // 3
214 
215  template <typename C, typename E>
216  inline
217  const C& mutable_coord_impl_<3, C, E>::sli() const
218  {
219  return internal::force_exact<E>(*this)[0];
220  }
221 
222  template <typename C, typename E>
223  inline
224  C& mutable_coord_impl_<3, C, E>::sli()
225  {
226  return internal::force_exact<E>(*this)[0];
227  }
228 
229  template <typename C, typename E>
230  inline
231  const C& mutable_coord_impl_<3, C, E>::row() const
232  {
233  return internal::force_exact<E>(*this)[1];
234  }
235 
236  template <typename C, typename E>
237  inline
238  C& mutable_coord_impl_<3, C, E>::row()
239  {
240  return internal::force_exact<E>(*this)[1];
241  }
242 
243  template <typename C, typename E>
244  inline
245  const C& mutable_coord_impl_<3, C, E>::col() const
246  {
247  return internal::force_exact<E>(*this)[2];
248  }
249 
250  template <typename C, typename E>
251  inline
252  C& mutable_coord_impl_<3, C, E>::col()
253  {
254  return internal::force_exact<E>(*this)[2];
255  }
256 
257 # endif // ! MLN_INCLUDE_ONLY
258 
259  } // end of namespace mln::internal
260 
261 } // end of namespace mln
262 
263 
264 #endif // ! MLN_CORE_INTERNAL_COORD_IMPL_HH