X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fapp%2FStateControl.hpp;fp=src%2Fapp%2FStateControl.hpp;h=818bce5c0369ab0987d3736a28ea516bc52564c4;hb=afd253b2dd10fdf2d4655d3d4a5766e6aa8c1a2c;hp=0000000000000000000000000000000000000000;hpb=aefc5482b27e3d259b6c9f3f1e4cdd9ef2e6a8d2;p=blank.git diff --git a/src/app/StateControl.hpp b/src/app/StateControl.hpp new file mode 100644 index 0000000..818bce5 --- /dev/null +++ b/src/app/StateControl.hpp @@ -0,0 +1,52 @@ +#ifndef BLANK_APP_STATECONTROL_HPP_ +#define BLANK_APP_STATECONTROL_HPP_ + +#include + + +namespace blank { + +class Application; +class State; + +class StateControl { + +public: + void Push(State *s) { + cue.emplace(PUSH, s); + } + + void Switch(State *s) { + cue.emplace(SWITCH, s); + } + + void Pop() { + cue.emplace(POP); + } + + void PopAll() { + cue.emplace(POP_ALL); + } + + + void Commit(Application &); + +private: + enum Command { + PUSH, + SWITCH, + POP, + POP_ALL, + }; + struct Memo { + State *state; + Command cmd; + explicit Memo(Command c, State *s = nullptr): state(s), cmd(c) { } + }; + std::queue cue; + +}; + +} + +#endif