00001 /* 00002 * Copyright 2007 Martin von Gagern 00003 * 00004 * 00005 * This file is part of bande. 00006 * 00007 * bande is free software; you can redistribute it and/or modify 00008 * it under the terms of the GNU General Public License as published by 00009 * the Free Software Foundation; either version 3 of the License, or 00010 * (at your option) any later version. 00011 * 00012 * bande is distributed in the hope that it will be useful, 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 * GNU General Public License for more details. 00016 * 00017 * You should have received a copy of the GNU General Public License 00018 * along with this program. If not, see <http://www.gnu.org/licenses/>. 00019 */ 00020 00021 00022 /** 00023 * @file 00024 * Implementation of class bande::UndoManager. 00025 */ 00026 00027 #include "bande.hh" 00028 00029 namespace bande { 00030 00031 00032 /** 00033 * Destructor. 00034 * 00035 * Cleans up all undo events stored in the stack, without undoing 00036 * them. 00037 */ 00038 UndoManager::~UndoManager() { 00039 while (!events.empty()) { 00040 delete events.back(); 00041 events.pop_back(); 00042 } 00043 } 00044 00045 /** 00046 * Undo events in reverse order up to a certain state. 00047 * 00048 * This is a protected method to be accessed by UndoState. 00049 * 00050 * @param pos the stack position to which to rewind. 00051 */ 00052 void UndoManager::restore(unsigned pos) { 00053 while (events.size() > pos) { 00054 events.back()->undo(); 00055 delete events.back(); 00056 events.pop_back(); 00057 } 00058 } 00059 00060 }
1.6.0