Milena (Olena)  User documentation 2.0a Id
 All Classes Namespaces Functions Variables Typedefs Enumerator Groups Pages
point3d.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_ALIAS_POINT3D_HH
27 # define MLN_CORE_ALIAS_POINT3D_HH
28 
33 
34 # include <mln/core/point.hh>
35 // For site_const_impl and site_mutable_impl:
36 # include <mln/core/concept/site_proxy.hh>
37 # include <mln/core/internal/force_exact.hh>
38 
39 namespace mln
40 {
41 
45 
49 
50  namespace internal
51  {
52 
53  // Specialization.
54 
55  template <typename C, typename E>
56  struct subject_impl< const point<grid::cube, C>, E >
57  : subject_point_impl< point<grid::cube, C>, E >
58  {
59  typedef C coord;
60  enum { dim = 3 };
61 
62  typedef const C& row_t;
63  const C& row() const;
64 
65  typedef const C& col_t;
66  const C& col() const;
67 
68  typedef const C& sli_t;
69  const C& sli() const;
70 
71  const C& operator[](unsigned i) const;
72  const C& last_coord() const;
73  private:
74  const E& exact_() const;
75  };
76 
77 
78  // Specialization for point<M,C>.
79 
80  template <typename C, typename E>
81  struct subject_impl< point<grid::cube, C>, E > :
82  subject_impl< const point<grid::cube, C>, E >
83  {
84  private:
85  typedef subject_impl< const point<grid::cube, C>, E > super_;
86  E& exact_();
87  public:
88 
89  using super_::row;
90  C& row();
91 
92  using super_::col;
93  C& col();
94 
95  using super_::sli;
96  C& sli();
97 
98  using super_::operator[];
99  C& operator[](unsigned i);
100  };
101 
102 
103 
104 # ifndef MLN_INCLUDE_ONLY
105 
106  // subject_impl
107 
108  template <typename C, typename E>
109  inline
110  const C&
111  subject_impl< const point<grid::cube, C>, E >::row() const
112  {
113  return exact_().get_subject().row();
114  }
115 
116  template <typename C, typename E>
117  inline
118  const C&
119  subject_impl< const point<grid::cube, C>, E >::col() const
120  {
121  return exact_().get_subject().col();
122  }
123 
124  template <typename C, typename E>
125  inline
126  const C&
127  subject_impl< const point<grid::cube, C>, E >::sli() const
128  {
129  return exact_().get_subject().sli();
130  }
131 
132  template <typename C, typename E>
133  inline
134  const C&
135  subject_impl< const point<grid::cube, C>, E >::operator[](unsigned i) const
136  {
137  mln_precondition(i < 3);
138  return exact_().get_subject()[i];
139  }
140 
141  template <typename C, typename E>
142  inline
143  const C&
144  subject_impl< const point<grid::cube, C>, E >::last_coord() const
145  {
146  return this->col();
147  }
148 
149  template <typename C, typename E>
150  inline
151  const E&
152  subject_impl< const point<grid::cube, C>, E >::exact_() const
153  {
154  return internal::force_exact<const E>(*this);
155  }
156 
157  // subject_impl
158 
159  template <typename C, typename E>
160  inline
161  C&
162  subject_impl< point<grid::cube, C>, E >::row()
163  {
164  return exact_().get_subject().row();
165  }
166 
167  template <typename C, typename E>
168  inline
169  C&
170  subject_impl< point<grid::cube, C>, E >::col()
171  {
172  return exact_().get_subject().col();
173  }
174 
175  template <typename C, typename E>
176  inline
177  C&
178  subject_impl< point<grid::cube, C>, E >::sli()
179  {
180  return exact_().get_subject().sli();
181  }
182 
183  template <typename C, typename E>
184  inline
185  C&
186  subject_impl< point<grid::cube, C>, E >::operator[](unsigned i)
187  {
188  mln_precondition(i < 3);
189  return exact_().get_subject()[i];
190  }
191 
192  template <typename C, typename E>
193  inline
194  E&
195  subject_impl< point<grid::cube, C>, E >::exact_()
196  {
197  return internal::force_exact<E>(*this);
198  }
199 
200 # endif // ! MLN_INCLUDE_ONLY
201 
202  } // end of namespace mln::internal
203 
204 
205 } // end of namespace mln
206 
207 
208 # include <mln/core/alias/dpoint3d.hh>
209 
210 
211 #endif // ! MLN_CORE_ALIAS_POINT3D_HH