$extrastylesheet
Olena  User documentation 2.1
An Image Processing Platform
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
site_set_impl.hh
1 // Copyright (C) 2008, 2009, 2013 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_INTERNAL_SITE_SET_IMPL_HH
28 # define MLN_CORE_INTERNAL_SITE_SET_IMPL_HH
29 
32 
33 # include <mln/core/concept/site_set.hh>
34 # include <mln/accu/shape/bbox.hh>
35 
36 
37 
38 namespace mln
39 {
40 
41  namespace internal
42  {
43 
46  template <typename Sc>
47  struct site_set_impl;
48 
49 
50 
51  // For .nsites()
52 
53  template <typename trait_nsites, typename Sc>
55  {
56  protected:
57  template <typename T>
58  void update_nsites_(const T&); // No-op.
59  };
60 
61  template <typename Sc>
62  struct site_set_impl__nsites< trait::site_set::nsites::known, Sc>
63  {
65  unsigned nsites() const;
66  protected:
67  void update_nsites_(const mln_site(Sc)& p);
68  template <typename S>
69  void update_nsites_(const Site_Set<S>& s);
70  unsigned nsites_;
71  };
72 
73 
74  // For .bbox()
75 
76  template <typename trait_bbox, typename Sc>
78  {
79  typedef const mln::box<mln_site(Sc)>& q_box;
80  q_box bbox() const;
81 
82  protected:
83  void update_bbox_(const mln_site(Sc)& p);
84  template <typename S>
85  void update_bbox_(const Site_Set<S>& s);
86 
88  };
89 
90  template <typename Sc>
91  struct site_set_impl__bbox< trait::site_set::nsites::unknown, Sc >
92  {
93  protected:
94  template <typename T>
95  void update_bbox_(const T&); // No-op.
96  };
97 
98 
99  // Facade.
100 
101  template <typename Sc>
103  : site_set_impl__nsites< mln_trait_site_set_nsites(Sc), Sc>,
104  site_set_impl__bbox < mln_trait_site_set_bbox(Sc), Sc>
105  {
106  };
107 
108 
109 
110 
111 # ifndef MLN_INCLUDE_ONLY
112 
113 
114  // site_set_impl__nsites
115 
116  template <typename trait_nsites, typename Sc>
117  template <typename T>
118  inline
119  void
121  {
122  // No-op.
123  }
124 
125  template <typename Sc>
126  inline
128  : nsites_(0)
129  {
130  }
131 
132  template <typename Sc>
133  inline
134  unsigned
136  {
137  return nsites_;
138  }
139 
140  template <typename Sc>
141  inline
142  void
144  {
145  ++nsites_;
146  }
147 
148  template <typename Sc>
149  template <typename S>
150  inline
151  void
153  {
154  nsites_ += exact(s).nsites();
155  }
156 
157  // site_set_impl__bbox
158 
159  template <typename trait_bbox, typename Sc>
160  inline
161  typename site_set_impl__bbox<trait_bbox, Sc>::q_box
163  {
164  return bb_.to_result();
165  }
166 
167  template <typename trait_bbox, typename Sc>
168  inline
169  void
171  {
172  bb_.take(p);
173  }
174 
175  template <typename trait_bbox, typename Sc>
176  template <typename S>
177  inline
178  void
180  {
181  bb_.take(exact(s).bbox());
182  }
183 
184  template <typename Sc>
185  template <typename T>
186  inline
187  void
189  {
190  // No-op.
191  }
192 
193 # endif // ! MLN_INCLUDE_ONLY
194 
195  } // end of namespace mln::internal
196 
197 } // end of namespace mln
198 
199 
200 #endif // ! MLN_CORE_INTERNAL_SITE_SET_IMPL_HH