Milena (Olena)  User documentation 2.0a Id
 All Classes Namespaces Functions Variables Typedefs Enumerator Groups Pages
complex_window_base.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_CORE_INTERNAL_COMPLEX_WINDOW_BASE_HH
27 # define MLN_CORE_INTERNAL_COMPLEX_WINDOW_BASE_HH
28 
32 
33 # include <mln/core/concept/window.hh>
34 # include <mln/core/site_set/complex_psite.hh>
35 # include <mln/core/image/complex_window_piter.hh>
36 
37 # include <mln/topo/centered_iter_adapter.hh>
38 
39 // FIXME: Factor with mln::internal::complex_neighborhood_base.
40 
41 
42 namespace mln
43 {
44  // Forward declarations.
45  template <typename I, typename G, typename W>
46  class complex_window_fwd_piter;
47  template <typename I, typename G, typename W>
48  class complex_window_bkd_piter;
49 
50  namespace internal
51  {
52  template <unsigned D, typename G, typename F, typename B, typename E>
53  class complex_window_base;
54  }
55 
56 
57  namespace trait
58  {
59 
60  template <unsigned D, typename G, typename F, typename B, typename E>
61  struct window_< mln::internal::complex_window_base<D, G, F, B, E> >
62  {
63  typedef trait::window::size::unknown size;
64  typedef trait::window::support::irregular support;
65  typedef trait::window::definition::varying definition;
66  };
67 
68  } // end of namespace mln::trait
69 
70 
71  namespace internal
72  {
82  template <unsigned D, typename G, typename F, typename B, typename E>
83  class complex_window_base : public Window<E>
84  {
85  public:
88  typedef F complex_fwd_iter;
89  typedef B complex_bkd_iter;
91 
92  public:
96  typedef G geom;
98  typedef complex_psite<D, G> psite;
100  typedef mln_site(psite) site;
101 
102  // FIXME: This is a dummy value.
103  typedef void dpsite;
104 
105  /* FIXME: Ideally, the `is_centered' information should be
106  fetched from the iterators, but that's not a straighforward
107  task. */
108  complex_window_base(bool is_centered = false);
109 
112  typedef
113  complex_window_fwd_piter<complex_fwd_iter, G, E> fwd_qiter;
114 
117  typedef
118  complex_window_bkd_piter<complex_bkd_iter, G, E> bkd_qiter;
119 
121  typedef fwd_qiter qiter;
123 
124  public:
127  /* FIXME: mln::morpho::dilation requires these method from models
128  of concept Window, but Window does not list them in its
129  requirements. Who's guilty: morpho::dilation or Window? */
131  bool is_empty() const;
133  bool is_centered() const;
134 
136  bool is_valid() const;
138 
139  private:
140  bool is_centered_;
141  };
142 
143 
144 
145 # ifndef MLN_INCLUDE_ONLY
146 
147  template <unsigned D, typename G, typename F, typename B, typename E>
148  inline
149  complex_window_base<D, G, F, B, E>::complex_window_base(bool is_centered)
150  : is_centered_(is_centered)
151  {
152  }
153 
154 
155  template <unsigned D, typename G, typename F, typename B, typename E>
156  inline
157  bool
158  complex_window_base<D, G, F, B, E>::is_empty() const
159  {
160  return false;
161  }
162 
163  template <unsigned D, typename G, typename F, typename B, typename E>
164  inline
165  bool
166  complex_window_base<D, G, F, B, E>::is_centered() const
167  {
168  return is_centered_;
169  }
170 
171  template <unsigned D, typename G, typename F, typename B, typename E>
172  inline
173  bool
174  complex_window_base<D, G, F, B, E>::is_valid() const
175  {
176  return true;
177  }
178 
179 # endif // ! MLN_INCLUDE_ONLY
180 
181  } // end of namespace mln::internal
182 
183 } // end of namespace mln
184 
185 #endif // ! MLN_CORE_INTERNAL_COMPLEX_WINDOW_BASE_HH