File ghoststatekeeper.h
File List > code_source > templat > include > TempLat > lattice > ghostcells > ghoststatekeeper.h
Go to the documentation of this file
#ifndef TEMPLAT_LATTICE_MANIPULATION_GHOSTSTATEKEEPER_H
#define TEMPLAT_LATTICE_MANIPULATION_GHOSTSTATEKEEPER_H
/* This file is part of TempLat, available at https://cosmolattice.github.io/templat .
Copyright 2021-2026 The TempLat authors, see AUTHORS.md.
Released under the MIT license, see LICENSE.md. */
// File info: Main contributor(s): Wessel Valkenburg, Year: 2019
#include <ostream>
namespace TempLat
{
class GhostStateKeeper
{
public:
// Put public methods here. These should change very little over time.
GhostStateKeeper() : mCurrentlyStale(true), mCurrentlyUpToDate(false) {}
void setStale()
{
mCurrentlyUpToDate = false;
mCurrentlyStale = true;
}
void setUpToDate()
{
mCurrentlyUpToDate = true;
mCurrentlyStale = false;
}
const bool &isStale() const { return mCurrentlyStale; }
const bool &isUpToDate() const { return mCurrentlyUpToDate; }
const bool &isOutDated() const { return isStale(); }
const bool &needsUpdate() const { return isStale(); }
friend std::ostream &operator<<(std::ostream &ostream, const GhostStateKeeper &gsk)
{
ostream << "Ghost state: "
<< (gsk.isStale() ? "stale (needs update)" : (gsk.isUpToDate() ? "up to date" : "(BROKEN)"));
return ostream;
}
private:
/* Put all member variables and private methods here. These may change arbitrarily. */
bool mCurrentlyStale;
bool mCurrentlyUpToDate;
};
} // namespace TempLat
#endif