00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #ifndef MLN_CORE_INTERNAL_WEIGHTED_WINDOW_BASE_HH
00027 # define MLN_CORE_INTERNAL_WEIGHTED_WINDOW_BASE_HH
00028
00032
00033 # include <mln/core/concept/weighted_window.hh>
00034
00035
00036 namespace mln
00037 {
00038
00039 namespace internal
00040 {
00041
00045
00046 template <typename W, typename E>
00047 struct weighted_window_base : public Weighted_Window<E>
00048 {
00049
00051 typedef W window;
00052
00054 typedef mln_dpsite(W) dpsite;
00055
00057 typedef mln_psite(W) psite;
00058
00060 typedef mln_site(W) site;
00061
00063 bool is_empty() const;
00064
00067 unsigned size() const;
00068
00072 bool is_centered() const;
00073
00077 unsigned delta() const;
00078
00082 const mln_dpsite(W)& dp(unsigned i) const;
00083
00087 bool has(const mln_dpsite(W)& dp) const;
00088
00090 bool is_valid() const;
00091
00092 protected:
00093 weighted_window_base();
00094 };
00095
00096
00097 # ifndef MLN_INCLUDE_ONLY
00098
00099 template <typename W, typename E>
00100 inline
00101 weighted_window_base<W,E>::weighted_window_base()
00102 {
00103 }
00104
00105 template <typename W, typename E>
00106 inline
00107 bool
00108 weighted_window_base<W,E>::is_empty() const
00109 {
00110 return exact(this)->win().is_empty();
00111 }
00112
00113 template <typename W, typename E>
00114 inline
00115 unsigned
00116 weighted_window_base<W,E>::size() const
00117 {
00118 mlc_equal(mln_trait_window_size(W),
00119 trait::window::size::fixed)::check();
00120 return exact(this)->win().size();
00121 }
00122
00123 template <typename W, typename E>
00124 inline
00125 bool
00126 weighted_window_base<W,E>::is_centered() const
00127 {
00128 mlc_equal(mln_trait_window_support(W),
00129 trait::window::support::regular)::check();
00130 mlc_not_equal(mln_trait_window_definition(W),
00131 trait::window::definition::varying)::check();
00132 return exact(this)->win().is_centered();
00133 }
00134
00135 template <typename W, typename E>
00136 inline
00137 unsigned
00138 weighted_window_base<W,E>::delta() const
00139 {
00140 mlc_equal(mln_trait_window_support(W),
00141 trait::window::support::regular)::check();
00142 mlc_not_equal(mln_trait_window_definition(W),
00143 trait::window::definition::varying)::check();
00144 return exact(this)->win().delta();
00145 }
00146
00147 template <typename W, typename E>
00148 inline
00149 const mln_dpsite(W)&
00150 weighted_window_base<W,E>::dp(unsigned i) const
00151 {
00152 mlc_equal(mln_trait_window_support(W),
00153 trait::window::support::regular)::check();
00154 mlc_equal(mln_trait_window_definition(W),
00155 trait::window::definition::unique)::check();
00156 mln_precondition(i < this->size());
00157 return exact(this)->win().dp(i);
00158 }
00159
00160 template <typename W, typename E>
00161 inline
00162 bool
00163 weighted_window_base<W,E>::has(const mln_dpsite(W)& dp) const
00164 {
00165 mlc_equal(mln_trait_window_support(W),
00166 trait::window::support::regular)::check();
00167 mlc_equal(mln_trait_window_definition(W),
00168 trait::window::definition::unique)::check();
00169 return exact(this)->win().has(dp);
00170 }
00171
00172 template <typename W, typename E>
00173 inline
00174 bool
00175 weighted_window_base<W,E>::is_valid() const
00176 {
00177 return true;
00178 }
00179
00180 # endif // ! MLN_INCLUDE_ONLY
00181
00182 }
00183
00184 }
00185
00186
00187 #endif // ! MLN_CORE_INTERNAL_WEIGHTED_WINDOW_BASE_HH