From aac8ff6cb98f5a4a5ae4482dfe4381f0916dd6d6 Mon Sep 17 00:00:00 2001 From: okoenig Date: Thu, 21 Aug 2003 13:02:53 +0000 Subject: [PATCH] added parameters to the constructors to start generation counting !=0 the parameters are optional and appended in the end --- eo/src/utils/eoFileSnapshot.h | 12 ++++++++---- eo/src/utils/eoGnuplot1DSnapshot.h | 12 ++++++------ eo/src/utils/eoUpdater.h | 8 ++++---- 3 files changed, 18 insertions(+), 14 deletions(-) diff --git a/eo/src/utils/eoFileSnapshot.h b/eo/src/utils/eoFileSnapshot.h index 67182d79..ed285768 100644 --- a/eo/src/utils/eoFileSnapshot.h +++ b/eo/src/utils/eoFileSnapshot.h @@ -56,12 +56,13 @@ public : typedef std::vector vDouble; typedef eoValueParam > vDoubleParam; - eoFileSnapshot(std::string _dirname, unsigned _frequency = 1, - std::string _filename = "gen", std::string _delim = " "): + eoFileSnapshot(std::string _dirname, unsigned _frequency = 1, std::string _filename = "gen", + std::string _delim = " ", unsigned _counter = 0, bool _rmFiles = true): dirname(_dirname), frequency(_frequency), - filename(_filename), delim(_delim), counter(0), boolChanged(true) + filename(_filename), delim(_delim), counter(_counter), boolChanged(true) { std::string s = "test -d " + dirname; + int res = system(s.c_str()); // test for (unlikely) errors if ( (res==-1) || (res==127) ) @@ -71,10 +72,13 @@ public : { s = std::string("mkdir ")+dirname; } - else + else if (!res && _rmFiles) { s = std::string("/bin/rm ")+dirname+ "/" + filename + "*"; } + else + s = " "; + system(s.c_str()); // all done } diff --git a/eo/src/utils/eoGnuplot1DSnapshot.h b/eo/src/utils/eoGnuplot1DSnapshot.h index a8a967b2..0e208321 100644 --- a/eo/src/utils/eoGnuplot1DSnapshot.h +++ b/eo/src/utils/eoGnuplot1DSnapshot.h @@ -58,17 +58,17 @@ class eoGnuplot1DSnapshot: public eoFileSnapshot, public eoGnuplot public: // Ctor eoGnuplot1DSnapshot(std::string _dirname, unsigned _frequency = 1, - std::string _filename = "gen", std::string _delim = " ") : - eoFileSnapshot(_dirname, _frequency, _filename, _delim), + std::string _filename = "gen", std::string _delim = " ", unsigned _counter = 0, bool _rmFiles = true) : + eoFileSnapshot(_dirname, _frequency, _filename, _delim, _counter, _rmFiles), eoGnuplot(_filename,"set data style points"), pointSize(5) {} // Ctor - eoGnuplot1DSnapshot(std::string _dirname, eoRealVectorBounds & _bounds, - unsigned _frequency = 1, - std::string _filename = "gen", std::string _delim = " ") : - eoFileSnapshot(_dirname, _frequency, _filename, _delim), + eoGnuplot1DSnapshot(std::string _dirname, eoRealVectorBounds & _bounds, + unsigned _frequency = 1, std::string _filename = "gen", + std::string _delim = " ", unsigned _counter = 0, bool _rmFiles = true ) : + eoFileSnapshot(_dirname, _frequency, _filename, _delim, _counter, _rmFiles), eoGnuplot(_filename,"set data style points"), pointSize(5) { diff --git a/eo/src/utils/eoUpdater.h b/eo/src/utils/eoUpdater.h index 4d87906b..c708fd5d 100644 --- a/eo/src/utils/eoUpdater.h +++ b/eo/src/utils/eoUpdater.h @@ -119,13 +119,13 @@ private : class eoCountedStateSaver : public eoUpdater { public : - eoCountedStateSaver(unsigned _interval, const eoState& _state, std::string _prefix, bool _saveOnLastCall, std::string _extension = "sav") - : state(_state), interval(_interval), counter(0), + eoCountedStateSaver(unsigned _interval, const eoState& _state, std::string _prefix, bool _saveOnLastCall, std::string _extension = "sav", unsigned _counter = 0) + : state(_state), interval(_interval), counter(_counter), saveOnLastCall(_saveOnLastCall), prefix(_prefix), extension(_extension) {} - eoCountedStateSaver(unsigned _interval, const eoState& _state, std::string _prefix = "state", std::string _extension = "sav") - : state(_state), interval(_interval), counter(0), + eoCountedStateSaver(unsigned _interval, const eoState& _state, std::string _prefix = "state", std::string _extension = "sav", unsigned _counter = 0) + : state(_state), interval(_interval), counter(_counter), saveOnLastCall(true), prefix(_prefix), extension(_extension) {}