Commit b045126c authored by Matthias Möller's avatar Matthias Möller

add option for max backups

closes #2264

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@20242 383ad7c9-94d9-4d36-a494-682f7c89f535
parent bba341b8
#include "BackupData.hh"
#define MAX_BACKUPS 20
//-----------------------------------------------------------------------------
BackupData::BackupData(BaseObjectData* _object) : currentState_(0), object_(_object)
BackupData::BackupData(BaseObjectData* _object) : currentState_(0), object_(_object), maxBackups_(20)
{
}
......@@ -16,6 +14,20 @@ BackupData::~BackupData(){
//-----------------------------------------------------------------------------
size_t BackupData::maxBackups()
{
return maxBackups_;
}
//-----------------------------------------------------------------------------
void BackupData::setMaxBackups(size_t _max)
{
maxBackups_ = _max;
}
//-----------------------------------------------------------------------------
void BackupData::storeBackup(BaseBackup* _backup){
//store state
......@@ -31,7 +43,7 @@ void BackupData::storeBackup(BaseBackup* _backup){
}
//delete undo backups if there are too many
while( undoStates_.size() > MAX_BACKUPS ){
while( undoStates_.size() > maxBackups_ ){
delete undoStates_.front();
undoStates_.erase( undoStates_.begin() );
}
......
......@@ -106,12 +106,20 @@ class DLLEXPORT BackupData : public PerObjectData
/// return the current state
BaseBackup* currentState();
/// return the maximum of backups which are saved
size_t maxBackups();
/// set the maximum of saved backups
void setMaxBackups(size_t _max);
protected:
std::vector< BaseBackup* > undoStates_;
std::vector< BaseBackup* > redoStates_;
BaseBackup* currentState_;
BaseObjectData* object_;
size_t maxBackups_;
};
#endif //BACKUPDATA_HH
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment