Milena (Olena)
User documentation 2.0a Id
|
00001 // Copyright (C) 2008, 2009 EPITA Research and Development Laboratory (LRDE) 00002 // 00003 // This file is part of Olena. 00004 // 00005 // Olena is free software: you can redistribute it and/or modify it under 00006 // the terms of the GNU General Public License as published by the Free 00007 // Software Foundation, version 2 of the License. 00008 // 00009 // Olena is distributed in the hope that it will be useful, 00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00012 // General Public License for more details. 00013 // 00014 // You should have received a copy of the GNU General Public License 00015 // along with Olena. If not, see <http://www.gnu.org/licenses/>. 00016 // 00017 // As a special exception, you may use this file as part of a free 00018 // software project without restriction. Specifically, if other files 00019 // instantiate templates or use macros or inline functions from this 00020 // file, or you compile this file and link it with other files to produce 00021 // an executable, this file does not by itself cause the resulting 00022 // executable to be covered by the GNU General Public License. This 00023 // exception does not however invalidate any other reasons why the 00024 // executable file might be covered by the GNU General Public License. 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 } // end of namespace mln::internal 00183 00184 } // end of namespace mln 00185 00186 00187 #endif // ! MLN_CORE_INTERNAL_WEIGHTED_WINDOW_BASE_HH