Milena (Olena)  User documentation 2.0a Id
 All Classes Namespaces Functions Variables Typedefs Enumerator Groups Pages
mixed_neighb.hh
1 // Copyright (C) 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_MIXED_NEIGHB_HH
27 # define MLN_CORE_MIXED_NEIGHB_HH
28 
39 
40 # include <mln/core/neighb.hh>
41 # include <mln/core/internal/neighb_base.hh>
42 # include <mln/core/internal/neighb_niter_base.hh>
43 # include <mln/core/internal/site_relative_iterator_base.hh>
44 # include <mln/core/internal/neighb_niter_impl.hh>
45 
46 
47 namespace mln
48 {
49 
50  // Forward declarations.
51  template <typename W> class mixed_neighb_fwd_niter;
52  template <typename W> class mixed_neighb_bkd_niter;
53  template <typename W> class mixed_neighb;
54 
55 
56  namespace convert
57  {
58 
59  namespace over_load
60  {
61 
62  template <typename W>
63  void
64  from_to_(const mln::mixed_neighb<W>& from, W& to);
65 
66  template <typename W>
67  void
68  from_to_(const W& from, mln::mixed_neighb<W>& to);
69 
70  } // end of namespace mln::convert::over_load
71 
72  } // end of namespace mln::convert
73 
74 
75 
77 
78  template <typename W>
79  class mixed_neighb
80  : public internal::neighb_base<W,mixed_neighb<W> >,
81  private mlc_is_a(W, Window)::check_t
82  {
83  typedef internal::neighb_base<W,mixed_neighb<W> > super_;
84 
85  public:
86 
88  typedef mixed_neighb_fwd_niter<W> fwd_niter;
89 
91  typedef mixed_neighb_bkd_niter<W> bkd_niter;
92 
94  typedef fwd_niter niter;
95 
96 
98  mixed_neighb();
99 
101  mixed_neighb(const W& win);
102 
103  };
104 
105 
106  // mixed_neighb_fwd_niter<W>
107 
108  template <typename W>
109  class mixed_neighb_fwd_niter
110  : public internal::neighb_niter_base<W,mixed_neighb<W>,
111  mln_fwd_qiter(W),neighb_fwd_niter<W> >
112  {
113  typedef
114  internal::neighb_niter_base<W,mixed_neighb<W>,
115  mln_fwd_qiter(W),neighb_fwd_niter<W> > super_;
116 
117  public:
118  mixed_neighb_fwd_niter();
119 
120  template <typename P>
121  mixed_neighb_fwd_niter(const mixed_neighb<W>& nbh,
122  const mln_target(W)& nbh_site_set,
123  const P& c);
124 
125  };
126 
127 
128 
129  // mixed_neighb_bkd_niter<W,E>
130 
131  template <typename W>
132  class mixed_neighb_bkd_niter
133  : public internal::neighb_niter_base<W,mixed_neighb<W>,
134  mln_bkd_qiter(W),neighb_bkd_niter<W> >
135  {
136  typedef
137  internal::neighb_niter_base<W,mixed_neighb<W>,
138  mln_bkd_qiter(W),neighb_bkd_niter<W> > super_;
139 
140  public:
141  mixed_neighb_bkd_niter();
142 
143  template <typename P>
144  mixed_neighb_bkd_niter(const mixed_neighb<W>& nbh,
145  const mln_target(W)& nbh_site_set,
146  const P& c);
147 
148  };
149 
150 
151 
152 # ifndef MLN_INCLUDE_ONLY
153 
154  // mixed_neighb<W>
155 
156  template <typename W>
157  inline
158  mixed_neighb<W>::mixed_neighb()
159  {
160  }
161 
162  template <typename W>
163  inline
164  mixed_neighb<W>::mixed_neighb(const W& win)
165  : super_(win)
166  {
167  }
168 
169 
170  // mln::convert::from_to
171 
172  namespace convert
173  {
174 
175  namespace over_load
176  {
177 
178  template <typename W>
179  void
180  from_to_(const mln::mixed_neighb<W>& from, W& to)
181  {
182  to = from.win();
183  }
184 
185  template <typename W>
186  void
187  from_to_(const W& from, mln::mixed_neighb<W>& to)
188  {
189  to.change_window(from);
190  }
191 
192  } // end of namespace mln::convert::over_load
193 
194  } // end of namespace mln::convert
195 
196 
197 
198 
199  // mixed_neighb_fwd_niter<W>
200 
201  template <typename W>
202  inline
203  mixed_neighb_fwd_niter<W>::mixed_neighb_fwd_niter()
204  {
205  }
206 
207  template <typename W>
208  template <typename P>
209  inline
210  mixed_neighb_fwd_niter<W>::mixed_neighb_fwd_niter(const mixed_neighb<W>& nbh,
211  const mln_target(W)& nbh_site_set,
212  const P& c)
213  : super_(nbh, c)
214  {
215  this->i_.init_(nbh.win(), nbh_site_set, c);
216  }
217 
218 
219 
220  // mixed_neighb_bkd_niter<W>
221 
222  template <typename W>
223  inline
224  mixed_neighb_bkd_niter<W>::mixed_neighb_bkd_niter()
225  {
226  }
227 
228  template <typename W>
229  template <typename P>
230  inline
231  mixed_neighb_bkd_niter<W>::mixed_neighb_bkd_niter(const mixed_neighb<W>& nbh,
232  const mln_target(W)& nbh_site_set,
233  const P& c)
234  : super_(nbh, c)
235  {
236  this->i_.init_(nbh.win(), nbh_site_set, c);
237  }
238 
239 
240 # endif // ! MLN_INCLUDE_ONLY
241 
242 } // end of namespace mln
243 
244 
245 #endif // ! MLN_CORE_MIXED_NEIGHB_HH