Maze Builder Docs 7.5.6
Loading...
Searching...
No Matches
singleton_base.h
1#ifndef SINGLETON_BASE_H
2#define SINGLETON_BASE_H
3
4#include <memory>
5
6namespace mazes
7{
8
9 template <typename T>
11 {
12 public:
13 // Deleted copy constructor and assignment operator to prevent copying
14 singleton_base(const singleton_base &) = delete;
15 singleton_base &operator=(const singleton_base &) = delete;
16
17 // Deleted move constructor and assignment operator to prevent moving
18 singleton_base(singleton_base &&) = delete;
19 singleton_base &operator=(singleton_base &&) = delete;
20
21 // Static method to access the singleton instance
22 template <typename... Args>
23 static std::shared_ptr<T> &instance(Args &&...args) noexcept
24 {
25 static std::shared_ptr<T> instance = std::make_shared<T>(std::forward<Args>(args)...);
26 return instance;
27 }
28
29 protected:
30 // Private constructor to prevent instantiation from outside the class
31 singleton_base() = default;
32
33 // Private destructor to prevent deletion from outside the class
34 virtual ~singleton_base() = default;
35 };
36
37} // namespace mazes
38
39#endif // SINGLETON_BASE_H
Command-line argument handler with JSON support.
Definition args.h:20
Definition singleton_base.h:11
Namespace for the maze builder.
Definition algo_interface.h:6