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