Divide Framework 0.1
A free and open-source 3D Framework under heavy development
Loading...
Searching...
No Matches
UndoManager.cpp
Go to the documentation of this file.
1
2
4
5namespace Divide {
6
8 : _maxSize(maxSize)
9{
10}
11
13 if (!_undoStack.empty()) {
14 auto entry = _undoStack.back();
15 const bool ret = apply(entry);
16 _undoStack.pop_back();
17 if (ret) {
18 entry->swapValues();
19 _redoStack.push_back(entry);
20 }
21 return ret;
22 }
23
24 return false;
25}
26
28 if (!_redoStack.empty()) {
29 auto entry = _redoStack.back();
30 const bool ret = apply(entry);
31 _redoStack.pop_back();
32 if (ret) {
33 entry->swapValues();
34 _undoStack.push_back(entry);
35 }
36 return ret;
37 }
38 return false;
39}
40
41bool UndoManager::apply(const std::shared_ptr<IUndoEntry>& entry) {
42 if (entry != nullptr) {
43 entry->apply();
44 _lastActionName = entry->_name;
45 return true;
46 }
47 return false;
48}
49
50
51const string& UndoManager::lasActionName() const noexcept {
52 return _lastActionName;
53}
54
55} //namespace Divide
const string & lasActionName() const noexcept
Definition: UndoManager.cpp:51
bool apply(const std::shared_ptr< IUndoEntry > &entry)
Definition: UndoManager.cpp:41
UndoStack _undoStack
Definition: UndoManager.h:100
UndoManager(U32 maxSize)
Definition: UndoManager.cpp:7
UndoStack _redoStack
Definition: UndoManager.h:101
Handle console commands that start with a forward slash.
Definition: AIProcessor.cpp:7
uint32_t U32
Project const SceneEntry & entry
Definition: DefaultScene.h:41