1 /* 2 * Copyright (c) 2002-2007 Daniel Elstner <daniel.kitta@gmail.com> 3 * 4 * This file is part of regexxer. 5 * 6 * regexxer is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation; either version 2 of the License, or 9 * (at your option) any later version. 10 * 11 * regexxer is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License 17 * along with regexxer; if not, write to the Free Software Foundation, 18 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 19 */ 20 21 #ifndef REGEXXER_UNDOSTACK_H_INCLUDED 22 #define REGEXXER_UNDOSTACK_H_INCLUDED 23 24 #include "sharedptr.h" 25 26 #include <sigc++/sigc++.h> 27 #include <stack> 28 29 30 namespace Regexxer 31 { 32 33 class UndoAction : public Util::SharedObject 34 { 35 public: UndoAction()36 UndoAction() {} 37 virtual ~UndoAction() = 0; 38 39 bool undo(const sigc::slot<bool>& pulse); 40 41 private: 42 UndoAction(const UndoAction&); 43 UndoAction& operator=(const UndoAction&); 44 45 virtual bool do_undo(const sigc::slot<bool>& pulse) = 0; 46 }; 47 48 typedef Util::SharedPtr<UndoAction> UndoActionPtr; 49 50 51 class UndoStack : public UndoAction 52 { 53 public: 54 UndoStack(); 55 virtual ~UndoStack(); 56 57 void push(const UndoActionPtr& action); 58 bool empty() const; 59 60 void undo_step(const sigc::slot<bool>& pulse); 61 62 private: 63 std::stack<UndoActionPtr> actions_; 64 65 virtual bool do_undo(const sigc::slot<bool>& pulse); 66 }; 67 68 typedef Util::SharedPtr<UndoStack> UndoStackPtr; 69 70 71 } // namespace Regexxer 72 73 #endif /* REGEXXER_UNDOSTACK_H_INCLUDED */ 74