$extrastylesheet
Olena  User documentation 2.1
An Image Processing Platform
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
classical_window_base.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_INTERNAL_CLASSICAL_WINDOW_BASE_HH
28 # define MLN_CORE_INTERNAL_CLASSICAL_WINDOW_BASE_HH
29 
40 # include <mln/core/window.hh>
41 # include <mln/core/dpsites_piter.hh>
42 
43 
44 
45 namespace mln
46 {
47 
48  namespace internal
49  {
50 
54  template <typename D, typename E>
55  class classical_window_base : public window_base<D, E>
56  {
57  public:
58 
59 
61  typedef window<D> regular;
62 
63 
66 
69 
71  typedef fwd_qiter qiter;
72 
73 
75  unsigned size() const;
76 
78  bool is_empty() const;
79 
80 
82  bool is_centered() const;
83 
85  bool is_symmetric() const;
86 
88  void sym();
89 
90 
93  unsigned delta() const;
94 
95 
97  bool has(const D& dp) const;
98 
100  const D& dp(unsigned i) const;
101 
103  const std::vector<D>& vect() const;
104 
106  const std::vector<D>& std_vector() const;
107 
109  void print(std::ostream& ostr) const;
110 
111  protected:
112 
114 
115  void insert(const D& d);
116  unsigned delta_() const; // Default implementation based on win_.
117  void print_(std::ostream& ostr) const; // Default implementation based on win_.
118 
120  };
121 
122 
123 
124 # ifndef MLN_INCLUDE_ONLY
125 
126  template <typename D, typename E>
127  inline
129  {
130  }
131 
132  template <typename D, typename E>
133  inline
134  unsigned
136  {
137  return win_.size();
138  }
139 
140  template <typename D, typename E>
141  inline
142  bool
144  {
145  return win_.is_empty();
146  }
147 
148  template <typename D, typename E>
149  inline
150  bool
152  {
153  mln_invariant(win_.is_centered());
154  return true;
155  }
156 
157  template <typename D, typename E>
158  inline
159  bool
161  {
162  mln_invariant(win_.is_symmetric());
163  return true;
164  }
165 
166  template <typename D, typename E>
167  inline
168  void
170  {
171  mln_invariant(win_.is_symmetric());
172  // No-op.
173  }
174 
175  template <typename D, typename E>
176  inline
177  unsigned
179  {
180  // void *v = (void*)(& classical_window_base<D,E>::delta_);
181  // void *w = (void*)(& E::delta_);
182  return exact(this)->delta_();
183  }
184 
185  template <typename D, typename E>
186  inline
187  unsigned
189  {
190  return win_.delta();
191  }
192 
193  template <typename D, typename E>
194  inline
195  const D&
196  classical_window_base<D,E>::dp(unsigned i) const
197  {
198  mln_precondition(i < size());
199  return win_.dp(i);
200  }
201 
202  template <typename D, typename E>
203  inline
204  const std::vector<D>&
206  {
207  return win_.std_vector();
208  }
209 
210  template <typename D, typename E>
211  inline
212  const std::vector<D>&
214  {
215  return std_vector();
216  }
217 
218  template <typename D, typename E>
219  inline
220  bool
221  classical_window_base<D,E>::has(const D& dp) const
222  {
223  return win_.has(dp);
224  }
225 
226  template <typename D, typename E>
227  inline
228  void
230  {
231  win_.insert(d);
232  }
233 
234  template <typename D, typename E>
235  inline
236  void
237  classical_window_base<D,E>::print(std::ostream& ostr) const
238  {
239  exact(this)->print_(ostr);
240  }
241 
242  template <typename D, typename E>
243  inline
244  void
245  classical_window_base<D,E>::print_(std::ostream& ostr) const
246  {
247  ostr << win_;
248  }
249 
250 # endif // ! MLN_INCLUDE_ONLY
251 
252  } // end of namespace internal
253 
254 } // end of namespace mln
255 
256 
257 #endif // ! MLN_CORE_INTERNAL_CLASSICAL_WINDOW_BASE_HH