12 #ifndef BACKUP_TYPE_HPP 13 #define BACKUP_TYPE_HPP 30 Backup(T &original,
const char *
const file,
const int line) : original(original), valid(true), original_value(original), file(file), line(line) {}
40 Backup(T &original,
const U &new_value,
const char *
const file,
const int line) : original(original), valid(true), original_value(original), file(file), line(line)
56 DEBUG(misc, 0,
"%s:%d: Backupped value was not restored!", this->file, this->line);
77 return original_value;
99 this->original = this->original_value;
127 this->original_value = this->original;
137 return this->original_value == this->original;
145 const char *
const file;
bool IsValid() const
Checks whether the variable was already restored.
void Revert()
Revert the variable to its original value, but do not mark it as restored.
void Change(const U &new_value)
Change the value of the variable.
Backup(T &original, const U &new_value, const char *const file, const int line)
Backup variable and switch to new value.
Class to backup a specific variable and restore it later.
bool Verify() const
Check whether the variable is currently equals the backup.
Backup(T &original, const char *const file, const int line)
Backup variable.
const T & GetOriginalValue() const
Returns the backupped value.
void Update()
Update the backup.
#define DEBUG(name, level,...)
Output a line of debugging information.
void Trash()
Trash the backup.
~Backup()
Check whether the variable was restored on object destruction.
void Restore()
Restore the variable.