23#include "OPALconfig.h"
37 namespace fs = std::filesystem;
39 if (fs::exists(
fname_m) && restart) {
54 std::queue<std::string> allLines;
57 fs.open (
fname_m.c_str(), std::fstream::in);
59 if (!fs.is_open())
return;
61 while (getline(fs, line)) {
66 fs.open (
fname_m.c_str(), std::fstream::out);
68 if (!fs.is_open())
return;
70 while (allLines.size() > numberOfLines) {
71 fs << allLines.front() <<
"\n";
83 std::string versionFile;
89 std::queue<std::string> allLines;
92 fs.open (
fname_m.c_str(), std::fstream::in);
94 if (!fs.is_open())
return;
96 while (getline(fs, line)) {
101 fs.open (
fname_m.c_str(), std::fstream::out);
103 if (!fs.is_open())
return;
105 while (!allLines.empty()) {
106 line = allLines.front();
108 if (line != versionFile) {
111 fs << OPAL_PROJECT_NAME <<
" "
112 << OPAL_PROJECT_VERSION <<
" git rev. #"
138 os_m.setf(std::ios::scientific, std::ios::floatfield);
166 os_m <<
"SDDS1" << std::endl;
167 os_m <<
"&description\n"
178 os_m <<
"¶meter\n"
179 <<
indent_m <<
"name=" << std::get<0>(param) <<
",\n"
180 <<
indent_m <<
"type=" << std::get<1>(param) <<
",\n"
181 <<
indent_m <<
"description=\"" << std::get<2>(param) <<
"\"\n"
210 std::stringstream revision;
211 revision << OPAL_PROJECT_NAME <<
" "
212 << OPAL_PROJECT_VERSION <<
" "
219 flavor =
"opal-cycl";
226 addParameter(
"revision",
"string",
"git revision of opal", revision.str());
228 addParameter(
"flavor",
"string",
"OPAL flavor that wrote file", flavor);
Inform & endl(Inform &inf)
std::string getGitRevision()
static OpalData * getInstance()
void replaceVersionString()
SDDSWriter(const std::string &fname, bool restart)
void rewindLines(size_t numberOfLines)
delete the last 'numberOfLines' lines of the file 'fileName'
static constexpr unsigned int precision_m
double getLastValue(const std::string &column)
void addDefaultParameters()
std::queue< std::string > paramValues_m
void writeHeader()
Write SDDS header.
std::ios_base::openmode mode_m
First write to the statistics output file.
std::tuple< std::string, std::string, std::string > param_t
std::queue< param_t > params_m
void addParameter(const std::string &name, const std::string &type, const std::string &desc, const T &value)
void getParameterValue(std::string parameter_name, T &nval)
void getValue(int t, std::string column_name, T &nval)