Maze Builder Docs 7.5.6
Loading...
Searching...
No Matches
grid_factory.h
Go to the documentation of this file.
1#ifndef GRID_FACTORY_H
2#define GRID_FACTORY_H
3
4#include <functional>
5#include <memory>
6#include <mutex>
7#include <string>
8#include <unordered_map>
9#include <vector>
10
12
13namespace mazes
14{
15
16 class configurator;
17 class grid_interface;
18
25 {
26
27 public:
32 bool register_creator(const std::string &key, factory_creator_t creator) noexcept override;
33
37 bool unregister_creator(const std::string &key) noexcept override;
38
42 bool is_registered(const std::string &key) const override;
43
48 std::optional<std::unique_ptr<grid_interface>> create(const std::string &key, const configurator &config) const noexcept override;
49
52 std::vector<std::string> get_registered_keys() const override;
53
55 void clear() noexcept override;
56
57 private:
59 mutable std::mutex m_creators_mutex;
60 std::unordered_map<std::string, factory_creator_t> m_creators;
61 };
62
63} // namespace mazes
64
65#endif // GRID_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
Modern grid grid_factory with registration capabilities.
Definition grid_factory.h:25
std::vector< std::string > get_registered_keys() const override
Get all registered creator keys.
std::optional< std::unique_ptr< grid_interface > > create(const std::string &key, const configurator &config) const noexcept override
Create a grid using a registered creator.
bool is_registered(const std::string &key) const override
Check if a creator is registered for the given key.
void clear() noexcept override
Clear all registered creators.
bool register_creator(const std::string &key, factory_creator_t creator) noexcept override
Register a grid creator function with a unique identifier.
bool unregister_creator(const std::string &key) noexcept override
Unregister a grid creator function.
Namespace for the maze builder.
Definition algo_interface.h:6