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

point3d.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_ALIAS_POINT3D_HH
00027 # define MLN_CORE_ALIAS_POINT3D_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 namespace mln
00040 {
00041 
00044   typedef point<grid::cube, def::coord> point3d;
00045 
00048   typedef point<grid::cube, def::coordf> point3df;
00049 
00050   namespace internal
00051   {
00052 
00053     // Specialization.
00054 
00055     template <typename C, typename E>
00056     struct subject_impl< const point<grid::cube, C>, E >
00057       : subject_point_impl< point<grid::cube, C>, E >
00058     {
00059       typedef C coord;
00060       enum { dim = 3 };
00061 
00062       typedef const C& row_t;
00063       const C& row() const;
00064 
00065       typedef const C& col_t;
00066       const C& col() const;
00067 
00068       typedef const C& sli_t;
00069       const C& sli() const;
00070 
00071       const C& operator[](unsigned i) const;
00072       const C& last_coord() const;
00073     private:
00074       const E& exact_() const;
00075     };
00076 
00077 
00078     // Specialization for point<M,C>.
00079 
00080     template <typename C, typename E>
00081     struct subject_impl<       point<grid::cube, C>, E > :
00082            subject_impl< const point<grid::cube, C>, E >
00083     {
00084     private:
00085       typedef subject_impl< const point<grid::cube, C>, E > super_;
00086       E& exact_();
00087     public:
00088 
00089       using super_::row;
00090       C& row();
00091 
00092       using super_::col;
00093       C& col();
00094 
00095       using super_::sli;
00096       C& sli();
00097 
00098       using super_::operator[];
00099       C& operator[](unsigned i);
00100     };
00101 
00102 
00103 
00104 # ifndef MLN_INCLUDE_ONLY
00105 
00106     // subject_impl
00107 
00108     template <typename C, typename E>
00109     inline
00110     const C&
00111     subject_impl< const point<grid::cube, C>, E >::row() const
00112     {
00113       return exact_().get_subject().row();
00114     }
00115 
00116     template <typename C, typename E>
00117     inline
00118     const C&
00119     subject_impl< const point<grid::cube, C>, E >::col() const
00120     {
00121       return exact_().get_subject().col();
00122     }
00123 
00124     template <typename C, typename E>
00125     inline
00126     const C&
00127     subject_impl< const point<grid::cube, C>, E >::sli() const
00128     {
00129       return exact_().get_subject().sli();
00130     }
00131 
00132     template <typename C, typename E>
00133     inline
00134     const C&
00135     subject_impl< const point<grid::cube, C>, E >::operator[](unsigned i) const
00136     {
00137       mln_precondition(i < 3);
00138       return exact_().get_subject()[i];
00139     }
00140 
00141     template <typename C, typename E>
00142     inline
00143     const C&
00144     subject_impl< const point<grid::cube, C>, E >::last_coord() const
00145     {
00146       return this->col();
00147     }
00148 
00149     template <typename C, typename E>
00150     inline
00151     const E&
00152     subject_impl< const point<grid::cube, C>, E >::exact_() const
00153     {
00154       return internal::force_exact<const E>(*this);
00155     }
00156 
00157     // subject_impl
00158 
00159     template <typename C, typename E>
00160     inline
00161     C&
00162     subject_impl< point<grid::cube, C>, E >::row()
00163     {
00164       return exact_().get_subject().row();
00165     }
00166 
00167     template <typename C, typename E>
00168     inline
00169     C&
00170     subject_impl< point<grid::cube, C>, E >::col()
00171     {
00172       return exact_().get_subject().col();
00173     }
00174 
00175     template <typename C, typename E>
00176     inline
00177     C&
00178     subject_impl< point<grid::cube, C>, E >::sli()
00179     {
00180       return exact_().get_subject().sli();
00181     }
00182 
00183     template <typename C, typename E>
00184     inline
00185     C&
00186     subject_impl< point<grid::cube, C>, E >::operator[](unsigned i)
00187     {
00188       mln_precondition(i < 3);
00189       return exact_().get_subject()[i];
00190     }
00191 
00192     template <typename C, typename E>
00193     inline
00194     E&
00195     subject_impl< point<grid::cube, C>, E >::exact_()
00196     {
00197       return internal::force_exact<E>(*this);
00198     }
00199 
00200 # endif // ! MLN_INCLUDE_ONLY
00201 
00202   } // end of namespace mln::internal
00203 
00204 
00205 } // end of namespace mln
00206 
00207 
00208 # include <mln/core/alias/dpoint3d.hh>
00209 
00210 
00211 #endif // ! MLN_CORE_ALIAS_POINT3D_HH

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