2 Copyright (C) 2001-2006, William Joseph.
5 This file is part of GtkRadiant.
7 GtkRadiant is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 GtkRadiant is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GtkRadiant; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 #if !defined( INCLUDED_IUNDO_H )
23 #define INCLUDED_IUNDO_H
26 /// \brief The undo-system interface. Uses the 'memento' pattern.
29 #include "generic/constant.h"
30 #include "generic/callbackfwd.h"
35 virtual void release() = 0;
41 virtual UndoMemento* exportState() const = 0;
42 virtual void importState( const UndoMemento* state ) = 0;
48 virtual void save( Undoable* undoable ) = 0;
54 virtual void clear() = 0;
55 virtual void begin() = 0;
56 virtual void undo() = 0;
57 virtual void redo() = 0;
63 INTEGER_CONSTANT( Version, 1 );
64 STRING_CONSTANT( Name, "undo" );
66 virtual UndoObserver* observer( Undoable* undoable ) = 0;
67 virtual void release( Undoable* undoable ) = 0;
69 virtual std::size_t size() const = 0;
70 virtual void start() = 0;
71 virtual void finish( const char* command ) = 0;
72 virtual void undo() = 0;
73 virtual void redo() = 0;
74 virtual void clear() = 0;
76 virtual void trackerAttach( UndoTracker& tracker ) = 0;
77 virtual void trackerDetach( UndoTracker& tracker ) = 0;
80 #include "modulesystem.h"
82 template<typename Type>
84 typedef GlobalModule<UndoSystem> GlobalUndoModule;
86 template<typename Type>
87 class GlobalModuleRef;
88 typedef GlobalModuleRef<UndoSystem> GlobalUndoModuleRef;
90 inline UndoSystem& GlobalUndoSystem(){
91 return GlobalUndoModule::getTable();
96 const char* m_command;
98 UndoableCommand( const char* command ) : m_command( command ){
99 GlobalUndoSystem().start();
102 GlobalUndoSystem().finish( m_command );