File memorylayoutstate.h
File List > code_source > templat > include > TempLat > lattice > memory > memorylayoutstate.h
Go to the documentation of this file
#ifndef TEMPLAT_LATTICE_MEMORY_MEMORYLAYOUTSTATE_H
#define TEMPLAT_LATTICE_MEMORY_MEMORYLAYOUTSTATE_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 MemoryLayoutState
{
public:
// Put public methods here. These should change very little over time.
MemoryLayoutState() : mState(undefined) {}
void setToConfigSpace() { setState(configSpace); }
void setToFFTConfigSpace() { setState(fftConfigSpace); }
void setToFourierSpace() { setState(fourierSpace); }
bool isConfigSpace() const { return mState == configSpace || mState == undefined; }
bool isFFTConfigSpace() const { return mState == fftConfigSpace || mState == undefined; }
bool isFourierSpace() const { return mState == fourierSpace || mState == undefined; }
friend std::ostream &operator<<(std::ostream &ostream, const MemoryLayoutState &mls)
{
ostream << "Memory state: " << mls.getStateName(mls.mState);
return ostream;
}
private:
/* Put all member variables and private methods here. These may change arbitrarily. */
static constexpr int undefined = 0;
static constexpr int configSpace = 1;
static constexpr int fftConfigSpace = 2;
static constexpr int fourierSpace = 3;
int mState;
void setState(int state) { mState = state; }
const char *getStateName(const int state) const
{
const char *result = "unknown";
switch (state) {
case fourierSpace:
result = "Fourier space";
break;
case configSpace:
result = "configuration space";
break;
case fftConfigSpace:
result = "configuration space for FFT";
break;
case undefined:
default:
result = "undefined";
break;
}
return result;
}
};
} // namespace TempLat
#endif