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

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

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