00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #ifndef EO_eoFileMonitor_h
00028 #define EO_eoFileMonitor_h
00029
00030 #include <string>
00031 #include <fstream>
00032 #include <stdexcept>
00033
00034 #include "utils/eoMonitor.h"
00035 #include "eoObject.h"
00036
00044 class eoFileMonitor : public eoMonitor
00045 {
00046 public :
00047
00048 eoFileMonitor(std::string _filename, std::string _delim = " ", bool _keep = false, bool _header=false)
00049 : filename(_filename), delim(_delim), keep(_keep), header(_header), firstcall(true)
00050 {
00051 if (! _keep) {
00052 std::ofstream os(filename.c_str());
00053 if (!os){
00054 std::string str = "eoFileMonitor: Could not open " + filename;
00055 throw std::runtime_error(str);
00056 }
00057 }
00058 }
00059
00060 virtual eoMonitor& operator()(void);
00061
00062 virtual eoMonitor& operator()(std::ostream& os);
00063
00064 void printHeader(void);
00065 virtual void printHeader(std::ostream& os);
00066
00067 virtual std::string getFileName() { return filename;}
00068
00069 private :
00070 std::string filename;
00071 std::string delim;
00072 bool keep;
00073 bool header;
00074 bool firstcall;
00075
00076 };
00077
00078 #endif