Maze Builder Docs 8.10.23
Loading...
Searching...
No Matches
state_utils.h
Go to the documentation of this file.
1#ifndef STATE_UTILS_H
2#define STATE_UTILS_H
3
4#include <MazeBuilder/async_logger.h>
7#include <MazeBuilder/state.h>
8
9#include <string>
10#include <unordered_map>
11
14namespace mazes
15{
16 class args;
17 class grid_operations;
18 class randomizer;
19 class runtime_app;
20 class context;
21
23 {
24 public:
30 static void parse_dimensions(const std::unordered_map<std::string, std::string> &args, unsigned int &rows, unsigned int &cols,
31 unsigned int &levels) noexcept;
32
37 static bool has_distances(const std::unordered_map<std::string, std::string> &args) noexcept;
38
44 static configurator build_configurator(const args &a, const algo default_algo = algo::DFS) noexcept;
45
49 static state::ID output_state_for(const std::unordered_map<std::string, std::string> &args) noexcept;
50
51 static bool advance_args(const runtime_app::context &ctx) noexcept;
52
53 // Reseeds rng from the parsed "seed" arg so repeated apply() calls with the same
54 // seed reproduce identical topology; the rng is otherwise shared and keeps advancing.
55 static void reseed_from_args(const std::unordered_map<std::string, std::string> &args, randomizer &rng) noexcept;
56
57 template <typename... Mappers>
58 static void validate_mappers(Mappers &&...mapper) noexcept;
59
69 static void check_before_resize(grid_operations *ops, unsigned int rows, unsigned int cols, unsigned int levels) noexcept;
70
71 }; // class state_utils
72} // namespace mazes
73
74template <typename... Mappers>
75void mazes::state_utils::validate_mappers(Mappers &&...mapper) noexcept
76{
77 if (!((mapper != nullptr) && ...))
78 {
79 async_logger::instance()->log("mappers are null");
80 }
81}
82
83#endif // STATE_UTILS_H
algo
Enumeration of maze generation algorithms.
Definition algos.h:20
Command-line argument handler with JSON support.
Definition args.h:19
Configuration class for arguments.
Definition configurator.h:21
Interface for grid navigation and manipulation operations.
Definition grid_operations.h:22
Provides random-number generating capabilities.
Definition randomizer.h:16
The main application class for the maze builder, responsible for managing the runtime stack and resou...
Definition runtime_app.h:28
Definition state_utils.h:23
static bool has_distances(const std::unordered_map< std::string, std::string > &args) noexcept
Checks if the "distances" argument is present in the given arguments.
static configurator build_configurator(const args &a, const algo default_algo=algo::DFS) noexcept
Builds a configurator from the front entry of the given arguments.
static void parse_dimensions(const std::unordered_map< std::string, std::string > &args, unsigned int &rows, unsigned int &cols, unsigned int &levels) noexcept
Parses the maze dimensions from the given arguments.
static state::ID output_state_for(const std::unordered_map< std::string, std::string > &args) noexcept
Determines the output state based on the given arguments.
static void check_before_resize(grid_operations *ops, unsigned int rows, unsigned int cols, unsigned int levels) noexcept
Resets the grid's topology (links) before each generation.
struct representing the context passed to states in the runtime_app stack
Definition runtime_app.h:34