Loading...
Searching...
No Matches
PLMD::CheckpointReader Class Reference

Reader for the PLUMED checkpoint file written by CheckpointWriter. More...

#include <Checkpoint.h>

Classes

struct  Entry
 

Public Types

enum class  Type { Int , Double , String }
 

Public Member Functions

 CheckpointReader (const std::string &content)
 Parse the content of a checkpoint file. Throws on any inconsistency.
 
void beginSection (const std::string &name)
 
void endSection ()
 
template<typename T>
T get (const std::string &name) const
 
const Entry & getEntry (const std::string &fullName) const
 
const std::vector< std::string > & getEntryNames () const
 Full names of all entries, in file order (for inspection tools).
 
unsigned getFormatVersion () const
 
const std::string & getPlumedVersion () const
 
const std::vector< std::string > & getSections () const
 Full names of all sections, in file order (for inspection tools).
 
std::vector< unsigned long long > getShape (const std::string &name) const
 Shape of a stored array.
 
bool has (const std::string &name) const
 True if an entry with this name exists in the current section.
 
bool hasSection (const std::string &name) const
 True if a section with this name exists inside the current section.
 
void read (const std::string &name, double &value) const
 
void read (const std::string &name, long long &value) const
 
void read (const std::string &name, std::string &value) const
 
template<typename T>
void read (const std::string &name, std::vector< T > &value) const
 Read an array; value is resized to the stored number of elements.
 
template<typename T>
std::enable_if< std::is_integral< T >::value &&!std::is_same< T, longlong >::value >::type read (const std::string &name, T &value) const
 
template<typename T>
std::enable_if< std::is_floating_point< T >::value &&!std::is_same< T, double >::value >::type read (const std::string &name, T &value) const
 

Static Public Member Functions

static unsigned checksum (const std::string &data)
 CRC32 of a string, the checksum used in the checkpoint file.
 
static std::string readFile (const std::string &path)
 Read a file and parse it.
 

Private Member Functions

std::string currentPath () const
 
const Entry & find (const std::string &name, Type type, bool scalar) const
 

Private Attributes

std::map< std::string, Entry > entries
 
unsigned formatVersion =0
 
std::vector< std::string > order
 
std::string plumedVersion
 
std::vector< std::string > sectionList
 
std::vector< std::string > sections
 

Detailed Description

Reader for the PLUMED checkpoint file written by CheckpointWriter.

The whole content is parsed on construction, which detects truncated or corrupted files. Entries are then accessed by name, relative to the current section; unknown entries and sections are ignored, so that newer files can be read by older code as long as the entries they need are present.

Member Enumeration Documentation

◆ Type

enum class PLMD::CheckpointReader::Type
strong
Enumerator
Int 
Double 
String 

Constructor & Destructor Documentation

◆ CheckpointReader()

PLMD::CheckpointReader::CheckpointReader ( const std::string & content)
explicit

Parse the content of a checkpoint file. Throws on any inconsistency.

Member Function Documentation

◆ beginSection()

void PLMD::CheckpointReader::beginSection ( const std::string & name)

◆ checksum()

unsigned PLMD::CheckpointReader::checksum ( const std::string & data)
static

CRC32 of a string, the checksum used in the checkpoint file.

◆ currentPath()

std::string PLMD::CheckpointReader::currentPath ( ) const
private

◆ endSection()

void PLMD::CheckpointReader::endSection ( )

◆ find()

const CheckpointReader::Entry & PLMD::CheckpointReader::find ( const std::string & name,
Type type,
bool scalar ) const
private

◆ get()

template<typename T>
T PLMD::CheckpointReader::get ( const std::string & name) const
inline

◆ getEntry()

const CheckpointReader::Entry & PLMD::CheckpointReader::getEntry ( const std::string & fullName) const

◆ getEntryNames()

const std::vector< std::string > & PLMD::CheckpointReader::getEntryNames ( ) const
inline

Full names of all entries, in file order (for inspection tools).

◆ getFormatVersion()

unsigned PLMD::CheckpointReader::getFormatVersion ( ) const
inline

◆ getPlumedVersion()

const std::string & PLMD::CheckpointReader::getPlumedVersion ( ) const
inline

◆ getSections()

const std::vector< std::string > & PLMD::CheckpointReader::getSections ( ) const
inline

Full names of all sections, in file order (for inspection tools).

◆ getShape()

std::vector< unsigned long long > PLMD::CheckpointReader::getShape ( const std::string & name) const

Shape of a stored array.

◆ has()

bool PLMD::CheckpointReader::has ( const std::string & name) const

True if an entry with this name exists in the current section.

◆ hasSection()

bool PLMD::CheckpointReader::hasSection ( const std::string & name) const

True if a section with this name exists inside the current section.

◆ read() [1/6]

void PLMD::CheckpointReader::read ( const std::string & name,
double & value ) const

◆ read() [2/6]

void PLMD::CheckpointReader::read ( const std::string & name,
long long & value ) const

◆ read() [3/6]

void PLMD::CheckpointReader::read ( const std::string & name,
std::string & value ) const

◆ read() [4/6]

template<typename T>
void PLMD::CheckpointReader::read ( const std::string & name,
std::vector< T > & value ) const
inline

Read an array; value is resized to the stored number of elements.

◆ read() [5/6]

template<typename T>
std::enable_if< std::is_integral< T >::value &&!std::is_same< T, longlong >::value >::type PLMD::CheckpointReader::read ( const std::string & name,
T & value ) const
inline

◆ read() [6/6]

template<typename T>
std::enable_if< std::is_floating_point< T >::value &&!std::is_same< T, double >::value >::type PLMD::CheckpointReader::read ( const std::string & name,
T & value ) const
inline

◆ readFile()

std::string PLMD::CheckpointReader::readFile ( const std::string & path)
static

Read a file and parse it.

Member Data Documentation

◆ entries

std::map<std::string,Entry> PLMD::CheckpointReader::entries
private

◆ formatVersion

unsigned PLMD::CheckpointReader::formatVersion =0
private

◆ order

std::vector<std::string> PLMD::CheckpointReader::order
private

◆ plumedVersion

std::string PLMD::CheckpointReader::plumedVersion
private

◆ sectionList

std::vector<std::string> PLMD::CheckpointReader::sectionList
private

◆ sections

std::vector<std::string> PLMD::CheckpointReader::sections
private

The documentation for this class was generated from the following files: