Maze Builder Docs 7.5.6
Loading...
Searching...
No Matches
maze_factory.h
1#ifndef MAZE_FACTORY_H
2#define MAZE_FACTORY_H
3
5
6#include <memory>
7#include <mutex>
8#include <optional>
9#include <string>
10#include <unordered_map>
11#include <vector>
12
13namespace mazes
14{
15
16 class configurator;
17 class maze_interface;
18
20 {
21
22 public:
27 bool register_creator(const std::string &key, factory_creator_t creator) noexcept override;
28
32 bool unregister_creator(const std::string &key) noexcept override;
33
37 bool is_registered(const std::string &key) const override;
38
43 std::optional<std::unique_ptr<maze_interface>> create(const std::string &key, const configurator &config) const noexcept override;
44
47 std::vector<std::string> get_registered_keys() const override;
48
50 void clear() noexcept override;
51
52 private:
54 mutable std::mutex m_creators_mutex;
55 std::unordered_map<std::string, factory_creator_t> m_creators;
56 };
57}
58
59#endif // MAZE_FACTORY_H
Configuration class for arguments.
Definition configurator.h:23
Modern factory interface using registration pattern.
Definition factory_interface.h:24
std::function< std::unique_ptr< InterfaceType >(const configurator &)> factory_creator_t
Type alias for product creation function.
Definition factory_interface.h:28
Definition maze_factory.h:20
std::vector< std::string > get_registered_keys() const override
Get all registered creator keys.
bool register_creator(const std::string &key, factory_creator_t creator) noexcept override
Register a grid creator function with a unique identifier.
void clear() noexcept override
Clear all registered creators.
bool is_registered(const std::string &key) const override
Check if a creator is registered for the given key.
std::optional< std::unique_ptr< maze_interface > > create(const std::string &key, const configurator &config) const noexcept override
Create a grid using a registered creator.
bool unregister_creator(const std::string &key) noexcept override
Unregister a grid creator function.
Namespace for the maze builder.
Definition algo_interface.h:6