Debian Codegraph @

src/editor/undostack.hpp

raw symbols SCIP
1 // This file is part of Dust Racing 2D.
2 // Copyright (C) 2017 Jussi Lind <[email protected]>
3 //
4 // Dust Racing 2D is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
8 // Dust Racing 2D is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 // GNU General Public License for more details.
12 //
13 // You should have received a copy of the GNU General Public License
14 // along with Dust Racing 2D. If not, see <http://www.gnu.org/licenses/>.
15
16 #ifndef UNDOSTACK_HPP
17 #define UNDOSTACK_HPP
18
19 #include "trackdata.hpp"
20
21 #include <list>
22
23 class UndoStack
24 {
25 public:
26 UndoStack(unsigned int maxHistorySize = 100);
27
28 void pushUndoPoint(TrackDataPtr trackData);
29
30 void pushRedoPoint(TrackDataPtr trackData);
31
32 void clear();
33
34 bool isUndoable() const;
35
36 TrackDataPtr undo();
37
38 bool isRedoable() const;
39
40 TrackDataPtr redo();
41
42 private:
43 using TrackDataVector = std::list<TrackDataPtr>;
44
45 TrackDataVector m_undoStack;
46
47 TrackDataVector m_redoStack;
48
49 unsigned int m_maxHistorySize;
50 };
51
52 #endif // UNDOSTACK_HPP