$extrastylesheet
Olena  User documentation 2.1
An Image Processing Platform
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
dpsites_piter.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_DPSITES_PITER_HH
28 # define MLN_CORE_DPSITES_PITER_HH
29 
34 
35 # include <vector>
36 # include <mln/core/internal/site_relative_iterator_base.hh>
37 
38 
39 namespace mln
40 {
41 
50  template <typename V>
52  : public internal::site_relative_iterator_base< V, dpsites_fwd_piter<V> >
53  {
54  public:
55 
60  template <typename P>
61  dpsites_fwd_piter(const V& v, const P& c);
62 
64 
66  template <typename P>
67  void init_(const V& v, const P& c);
69 
72 
75  bool is_valid_() const;
76 
78  void invalidate_();
79 
81  void do_start_();
82 
84  void do_next_();
85 
87  mln_psite(V) compute_p_() const;
88 
89  protected:
90 
91  unsigned i_;
92 
94  };
95 
96 
105  template <typename V>
107  public internal::site_relative_iterator_base< V, dpsites_bkd_piter<V> >
108  {
109  public:
110 
115  template <typename P>
116  dpsites_bkd_piter(const V& v, const P& c);
117 
120 
122 
124  template <typename P>
125  void init_(const V& v, const P& c);
126 
128  bool is_valid_() const;
129 
131  void invalidate_();
132 
134  void do_start_();
135 
137  void do_next_();
138 
140  mln_psite(V) compute_p_() const;
141 
142  protected:
143 
144  int i_;
145 
147  };
148 
149 
150 
151 # ifndef MLN_INCLUDE_ONLY
152 
153 
154  // Forward.
155 
156  template <typename V>
157  inline
159  {
160  }
161 
162  template <typename V>
163  template <typename P>
164  inline
165  dpsites_fwd_piter<V>::dpsites_fwd_piter(const V& v, const P& c)
166  {
167  init_(v, c);
168  }
169 
170  template <typename V>
171  template <typename P>
172  inline
173  void
174  dpsites_fwd_piter<V>::init_(const V& v, const P& c)
175  {
176  this->change_target(v);
177  this->center_at(c);
178  }
179 
180 
181  template <typename V>
182  inline
183  bool
185  {
186  return i_ != this->s_->std_vector().size();
187  }
188 
189  template <typename V>
190  inline
191  void
193  {
194  i_ = this->s_->std_vector().size();
195  }
196 
197  template <typename V>
198  inline
199  void
201  {
202  i_ = 0;
203  }
204 
205  template <typename V>
206  inline
207  void
209  {
210  ++i_;
211  }
212 
213  template <typename V>
214  inline
215  mln_psite(V)
216  dpsites_fwd_piter<V>::compute_p_() const
217  {
218  return *this->c_ + this->s_->std_vector()[i_];
219  }
220 
221 
222  // Backward.
223 
224  template <typename V>
225  inline
227  {
228  }
229 
230  template <typename V>
231  template <typename P>
232  inline
233  dpsites_bkd_piter<V>::dpsites_bkd_piter(const V& v, const P& c)
234  {
235  init_(v, c);
236  }
237 
238  template <typename V>
239  template <typename P>
240  inline
241  void
242  dpsites_bkd_piter<V>::init_(const V& v, const P& c)
243  {
244  this->change_target(v);
245  this->center_at(c);
246  }
247 
248 
249  template <typename V>
250  inline
251  bool
252  dpsites_bkd_piter<V>::is_valid_() const
253  {
254  return i_ != -1;
255  }
256 
257  template <typename V>
258  inline
259  void
260  dpsites_bkd_piter<V>::invalidate_()
261  {
262  i_ = -1;
263  }
264 
265  template <typename V>
266  inline
267  void
268  dpsites_bkd_piter<V>::do_start_()
269  {
270  i_ = this->s_->std_vector().size() - 1;
271  }
272 
273  template <typename V>
274  inline
275  void
276  dpsites_bkd_piter<V>::do_next_()
277  {
278  --i_;
279  }
280 
281  template <typename V>
282  inline
283  mln_psite(V)
284  dpsites_bkd_piter<V>::compute_p_() const
285  {
286  return *this->c_ + this->s_->std_vector()[i_];
287  }
288 
289 # endif // ! MLN_INCLUDE_ONLY
290 
291 } // end of namespace mln
292 
293 
294 #endif // ! MLN_CORE_DPSITES_PITER_HH