$extrastylesheet
Olena  User documentation 2.1
An Image Processing Platform
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
point1d.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_ALIAS_POINT1D_HH
28 # define MLN_CORE_ALIAS_POINT1D_HH
29 
34 
35 # include <mln/core/def/coord.hh>
36 # include <mln/core/def/coordf.hh>
37 # include <mln/core/point.hh>
38 // For site_const_impl and site_mutable_impl.
39 # include <mln/core/concept/site_proxy.hh>
40 # include <mln/core/internal/force_exact.hh>
41 
42 
43 namespace mln
44 {
45 
53 
54  typedef point<grid::tick, def::coord> point1d;
56 
64 
65  typedef point<grid::tick, def::coordf> point1df;
67 
68 
69  namespace internal
70  {
71 
72  // Specialization.
73 
75  template <typename C, typename E>
76  struct subject_impl< const point<grid::tick, C>, E >
77  {
78  typedef C coord;
79  enum { dim = 1 };
80 
81  typedef const C& ind_t;
82  const C& ind() const;
83 
84  const C& operator[](unsigned i) const;
85  const C& last_coord() const;
86  private:
87  const E& exact_() const;
88  };
89 
90 
91  // Specialization for point<M,C>.
92 
94  template <typename C, typename E>
95  struct subject_impl< point<grid::tick, C>, E > :
96  subject_impl< const point<grid::tick, C>, E >
97  {
98  private:
99  typedef subject_impl< const point<grid::tick, C>, E > super_;
100  E& exact_();
101  public:
102  using super_::ind;
103  C& ind();
104  using super_::operator[];
105  C& operator[](unsigned i);
106  };
107 
108 
109 
110 # ifndef MLN_INCLUDE_ONLY
111 
112  // subject_impl
113 
114  template <typename C, typename E>
115  inline
116  const C&
118  {
119  return exact_().get_subject().ind();
120  }
121 
122  template <typename C, typename E>
123  inline
124  const C&
125  subject_impl< const point<grid::tick, C>, E >::operator[](unsigned i) const
126  {
127  mln_precondition(i == 0);
128  (void)i;
129  return exact_().get_subject()[0];
130  }
131 
132  template <typename C, typename E>
133  inline
134  const E&
135  subject_impl< const point<grid::tick, C>, E >::exact_() const
136  {
137  return internal::force_exact<const E>(*this);
138  }
139 
140  // subject_impl
141 
142  template <typename C, typename E>
143  inline
144  C&
146  {
147  return exact_().get_subject().ind();
148  }
149 
150  template <typename C, typename E>
151  inline
152  C&
153  subject_impl< point<grid::tick, C>, E >::operator[](unsigned i)
154  {
155  mln_precondition(i == 0);
156  (void)i;
157  return exact_().get_subject()[0];
158  }
159 
160 # endif // ! MLN_INCLUDE_ONLY
161 
162  } // end of namespace mln::internal
163 
164 } // end of namespace mln
165 
166 
167 # include <mln/core/alias/dpoint1d.hh>
168 
169 
170 #endif // ! MLN_CORE_ALIAS_POINT1D_HH