Dune Core Modules (2.10.0)

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// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file LICENSE.md in module root
4// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
5
6#ifndef DUNE_COMMON_PARALLEL_LOCALINDEX_HH
7#define DUNE_COMMON_PARALLEL_LOCALINDEX_HH
8
9#include <cstddef>
10
11namespace Dune
12{
13
14
28 enum LocalIndexState {VALID, DELETED};
29
30
35 {
36 public:
42 localIndex_(0), state_(VALID){}
43
44
49 LocalIndex(std::size_t index) :
50 localIndex_(index), state_(VALID){}
55 inline const std::size_t& local() const;
56
60 inline operator std::size_t() const;
61
67 inline LocalIndex& operator=(std::size_t index);
68
73 inline LocalIndexState state() const;
74
79 inline void setState(LocalIndexState state);
80
81 private:
83 std::size_t localIndex_;
84
91 char state_;
92
93 };
94
95
96
97 inline const std::size_t& LocalIndex::local() const {
98 return localIndex_;
99 }
100
101 inline LocalIndex::operator std::size_t() const {
102 return localIndex_;
103 }
104
105 inline LocalIndex& LocalIndex::operator=(std::size_t index){
106 localIndex_ = index;
107 return *this;
108 }
109
111 return static_cast<LocalIndexState>(state_);
112 }
113
115 state_ = static_cast<char>(state);
116 }
117
120} // namespace Dune
121
122#endif // DUNE_COMMON_PARALLEL_LOCALINDEX_HH
An index present on the local process.
Definition: localindex.hh:35
LocalIndex()
Constructor. known to other processes.
Definition: localindex.hh:41
LocalIndex(std::size_t index)
Constructor.
Definition: localindex.hh:49
LocalIndexState
The states available for the local indices.
Definition: localindex.hh:28
LocalIndex & operator=(std::size_t index)
Assign a new local index.
Definition: localindex.hh:105
LocalIndexState state() const
Get the state.
Definition: localindex.hh:110
const std::size_t & local() const
get the local index.
Definition: localindex.hh:97
void setState(LocalIndexState state)
Set the state.
Definition: localindex.hh:114
Dune namespace.
Definition: alignedallocator.hh:13
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Dec 27, 23:30, 2024)