Writer for the PLUMED checkpoint file. More...
#include <Checkpoint.h>
Public Member Functions | |
| CheckpointWriter (const std::string &plumedVersion="") | |
| plumedVersion is stored in the header, for inspection only. | |
| void | beginSection (const std::string &name) |
| Open a section. Sections can be nested. | |
| void | endSection () |
| Close the current section. | |
| std::string | finalize () const |
| Return the complete file content (header, entries, trailer with checksum). | |
| unsigned | getNumberOfEntriesInSection () const |
| Number of entries written so far in the current section (sub-sections count as one). | |
| void | write (const std::string &name, const char *value) |
| void | write (const std::string &name, const std::string &value) |
| template<typename T> | |
| void | write (const std::string &name, const std::vector< T > &value, std::vector< unsigned long long > dims={}) |
| Write an array with an explicit shape (dims empty means one-dimensional). | |
| void | write (const std::string &name, double value) |
| void | write (const std::string &name, long long value) |
| template<typename T> | |
| std::enable_if< std::is_integral< T >::value &&!std::is_same< T, longlong >::value >::type | write (const std::string &name, T value) |
| template<typename T> | |
| std::enable_if< std::is_floating_point< T >::value &&!std::is_same< T, double >::value >::type | write (const std::string &name, T value) |
| void | writeFile (const std::string &path, const std::string &prevPath) const |
| Write the content to path atomically: the data go to a temporary file, which is then renamed to path; the previous file, if any, is kept as prevPath (no backup if prevPath is empty). | |
Private Member Functions | |
| std::string | currentPath () const |
| void | putName (const std::string &name) |
| void | putShape (const std::vector< unsigned long long > &dims) |
| void | writeDoubleArray (const std::string &name, const double *data, const std::vector< unsigned long long > &dims) |
| void | writeIntArray (const std::string &name, const long long *data, const std::vector< unsigned long long > &dims) |
Private Attributes | |
| std::string | buffer |
| std::vector< unsigned > | entriesInSection |
| std::vector< std::string > | sections |
Writer for the PLUMED checkpoint file.
The checkpoint is a sequence of named, typed entries (64-bit integers, doubles, strings, and arrays of integers or doubles with a shape) grouped in nested sections. Actions write their own state in a section named after their label and never see the storage format, which is a minimal little-endian binary layout described in Checkpoint.cpp. The content is accumulated in memory and written to disk atomically by writeFile().
|
explicit |
plumedVersion is stored in the header, for inspection only.
| void PLMD::CheckpointWriter::beginSection | ( | const std::string & | name | ) |
Open a section. Sections can be nested.
|
private |
| void PLMD::CheckpointWriter::endSection | ( | ) |
Close the current section.
| std::string PLMD::CheckpointWriter::finalize | ( | ) | const |
Return the complete file content (header, entries, trailer with checksum).
All sections must be closed.
| unsigned PLMD::CheckpointWriter::getNumberOfEntriesInSection | ( | ) | const |
Number of entries written so far in the current section (sub-sections count as one).
|
private |
|
private |
|
inline |
| void PLMD::CheckpointWriter::write | ( | const std::string & | name, |
| const std::string & | value ) |
|
inline |
Write an array with an explicit shape (dims empty means one-dimensional).
| void PLMD::CheckpointWriter::write | ( | const std::string & | name, |
| double | value ) |
| void PLMD::CheckpointWriter::write | ( | const std::string & | name, |
| long long | value ) |
|
inline |
|
inline |
|
private |
| void PLMD::CheckpointWriter::writeFile | ( | const std::string & | path, |
| const std::string & | prevPath ) const |
Write the content to path atomically: the data go to a temporary file, which is then renamed to path; the previous file, if any, is kept as prevPath (no backup if prevPath is empty).
|
private |
|
private |
|
private |
|
private |
Hosted by GitHub
|
1.13.2
|