history.h

changeset 85
b1541b547c8c
child 89
5e6c08e98dbf
equal deleted inserted replaced
84:c9438ea54ed9 85:b1541b547c8c
1 /*
2 * LDForge: LDraw parts authoring CAD
3 * Copyright (C) 2013 Santeri `arezey` Piippo
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19 #ifndef HISTORY_H
20 #define HISTORY_H
21
22 #include "common.h"
23
24 #define IMPLEMENT_HISTORY_TYPE(N) \
25 virtual HistoryType_e getType () const { \
26 return HISTORY_##N; \
27 } \
28
29 enum HistoryType_e {
30 HISTORY_Delete,
31 };
32
33 class HistoryEntry {
34 public:
35 virtual void undo () {}
36 virtual void redo () {}
37 virtual ~HistoryEntry () {}
38
39 virtual HistoryType_e getType () const {
40 return (HistoryType_e)(0);
41 };
42 };
43
44 class DeleteHistory : public HistoryEntry {
45 public:
46 IMPLEMENT_HISTORY_TYPE (Delete)
47
48 vector<ulong> indices;
49 vector<LDObject*> cache;
50
51 DeleteHistory (vector<ulong> indices, vector<LDObject*> cache) :
52 indices (indices), cache (cache) {}
53 virtual ~DeleteHistory ();
54 virtual void undo ();
55 virtual void redo ();
56 };
57
58 namespace History {
59 extern std::vector<HistoryEntry*> entries;
60
61 void addEntry (HistoryEntry* entry);
62 void undo ();
63 void redo ();
64 };
65
66 #endif // HISTORY_H

mercurial