]> git.localhorst.tv Git - blank.git/blob - src/app/StateControl.hpp
split composite model in template and instance
[blank.git] / src / app / StateControl.hpp
1 #ifndef BLANK_APP_STATECONTROL_HPP_
2 #define BLANK_APP_STATECONTROL_HPP_
3
4 #include <queue>
5
6
7 namespace blank {
8
9 class Application;
10 class State;
11
12 class StateControl {
13
14 public:
15         void Push(State *s) {
16                 cue.emplace(PUSH, s);
17         }
18
19         void Switch(State *s) {
20                 cue.emplace(SWITCH, s);
21         }
22
23         void Pop() {
24                 cue.emplace(POP);
25         }
26
27         void PopAll() {
28                 cue.emplace(POP_ALL);
29         }
30
31
32         void Commit(Application &);
33
34 private:
35         enum Command {
36                 PUSH,
37                 SWITCH,
38                 POP,
39                 POP_ALL,
40         };
41         struct Memo {
42                 State *state;
43                 Command cmd;
44                 explicit Memo(Command c, State *s = nullptr): state(s), cmd(c) { }
45         };
46         std::queue<Memo> cue;
47
48 };
49
50 }
51
52 #endif