Milena (Olena)  User documentation 2.0a Id
 All Classes Namespaces Functions Variables Typedefs Enumerator Groups Pages
delta.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_GEOM_DELTA_HH
27 # define MLN_GEOM_DELTA_HH
28 
32 
33 
34 # include <mln/core/concept/window.hh>
35 # include <mln/core/concept/weighted_window.hh>
36 # include <mln/core/concept/neighborhood.hh>
37 
38 
39 namespace mln
40 {
41 
42  namespace geom
43  {
44 
46  template <typename W>
47  unsigned delta(const Window<W>& win);
48 
50  template <typename W>
51  unsigned delta(const Weighted_Window<W>& wwin);
52 
54  template <typename N>
55  unsigned delta(const Neighborhood<N>& nbh);
56 
57 
58 
59 # ifndef MLN_INCLUDE_ONLY
60 
61  namespace internal
62  {
63 
64  template <typename W>
65  unsigned delta_dispatch(trait::window::support::any,
66  trait::window::definition::any,
67  const W& win)
68  {
69  (void) win;
70  return 0;
71  }
72 
73  template <typename W>
74  unsigned delta_dispatch(trait::window::support::regular,
75  trait::window::definition::varying,
76  const W& win)
77  {
78  (void) win;
79  return 0;
80  }
81 
82  template <typename W>
83  unsigned delta_dispatch(trait::window::support::regular,
84  trait::window::definition::any, // So not varying.
85  const W& win)
86  {
87  return win.delta();
88  }
89 
90  } // end of namespace mln::geom::internal
91 
92 
93  // Facades.
94 
95  template <typename W>
96  unsigned delta(const Window<W>& win)
97  {
98  mln_precondition(exact(win).is_valid());
99  return internal::delta_dispatch(mln_trait_window_support(W)(),
100  mln_trait_window_definition(W)(),
101  exact(win));
102  }
103 
104  template <typename W>
105  unsigned delta(const Weighted_Window<W>& wwin)
106  {
107  mln_precondition(exact(wwin).is_valid());
108  return delta(exact(wwin).win());
109  }
110 
111  template <typename N>
112  unsigned delta(const Neighborhood<N>& nbh)
113  {
114  mln_precondition(exact(nbh).is_valid());
115  return delta(exact(nbh).win());
116  }
117 
118 # endif // ! MLN_INCLUDE_ONLY
119 
120  } // end of namespace mln::geom
121 
122 } // end of namespace mln
123 
124 
125 #endif // ! MLN_GEOM_DELTA_HH