From e5747053edee2ca1dcf438e58ce75539a58cf0cb Mon Sep 17 00:00:00 2001 From: Omar Valsson <omar.valsson@gmail.com> Date: Sun, 8 May 2016 17:03:58 +0200 Subject: [PATCH] Added an option in OFile to enforce backup of files even if restarting --- src/tools/OFile.cpp | 10 +++++++++- src/tools/OFile.h | 6 +++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/tools/OFile.cpp b/src/tools/OFile.cpp index def2c449a..e30bdd9e4 100644 --- a/src/tools/OFile.cpp +++ b/src/tools/OFile.cpp @@ -72,7 +72,8 @@ OFile::OFile(): linked(NULL), fieldChanged(false), backstring("bck"), - enforceRestart_(false) + enforceRestart_(false), + enforceBackup_(false) { fmtField(); buflen=1; @@ -373,6 +374,7 @@ FileBase& OFile::flush(){ bool OFile::checkRestart()const{ if(enforceRestart_) return true; + else if(enforceBackup_) return false; else if(action) return action->getRestart(); else if(plumed) return plumed->getRestart(); else return false; @@ -380,9 +382,15 @@ bool OFile::checkRestart()const{ OFile& OFile::enforceRestart(){ enforceRestart_=true; + enforceBackup_=false; return *this; } +OFile& OFile::enforceBackup(){ + enforceBackup_=true; + enforceRestart_=false; + return *this; } +} diff --git a/src/tools/OFile.h b/src/tools/OFile.h index 5edcc8573..a5633e76f 100644 --- a/src/tools/OFile.h +++ b/src/tools/OFile.h @@ -183,6 +183,8 @@ public virtual FileBase{ bool checkRestart()const; /// True if restart behavior should be forced bool enforceRestart_; +/// True if backup behavior (i.e. non restart) should be forced + bool enforceBackup_; public: /// Constructor OFile(); @@ -251,9 +253,11 @@ this method can be used to clean the field list. OFile&rewind(); /// Flush a file virtual FileBase&flush(); -/// Enforce restart, also if the attached plume object is not restarting. +/// Enforce restart, also if the attached plumed object is not restarting. /// Useful for tests OFile&enforceRestart(); +/// Enforce backup, even if the attached plumed object is restarting. + OFile&enforceBackup(); }; /// Write using << syntax -- GitLab