This repository has been archived on 2026-03-28. You can view files and clone it, but you cannot make any changes to its state, such as pushing and creating new issues, pull requests or comments.
eodev/eo/src/utils/eoFileMonitor.cpp
mac ff108477c3 eoCounter?
eoEasyEA -- made it copyable again
eoEvalFunc -- added specialized eoEvalFuncCounter
eoEvolutionStrategy -- nothing much
eoGenContinue -- nothing
eoPop -- fixed nth_element_fitness
eoBitOp -- fixed error in xover
eoFileMonitor -- now appends always
eoParam -- worked around memory leak in MSC's strstream
eoParser -- changed -pconfig_file to @config_file
eoParser -- added messages instead of exception when required param is missing
eoStat -- added eoDistanceStat
t-eoFunctor -- don't know
2000-08-23 12:03:01 +00:00

67 lines
1.1 KiB
C++

#include <iostream>
#include <fstream>
#include <stdexcept>
#include <utils/eoFileMonitor.h>
#include <utils/compatibility.h>
#include <utils/eoParam.h>
using namespace std;
void eoFileMonitor::printHeader(std::ostream& os)
{
iterator it = vec.begin();
os << (*it)->longName();
++it;
for (; it != vec.end(); ++it)
{
os << ',' << (*it)->longName();
}
os << '\n';
}
void eoFileMonitor::printHeader()
{
// create file
ofstream os(filename.c_str());
if (!os)
{
string str = "eoFileMonitor: Could not open " + filename;
throw runtime_error(str);
}
printHeader(os);
}
eoMonitor& eoFileMonitor::operator()(void)
{
ofstream os(filename.c_str(), ios_base::app);
if (!os)
{
string str = "eoFileMonitor: Could not append to " + filename;
throw runtime_error(str);
}
return operator()(os);
}
eoMonitor& eoFileMonitor::operator()(std::ostream& os)
{
iterator it = vec.begin();
os << (*it)->getValue();
for(++it; it != vec.end(); ++it)
{
os << ',' << (*it)->getValue();
}
os << '\n';
return *this;
}