OpenTTD Source
12.0-beta2
|
Go to the documentation of this file.
10 #ifndef BACKUP_TYPE_HPP
11 #define BACKUP_TYPE_HPP
28 Backup(T &original,
const char *
const file,
const int line) : original(original), valid(true), original_value(original), file(file), line(line) {}
38 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)
54 Debug(misc, 0,
"{}:{}: Backed-up value was not restored!", this->file, this->line);
75 return original_value;
97 this->original = this->original_value;
125 this->original_value = this->original;
135 return this->original_value == this->original;
143 const char *
const file;
void Change(const U &new_value)
Change the value of the variable.
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.
Backup(T &original, const U &new_value, const char *const file, const int line)
Backup variable and switch to new value.
~Backup()
Check whether the variable was restored on object destruction.
void Update()
Update the backup.
bool IsValid() const
Checks whether the variable was already restored.
void Trash()
Trash the backup.
void Restore()
Restore the variable.
const T & GetOriginalValue() const
Returns the backupped value.
#define Debug(name, level, format_string,...)
Ouptut a line of debugging information.
void Revert()
Revert the variable to its original value, but do not mark it as restored.