dune-common  2.3.1-rc1
localindex.hh
Go to the documentation of this file.
1 // -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 // vi: set et ts=4 sw=2 sts=2:
3 // $Id$
4 
5 #ifndef DUNE_COMMON_LOCALINDEX_HH
6 #define DUNE_COMMON_LOCALINDEX_HH
7 
8 #include <cstddef>
9 
10 namespace Dune
11 {
12 
13 
28 
29 
33  class LocalIndex
34  {
35  public:
41  localIndex_(0), state_(VALID){}
42 
43 
48  LocalIndex(std::size_t index) :
49  localIndex_(index), state_(VALID){}
54  inline const std::size_t& local() const;
55 
59  inline operator std::size_t() const;
60 
66  inline LocalIndex& operator=(std::size_t index);
67 
72  inline LocalIndexState state() const;
73 
78  inline void setState(LocalIndexState state);
79 
80  private:
82  std::size_t localIndex_;
83 
90  char state_;
91 
92  };
93 
94 
95 
96  inline const std::size_t& LocalIndex::local() const {
97  return localIndex_;
98  }
99 
100  inline LocalIndex::operator std::size_t() const {
101  return localIndex_;
102  }
103 
104  inline LocalIndex& LocalIndex::operator=(std::size_t index){
105  localIndex_ = index;
106  return *this;
107  }
108 
110  return static_cast<LocalIndexState>(state_);
111  }
112 
114  state_ = static_cast<char>(state);
115  }
116 
119 } // namespace Dune
120 
121 #endif
An index present on the local process.
Definition: localindex.hh:33
LocalIndexState
The states avaiable for the local indices.
Definition: localindex.hh:27
LocalIndex & operator=(std::size_t index)
Assign a new local index.
Definition: localindex.hh:104
LocalIndexState state() const
Get the state.
Definition: localindex.hh:109
Definition: localindex.hh:27
LocalIndex(std::size_t index)
Constructor.
Definition: localindex.hh:48
void setState(LocalIndexState state)
Set the state.
Definition: localindex.hh:113
const std::size_t & local() const
get the local index.
Definition: localindex.hh:96
LocalIndex()
Constructor. known to other processes.
Definition: localindex.hh:40
Definition: localindex.hh:27