Loading...
Searching...
No Matches
localindex.hh
Go to the documentation of this file.
// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
// vi: set et ts=4 sw=2 sts=2:
// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file LICENSE.md in module root
// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
#ifndef DUNE_COMMON_PARALLEL_LOCALINDEX_HH
#define DUNE_COMMON_PARALLEL_LOCALINDEX_HH
#include <cstddef>
namespace Dune
{
enum LocalIndexState {VALID, DELETED};
class LocalIndex
{
public:
LocalIndex() :
localIndex_(0), state_(VALID){}
LocalIndex(std::size_t index) :
localIndex_(index), state_(VALID){}
inline const std::size_t& local() const;
inline operator std::size_t() const;
inline LocalIndex& operator=(std::size_t index);
inline LocalIndexState state() const;
inline void setState(LocalIndexState state);
private:
std::size_t localIndex_;
char state_;
};
inline const std::size_t& LocalIndex::local() const {
return localIndex_;
}
inline LocalIndex::operator std::size_t() const {
return localIndex_;
}
inline LocalIndex& LocalIndex::operator=(std::size_t index){
localIndex_ = index;
return *this;
}
inline LocalIndexState LocalIndex::state() const {
return static_cast<LocalIndexState>(state_);
}
inline void LocalIndex::setState(LocalIndexState state){
state_ = static_cast<char>(state);
}
} // namespace Dune
#endif // DUNE_COMMON_PARALLEL_LOCALINDEX_HH
Dune::LocalIndexState
LocalIndexState
The states available for the local indices.
Definition localindex.hh:28
Dune::LocalIndex::operator=
LocalIndex & operator=(std::size_t index)
Assign a new local index.
Definition localindex.hh:105
Dune::LocalIndex::state
LocalIndexState state() const
Get the state.
Definition localindex.hh:110
Dune::LocalIndex::local
const std::size_t & local() const
get the local index.
Definition localindex.hh:97
Dune::LocalIndex::setState
void setState(LocalIndexState state)
Set the state.
Definition localindex.hh:114
Dune::VALID
@ VALID
Definition localindex.hh:28
Dune::DELETED
@ DELETED
Definition localindex.hh:28
Dune
Dune namespace
Definition alignedallocator.hh:13
Dune::LocalIndex
An index present on the local process.
Definition localindex.hh:35
Dune::LocalIndex::LocalIndex
LocalIndex()
Constructor. known to other processes.
Definition localindex.hh:41
Dune::LocalIndex::LocalIndex
LocalIndex(std::size_t index)
Constructor.
Definition localindex.hh:49