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