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