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

point1d.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_POINT1D_HH
00027 # define MLN_CORE_ALIAS_POINT1D_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<grid::tick, def::coord> point1d;
00046 
00049   typedef point<grid::tick, def::coordf> point1df;
00050 
00051 
00052   namespace internal
00053   {
00054 
00055     // Specialization.
00056 
00057     template <typename C, typename E>
00058     struct subject_impl< const point<grid::tick, C>, E >
00059     {
00060       typedef C coord;
00061       enum { dim = 1 };
00062 
00063       typedef const C& ind_t;
00064       const C& ind() const;
00065 
00066       const C& operator[](unsigned i) const;
00067       const C& last_coord() const;
00068     private:
00069       const E& exact_() const;
00070     };
00071 
00072 
00073     // Specialization for point<M,C>.
00074 
00075     template <typename C, typename E>
00076     struct subject_impl<       point<grid::tick, C>, E > :
00077            subject_impl< const point<grid::tick, C>, E >
00078     {
00079     private:
00080       typedef subject_impl< const point<grid::tick, C>, E > super_;
00081       E& exact_();
00082     public:
00083       using super_::ind;
00084       C& ind();
00085       using super_::operator[];
00086       C& operator[](unsigned i);
00087     };
00088 
00089 
00090 
00091 # ifndef MLN_INCLUDE_ONLY
00092 
00093     // subject_impl
00094 
00095     template <typename C, typename E>
00096     inline
00097     const C&
00098     subject_impl< const point<grid::tick, C>, E >::ind() const
00099     {
00100       return exact_().get_subject().ind();
00101     }
00102 
00103     template <typename C, typename E>
00104     inline
00105     const C&
00106     subject_impl< const point<grid::tick, C>, E >::operator[](unsigned i) const
00107     {
00108       mln_precondition(i == 0);
00109       (void)i;
00110       return exact_().get_subject()[0];
00111     }
00112 
00113     template <typename C, typename E>
00114     inline
00115     const E&
00116     subject_impl< const point<grid::tick, C>, E >::exact_() const
00117     {
00118       return internal::force_exact<const E>(*this);
00119     }
00120 
00121     // subject_impl
00122 
00123     template <typename C, typename E>
00124     inline
00125     C&
00126     subject_impl< point<grid::tick, C>, E >::ind()
00127     {
00128       return exact_().get_subject().ind();
00129     }
00130 
00131     template <typename C, typename E>
00132     inline
00133     C&
00134     subject_impl< point<grid::tick, C>, E >::operator[](unsigned i)
00135     {
00136       mln_precondition(i == 0);
00137       (void)i;
00138       return exact_().get_subject()[0];
00139     }
00140 
00141 # endif // ! MLN_INCLUDE_ONLY
00142 
00143   } // end of namespace mln::internal
00144 
00145 } // end of namespace mln
00146 
00147 
00148 # include <mln/core/alias/dpoint1d.hh>
00149 
00150 
00151 #endif // ! MLN_CORE_ALIAS_POINT1D_HH

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