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

dindex.hh

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_UTIL_DINDEX_HH
00027 # define MLN_UTIL_DINDEX_HH
00028 
00038 # include <mln/util/index.hh>
00039 # include <mln/literal/zero.hh>
00040 # include <mln/literal/one.hh>
00041 
00042 
00043 namespace mln
00044 {
00045 
00046   namespace util
00047   {
00048 
00049     // Fwd decl.
00050     template <typename Tag> struct dindex_;
00051 
00052 
00056     template <typename Tag = void>
00057     struct dindex_ // : public Object< dindex_<Tag> >
00058     {
00059       typedef Object<void> category;
00060 
00061       typedef index_<Tag> psite;
00062       typedef index_<Tag> site;
00063 
00064       typedef int coord;
00065       enum { dim = 1 };
00066 
00067       int i_;
00068 
00069       dindex_()
00070       {
00071       }
00072 
00073       dindex_(int i)
00074         : i_(i)
00075       {
00076       }
00077 
00079       dindex_(const literal::zero_t&)
00080         : i_(0)
00081       {
00082       }
00083       dindex_<Tag>& operator=(const literal::zero_t&)
00084       {
00085         i_ = 0;
00086         return *this;
00087       }
00088 
00089       dindex_(const literal::one_t&)
00090         : i_(1)
00091       {
00092       }
00093       dindex_<Tag>& operator=(const literal::one_t&)
00094       {
00095         i_ = 1;
00096         return *this;
00097       }
00099 
00100       bool operator<(const dindex_& rhs) const
00101       {
00102         return i_ < rhs.i_;
00103       }
00104 
00105       operator int() const
00106       {
00107         return i_;
00108       }
00109     };
00110 
00111     typedef dindex_<void> dindex;
00112 
00113 
00114 
00115 # ifndef MLN_INCLUDE_ONLY
00116 
00117     // FIXME
00118 
00119 # endif // ! MLN_INCLUDE_ONLY
00120 
00121   } // end of namespace mln::util
00122 
00123 } // end of namespace mln
00124 
00125 
00126 #endif // ! MLN_UTIL_DINDEX_HH

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