-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
63 lines (50 loc) · 1.06 KB
/
main.cpp
File metadata and controls
63 lines (50 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#include <iostream>
#include "UndoRedoPool.h"
struct test{
int id;
std::string name;
};
class testV {
public:
void print() {
std::cout<<"hello world"<<std::endl;
}
};
void fun1(test& a, int x) {
a.id += x;
a.name = "world";
}
void fun2(test& a, int x) {
a.id -= x;
a.name = "hello";
}
void fun3(test& a) {
a.id -= 1;
a.name = "hello";
}
void printTest(test& a) {
std::cout<<a.id<<std::endl;
std::cout<<a.name<<std::endl;
}
int main() {
UndoRedoClass undoRedoClass;
test x = {
0, "hello"
};
std::shared_ptr<UndoRedoPool> undoRedoPool = UndoRedoPool::getInstance();
testV testa;
// printTest(x);
undoRedoClass.MakeUndo(fun1, std::ref(x), 5);
undoRedoClass.MakeUndo(fun3, std::ref(x));
undoRedoClass.MakeUndo(&testV::print, testa);
undoRedoClass.MakeRedo(fun2, std::ref(x), 5);
undoRedoPool->SaveUndoRedo(undoRedoClass);
// undoRedoPool->Undo();
std::cout<<undoRedoPool->Undo()<<std::endl;
printTest(x);
// undoRedoPool->Redo();
std::cout<<undoRedoPool->Redo()<<std::endl;
printTest(x);
std::cout<<undoRedoPool->Redo()<<std::endl;
return 0;
}