Maze Builder Docs 8.2.1
Loading...
Searching...
No Matches
state.h
Go to the documentation of this file.
1#ifndef STATE_H
2#define STATE_H
3
5
6#include <functional>
7#include <optional>
8
11namespace mazes
12{
13 class args;
14 class runtime_stack;
15
17 struct state
18 {
19 enum class ID : unsigned int
20 {
21 BTING = 0,
22 DFSING = 1,
23 EMPTY = 2,
24 LOADING = 3,
25 PARSING = 4,
26 PIXELIZING = 5,
27 SIDEWINDERING = 6,
28 STRINGIFYING = 7,
29 WAVEFRONT_OBJECTIFYING = 8,
30 TOTAL = 9
31 };
32
33 explicit state(const runtime_app::context& c, runtime_stack* rs)
34 : ctx(c), _runtime_stack(rs)
35 {
36 }
37
38 virtual ~state() = default;
39
40 virtual void draw() const noexcept = 0;
41
46 virtual bool update(const std::optional<args>& args, double delta_time) noexcept = 0;
47
48 protected:
49 void request_stack_push(ID state_id) const noexcept;
50
51 void request_stack_pop() const noexcept;
52
53 void request_stack_clear() const noexcept;
54
55 [[nodiscard]] const runtime_app::context& get_context() const noexcept;
56
57 [[nodiscard]] runtime_stack& get_stack() const noexcept;
58
59 private:
60 std::reference_wrapper<const runtime_app::context> ctx;
61 runtime_stack* _runtime_stack;
62 };
63} // namespace mazes
64
65#endif // STATE_H
Command-line argument handler with JSON support.
Definition args.h:19
The main application class for the maze builder, responsible for managing the runtime stack and resou...
Definition runtime_app.h:28
Class representing the runtime stack of states in the maze builder application.
Definition runtime_stack.h:23
struct representing the context passed to states in the runtime_app stack
Definition runtime_app.h:34
struct representing a state in the runtime stack
Definition state.h:18
virtual bool update(const std::optional< args > &args, double delta_time) noexcept=0
Update the state with the given arguments and elapsed time.