Finalized Checkpointing, see t-eoCheckpointing for a test
This commit is contained in:
parent
6d5d34ba1f
commit
9bcf9d95f8
12 changed files with 558 additions and 11 deletions
58
eo/src/utils/eoFileMonitor.cpp
Normal file
58
eo/src/utils/eoFileMonitor.cpp
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <stdexcept>
|
||||
|
||||
#include <utils/eoFileMonitor.h>
|
||||
#include <utils/compatibility.h>
|
||||
#include <utils/eoParam.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
void eoFileMonitor::operator()(void)
|
||||
{
|
||||
if (firsttime)
|
||||
{
|
||||
firsttime = false;
|
||||
|
||||
// create file
|
||||
ofstream os(filename.c_str());
|
||||
|
||||
if (!os)
|
||||
{
|
||||
string str = "eoFileMonitor: Could not open " + filename;
|
||||
throw runtime_error(str);
|
||||
}
|
||||
|
||||
iterator it = begin();
|
||||
|
||||
os << (*it)->longName();
|
||||
|
||||
++it;
|
||||
|
||||
for (; it != end(); ++it)
|
||||
{
|
||||
os << ',' << (*it)->longName();
|
||||
}
|
||||
}
|
||||
// ok, now the real saving. append to file
|
||||
|
||||
ofstream os(filename.c_str(), ios_base::app);
|
||||
|
||||
if (!os)
|
||||
{
|
||||
string str = "eoFileMonitor: Could not append to " + filename;
|
||||
throw runtime_error(str);
|
||||
}
|
||||
|
||||
iterator it = begin();
|
||||
|
||||
os << '\n' << (*it)->getValue();
|
||||
|
||||
for(++it; it != end(); ++it)
|
||||
{
|
||||
os << ',' << (*it)->getValue();
|
||||
}
|
||||
|
||||
// and we're there
|
||||
}
|
||||
|
||||
Reference in a new issue