Milena (Olena)
User documentation 2.0a Id
|
00001 // Copyright (C) 2007, 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_ALIAS_POINT2D_HH 00027 # define MLN_CORE_ALIAS_POINT2D_HH 00028 00033 00034 # include <mln/core/point.hh> 00035 // For site_const_impl and site_mutable_impl. 00036 # include <mln/core/concept/site_proxy.hh> 00037 # include <mln/core/internal/force_exact.hh> 00038 00039 00040 namespace mln 00041 { 00042 00045 typedef point<mln::grid::square, mln::def::coord> point2d; 00046 00049 typedef point<mln::grid::square, mln::def::coordf> point2df; 00050 00051 00052 namespace internal 00053 { 00054 00055 // Specialization. 00056 00057 template <typename C, typename E> 00058 struct subject_impl< const point<grid::square, C>, E > 00059 { 00060 typedef C coord; 00061 enum { dim = 2 }; 00062 00063 typedef const C& row_t; 00064 const C& row() const; 00065 00066 typedef const C& col_t; 00067 const C& col() const; 00068 00069 const C& operator[](unsigned i) const; 00070 const C& last_coord() const; 00071 private: 00072 const E& exact_() const; 00073 }; 00074 00075 00076 // Specialization for point<M,C>. 00077 00078 template <typename C, typename E> 00079 struct subject_impl< point<grid::square, C>, E > : 00080 subject_impl< const point<grid::square, C>, E > 00081 { 00082 private: 00083 typedef subject_impl< const point<grid::square, C>, E > super_; 00084 E& exact_(); 00085 public: 00086 using super_::row; 00087 C& row(); 00088 using super_::col; 00089 C& col(); 00090 using super_::operator[]; 00091 C& operator[](unsigned i); 00092 }; 00093 00094 00095 00096 # ifndef MLN_INCLUDE_ONLY 00097 00098 // subject_impl 00099 00100 template <typename C, typename E> 00101 inline 00102 const C& 00103 subject_impl< const point<grid::square, C>, E >::row() const 00104 { 00105 return exact_().get_subject().row(); 00106 } 00107 00108 template <typename C, typename E> 00109 inline 00110 const C& 00111 subject_impl< const point<grid::square, C>, E >::col() const 00112 { 00113 return exact_().get_subject().col(); 00114 } 00115 00116 template <typename C, typename E> 00117 inline 00118 const C& 00119 subject_impl< const point<grid::square, C>, E >::operator[](unsigned i) const 00120 { 00121 mln_precondition(i < 2); 00122 return exact_().get_subject()[i]; 00123 } 00124 00125 template <typename C, typename E> 00126 inline 00127 const C& 00128 subject_impl< const point<grid::square, C>, E >::last_coord() const 00129 { 00130 return this->col(); 00131 } 00132 00133 template <typename C, typename E> 00134 inline 00135 const E& 00136 subject_impl< const point<grid::square, C>, E >::exact_() const 00137 { 00138 return internal::force_exact<const E>(*this); 00139 } 00140 00141 // subject_impl 00142 00143 template <typename C, typename E> 00144 inline 00145 C& 00146 subject_impl< point<grid::square, C>, E >::row() 00147 { 00148 return exact_().get_subject().row(); 00149 } 00150 00151 template <typename C, typename E> 00152 inline 00153 C& 00154 subject_impl< point<grid::square, C>, E >::col() 00155 { 00156 return exact_().get_subject().col(); 00157 } 00158 00159 template <typename C, typename E> 00160 inline 00161 C& 00162 subject_impl< point<grid::square, C>, E >::operator[](unsigned i) 00163 { 00164 mln_precondition(i < 2); 00165 return exact_().get_subject()[i]; 00166 } 00167 00168 template <typename C, typename E> 00169 inline 00170 E& 00171 subject_impl< point<grid::square, C>, E >::exact_() 00172 { 00173 return internal::force_exact<E>(*this); 00174 } 00175 00176 # endif // ! MLN_INCLUDE_ONLY 00177 00178 } // end of namespace mln::internal 00179 00180 00181 } // end of namespace mln 00182 00183 00184 # include <mln/core/alias/dpoint2d.hh> 00185 00186 00187 #endif // ! MLN_CORE_ALIAS_POINT2D_HH