Milena (Olena)  User documentation 2.0a Id
 All Classes Namespaces Functions Variables Typedefs Enumerator Groups Pages
p_n_faces_piter.hh
1 // Copyright (C) 2008, 2009, 2010 EPITA Research and Development
2 // 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_SITE_SET_P_N_FACES_PITER_HH
28 # define MLN_CORE_SITE_SET_P_N_FACES_PITER_HH
29 
33 
34 # include <mln/core/site_set/p_complex.hh>
35 # include <mln/core/internal/p_complex_piter_base.hh>
36 # include <mln/topo/n_face_iter.hh>
37 
38 /* FIXME: Maybe we could factor these iterators again, by introducing
39  an implementation class having methods n() and set_n(). */
40 
41 
42 namespace mln
43 {
44 
45  // Forward declarations.
46  template <unsigned D, typename G> class p_complex;
47 
48 
49  /*----------------------------.
50  | p_n_faces_fwd_piter<D, G>. |
51  `----------------------------*/
52 
55  template <unsigned D, typename G>
57  : public internal::p_complex_piter_base_< topo::n_face_fwd_iter<D>,
58  p_complex<D, G>,
59  mln_site(G),
60  p_n_faces_fwd_piter<D, G> >
61  {
63  typedef internal::p_complex_piter_base_< topo::n_face_fwd_iter<D>,
65  mln_site(G),
66  self_ > super_;
67 
68  public:
72  p_n_faces_fwd_piter(const p_complex<D, G>& pc, unsigned n);
74 
79  unsigned n() const;
80  void set_n (unsigned n);
82  };
83 
84 
85  /*----------------------------.
86  | p_n_faces_bkd_piter<D, G>. |
87  `----------------------------*/
88 
91  template <unsigned D, typename G>
93  /* FIXME: Rename internal::p_complex_piter_base_ to something else,
94  as it is also used for p_faces piters! */
95  : public internal::p_complex_piter_base_< topo::n_face_bkd_iter<D>,
96  p_complex<D, G>,
97  mln_site(G),
98  p_n_faces_bkd_piter<D, G> >
99  {
101  typedef internal::p_complex_piter_base_< topo::n_face_bkd_iter<D>,
103  mln_site(G),
104  self_ > super_;
105 
106  public:
110  p_n_faces_bkd_piter(const p_complex<D, G>& pc, unsigned n);
112 
117  unsigned n() const;
118  void set_n (unsigned n);
120  };
121 
122 
123 
124 # ifndef MLN_INCLUDE_ONLY
125 
126  /*----------------------------.
127  | p_n_faces_fwd_piter<D, G>. |
128  `----------------------------*/
129 
130  template <unsigned D, typename G>
131  inline
133  {
134  }
135 
136  template <unsigned D, typename G>
137  inline
139  unsigned n)
140  : super_(pc)
141  {
142  mln_precondition(n <= D);
143  set_n(n);
144  }
145 
146  template <unsigned D, typename G>
147  inline
148  unsigned
150  {
151  return this->iter_.n();
152  }
153 
154  template <unsigned D, typename G>
155  inline
156  void
158  {
159  this->iter_.set_n(n);
160  }
161 
162 
163  /*----------------------------.
164  | p_n_faces_bkd_piter<D, G>. |
165  `----------------------------*/
166 
167  template <unsigned D, typename G>
168  inline
170  {
171  }
172 
173  template <unsigned D, typename G>
174  inline
176  unsigned n)
177  : super_(pc)
178  {
179  mln_precondition(n <= D);
180  set_n(n);
181  }
182 
183  template <unsigned D, typename G>
184  inline
185  unsigned
187  {
188  return this->iter_.n();
189  }
190 
191  template <unsigned D, typename G>
192  inline
193  void
195  {
196  this->iter_.set_n(n);
197  }
198 
199 # endif // ! MLN_INCLUDE_ONLY
200 
201 } // end of mln
202 
203 #endif // ! MLN_CORE_SITE_SET_P_N_FACES_PITER_HH