• Main Page
  • Related Pages
  • Modules
  • Namespaces
  • Classes
  • Files
  • File List

coord_impl.hh

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_INTERNAL_COORD_IMPL_HH
00027 # define MLN_CORE_INTERNAL_COORD_IMPL_HH
00028 
00034 # include <mln/core/internal/force_exact.hh>
00035 
00036 
00037 namespace mln
00038 {
00039 
00040   namespace internal
00041   {
00042 
00043 
00045 
00046 
00047     /* Implementation class to equip generalized points with
00048      * explicit access to their coordinates.
00049      *
00050      */
00051     template <unsigned n, typename C, typename E>
00052     struct coord_impl_;
00053 
00054     template <typename C, typename E>
00055     struct coord_impl_<1, C, E>
00056     {
00057       const C& ind() const;
00058     private:
00059       typedef coord_impl_<1, C, E> self_;
00060 
00061     };
00062 
00063     template <typename C, typename E>
00064     struct coord_impl_<2, C, E>
00065     {
00066       const C&row() const;
00067       const C&col() const;
00068     };
00069 
00070     template <typename C, typename E>
00071     struct coord_impl_<3, C, E>
00072     {
00073       const C&sli() const;
00074       const C&row() const;
00075       const C&col() const;
00076     };
00077 
00078 
00079     // mutable_coord_impl
00080 
00081     template <unsigned n, typename C, typename E>
00082     struct mutable_coord_impl_;
00083 
00084     template <typename C, typename E>
00085     struct mutable_coord_impl_<1, C, E>
00086     {
00087       const C& ind() const;
00088       C& ind();
00089     };
00090 
00091     template <typename C, typename E>
00092     struct mutable_coord_impl_<2, C, E>
00093     {
00094       const C& row() const;
00095       C& row();
00096       const C& col() const;
00097       C& col();
00098     };
00099 
00100     template <typename C, typename E>
00101     struct mutable_coord_impl_<3, C, E>
00102     {
00103       const C& sli() const;
00104       C& sli();
00105       const C& row() const;
00106       C& row();
00107       const C& col() const;
00108       C& col();
00109     };
00110 
00111 
00112 # ifndef MLN_INCLUDE_ONLY
00113 
00114     // coord_impl
00115 
00116     // 1
00117 
00118     template <typename C, typename E>
00119     inline
00120     const C& coord_impl_<1, C, E>::ind() const
00121     {
00122       return internal::force_exact<E>(*this)[0];
00123     }
00124 
00125     // 2
00126 
00127     template <typename C, typename E>
00128     inline
00129     const C& coord_impl_<2, C, E>::row() const
00130     {
00131       return internal::force_exact<E>(*this)[0];
00132     }
00133 
00134     template <typename C, typename E>
00135     inline
00136     const C& coord_impl_<2, C, E>::col() const
00137     {
00138       return internal::force_exact<E>(*this)[1];
00139     }
00140 
00141     // 3
00142 
00143     template <typename C, typename E>
00144     inline
00145     const C& coord_impl_<3, C, E>::sli() const
00146     {
00147       return internal::force_exact<E>(*this)[0];
00148     }
00149 
00150     template <typename C, typename E>
00151     inline
00152     const C& coord_impl_<3, C, E>::row() const
00153     {
00154       return internal::force_exact<E>(*this)[1];
00155     }
00156 
00157     template <typename C, typename E>
00158     inline
00159     const C& coord_impl_<3, C, E>::col() const
00160     {
00161       return internal::force_exact<E>(*this)[2];
00162     }
00163 
00164 
00165     // mutable_coord_impl
00166 
00167     // 1
00168 
00169     template <typename C, typename E>
00170     inline
00171     const C& mutable_coord_impl_<1, C, E>::ind() const
00172     {
00173       return internal::force_exact<E>(*this)[0];
00174     }
00175 
00176     template <typename C, typename E>
00177     inline
00178     C& mutable_coord_impl_<1, C, E>::ind()
00179     {
00180       return internal::force_exact<E>(*this)[0];
00181     }
00182 
00183     // 2
00184 
00185     template <typename C, typename E>
00186     inline
00187     const C& mutable_coord_impl_<2, C, E>::row() const
00188     {
00189       return internal::force_exact<E>(*this)[0];
00190     }
00191 
00192     template <typename C, typename E>
00193     inline
00194     C& mutable_coord_impl_<2, C, E>::row()
00195     {
00196       return internal::force_exact<E>(*this)[0];
00197     }
00198 
00199     template <typename C, typename E>
00200     inline
00201     const C& mutable_coord_impl_<2, C, E>::col() const
00202     {
00203       return internal::force_exact<E>(*this)[1];
00204     }
00205 
00206     template <typename C, typename E>
00207     inline
00208     C& mutable_coord_impl_<2, C, E>::col()
00209     {
00210       return internal::force_exact<E>(*this)[1];
00211     }
00212 
00213     // 3
00214 
00215     template <typename C, typename E>
00216     inline
00217     const C& mutable_coord_impl_<3, C, E>::sli() const
00218     {
00219       return internal::force_exact<E>(*this)[0];
00220     }
00221 
00222     template <typename C, typename E>
00223     inline
00224     C& mutable_coord_impl_<3, C, E>::sli()
00225     {
00226       return internal::force_exact<E>(*this)[0];
00227     }
00228 
00229     template <typename C, typename E>
00230     inline
00231     const C& mutable_coord_impl_<3, C, E>::row() const
00232     {
00233       return internal::force_exact<E>(*this)[1];
00234     }
00235 
00236     template <typename C, typename E>
00237     inline
00238     C& mutable_coord_impl_<3, C, E>::row()
00239     {
00240       return internal::force_exact<E>(*this)[1];
00241     }
00242 
00243     template <typename C, typename E>
00244     inline
00245     const C& mutable_coord_impl_<3, C, E>::col() const
00246     {
00247       return internal::force_exact<E>(*this)[2];
00248     }
00249 
00250     template <typename C, typename E>
00251     inline
00252     C& mutable_coord_impl_<3, C, E>::col()
00253     {
00254       return internal::force_exact<E>(*this)[2];
00255     }
00256 
00257 # endif // ! MLN_INCLUDE_ONLY
00258 
00259   } // end of namespace mln::internal
00260 
00261 } // end of namespace mln
00262 
00263 
00264 #endif // ! MLN_CORE_INTERNAL_COORD_IMPL_HH

Generated on Tue Oct 4 2011 15:23:40 for Milena (Olena) by  doxygen 1.7.1