Milena (Olena)  User documentation 2.0a Id
 All Classes Namespaces Functions Variables Typedefs Enumerator Groups Pages
static_n_face_iter.hh
1 // Copyright (C) 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_TOPO_STATIC_N_FACE_ITER_HH
27 # define MLN_TOPO_STATIC_N_FACE_ITER_HH
28 
33 
34 # include <mln/topo/internal/complex_set_iterator_base.hh>
35 # include <mln/topo/face.hh>
36 
37 
38 namespace mln
39 {
40 
41  namespace topo
42  {
43 
44  /*-------------------------------------.
45  | topo::static_n_face_fwd_iter<N, D>. |
46  `-------------------------------------*/
47 
53  //
54  template <unsigned N, unsigned D>
56  : public internal::complex_set_iterator_base< topo::face<D>,
57  static_n_face_fwd_iter<N, D> >
58  {
59  // Tech note: we use topo::face to help g++-2.95.
60  private:
62  typedef internal::complex_set_iterator_base< topo::face<D>, self_ > super_;
63 
64  public:
65  using super_::is_valid;
66  using super_::invalidate;
67 
68  public:
72  // FIXME: See comment in internal::complex_set_iterator_base's
73  // default ctor.
76 
80  void start();
82  void next_();
84 
85  private:
86  using super_::f_;
87  };
88 
89 
90  /*-------------------------------------.
91  | topo::static_n_face_bkd_iter<N, D>. |
92  `-------------------------------------*/
93 
99  //
100  template <unsigned N, unsigned D>
102  : public internal::complex_set_iterator_base< topo::face<D>,
103  static_n_face_bkd_iter<N, D> >
104  {
105  // Tech note: we use topo::face to help g++-2.95.
106  private:
108  typedef internal::complex_set_iterator_base< topo::face<D>, self_ > super_;
109 
110  public:
111  using super_::is_valid;
112  using super_::invalidate;
113 
114  public:
118  // FIXME: See comment in internal::complex_set_iterator_base's
119  // default ctor.
122 
126  void start();
128  void next_();
130 
131  private:
132  using super_::f_;
133  };
134 
135 
136 
137 # ifndef MLN_INCLUDE_ONLY
138 
139  /*-------------------------------------.
140  | topo::static_n_face_fwd_iter<N, D>. |
141  `-------------------------------------*/
142 
143  template <unsigned N, unsigned D>
144  inline
146  : super_()
147  {
148  // Ensure N is compatible with D.
149  metal::bool_< N <= D >::check();
150  f_.set_n(N);
151  mln_postcondition(!is_valid());
152  }
153 
154  template <unsigned N, unsigned D>
155  inline
157  : super_(c)
158  {
159  // Ensure N is compatible with D.
160  metal::bool_< N <= D >::check();
161  f_.set_n(N);
162  mln_postcondition(!is_valid());
163  }
164 
165  template <unsigned N, unsigned D>
166  inline
167  void
169  {
170  f_.set_face_id(0u);
171  }
172 
173  template <unsigned N, unsigned D>
174  inline
175  void
177  {
178  if (is_valid())
179  {
180  if (f_.face_id() + 1 < f_.cplx().template nfaces_of_static_dim<N>())
181  f_.inc_face_id();
182  else
183  invalidate();
184  }
185  }
186 
187 
188  /*-------------------------------------.
189  | topo::static_n_face_bkd_iter<N, D>. |
190  `-------------------------------------*/
191 
192  template <unsigned N, unsigned D>
193  inline
195  : super_()
196  {
197  // Ensure N is compatible with D.
198  metal::bool_< N <= D >::check();
199  f_.set_n(N);
200  mln_postcondition(!is_valid());
201  }
202 
203  template <unsigned N, unsigned D>
204  inline
206  : super_(c)
207  {
208  // Ensure N is compatible with D.
209  metal::bool_< N <= D >::check();
210  f_.set_n(N);
211  mln_postcondition(!is_valid());
212  }
213 
214  template <unsigned N, unsigned D>
215  inline
216  void
218  {
219  f_.set_face_id(f_.cplx().template nfaces_of_static_dim<N>() - 1);
220  }
221 
222  template <unsigned N, unsigned D>
223  inline
224  void
226  {
227  if (is_valid())
228  {
229  if (f_.face_id() > 0)
230  f_.dec_face_id();
231  else
232  invalidate();
233  }
234  }
235 
236 # endif // ! MLN_INCLUDE_ONLY
237 
238  } // end of namespace mln::topo
239 
240 } // end of namespace mln
241 
242 #endif // ! MLN_TOPO_STATIC_N_FACE_ITER_HH