26 #ifndef MLN_CORE_INTERNAL_WEIGHTED_WINDOW_BASE_HH
27 # define MLN_CORE_INTERNAL_WEIGHTED_WINDOW_BASE_HH
33 # include <mln/core/concept/weighted_window.hh>
46 template <
typename W,
typename E>
47 struct weighted_window_base :
public Weighted_Window<E>
54 typedef mln_dpsite(W) dpsite;
57 typedef mln_psite(W) psite;
60 typedef mln_site(W) site;
63 bool is_empty() const;
67 unsigned size() const;
72 bool is_centered() const;
77 unsigned delta() const;
82 const mln_dpsite(W)& dp(
unsigned i) const;
87 bool has(const mln_dpsite(W)& dp) const;
90 bool is_valid() const;
93 weighted_window_base();
97 # ifndef MLN_INCLUDE_ONLY
99 template <
typename W,
typename E>
101 weighted_window_base<W,E>::weighted_window_base()
105 template <
typename W,
typename E>
108 weighted_window_base<W,E>::is_empty()
const
110 return exact(
this)->win().is_empty();
113 template <
typename W,
typename E>
116 weighted_window_base<W,E>::size()
const
118 mlc_equal(mln_trait_window_size(W),
119 trait::window::size::fixed)::check();
120 return exact(
this)->win().size();
123 template <
typename W,
typename E>
126 weighted_window_base<W,E>::is_centered()
const
128 mlc_equal(mln_trait_window_support(W),
129 trait::window::support::regular)::check();
130 mlc_not_equal(mln_trait_window_definition(W),
131 trait::window::definition::varying)::check();
132 return exact(
this)->win().is_centered();
135 template <
typename W,
typename E>
138 weighted_window_base<W,E>::delta()
const
140 mlc_equal(mln_trait_window_support(W),
141 trait::window::support::regular)::check();
142 mlc_not_equal(mln_trait_window_definition(W),
143 trait::window::definition::varying)::check();
144 return exact(
this)->win().delta();
147 template <
typename W,
typename E>
150 weighted_window_base<W,E>::dp(
unsigned i)
const
152 mlc_equal(mln_trait_window_support(W),
153 trait::window::support::regular)::check();
154 mlc_equal(mln_trait_window_definition(W),
155 trait::window::definition::unique)::check();
156 mln_precondition(i < this->size());
157 return exact(
this)->win().dp(i);
160 template <
typename W,
typename E>
163 weighted_window_base<W,E>::has(
const mln_dpsite(W)& dp)
const
165 mlc_equal(mln_trait_window_support(W),
166 trait::window::support::regular)::check();
167 mlc_equal(mln_trait_window_definition(W),
168 trait::window::definition::unique)::check();
169 return exact(
this)->win().has(dp);
172 template <
typename W,
typename E>
175 weighted_window_base<W,E>::is_valid()
const
180 # endif // ! MLN_INCLUDE_ONLY
187 #endif // ! MLN_CORE_INTERNAL_WEIGHTED_WINDOW_BASE_HH