Modified the contructor: the default value for the delimiter is now " "

and I added a boolean argument to indicate whether or not we want to
         overwrite an existing file with same name (default is overwrite).
Added the getFileName accessor.
This commit is contained in:
evomarc 2000-11-28 06:46:37 +00:00
commit bee8388a1e

View file

@ -23,6 +23,10 @@
mkeijzer@dhi.dk
*/
//-----------------------------------------------------------------------------
/** Modified the default behavior, so that it erases existing files.
Can be modified in the ctor.
MS 25/11/00
*/
#ifndef _eoFileMonitor_h
#define _eoFileMonitor_h
@ -38,17 +42,32 @@
class eoFileMonitor : public eoMonitor
{
public :
eoFileMonitor(std::string _filename, std::string _delim = ",") : filename(_filename), delim(_delim) {}
eoFileMonitor(std::string _filename, std::string _delim = " ",
bool _keep = false) :
filename(_filename), delim(_delim), keep(keep)
{
if (! _keep)
{
ofstream os(filename.c_str());
if (!os)
{
string str = "eoFileMonitor: Could not open " + filename;
throw runtime_error(str);
}
}
}
eoMonitor& operator()(void);
eoMonitor& operator()(std::ostream& os);
void printHeader(void);
virtual void printHeader(std::ostream& os);
virtual string getFileName() // for eoGnuPlot
{ return filename;}
private :
std::string filename;
std::string delim;
bool keep; // should we append or create a new file
};
#endif