2023-10-13 08:40:59 +02:00
|
|
|
#pragma once
|
|
|
|
|
2023-10-26 22:13:07 +02:00
|
|
|
#include <memory>
|
2023-10-13 08:40:59 +02:00
|
|
|
|
|
|
|
template <class T>
|
|
|
|
class singleton {
|
2023-10-26 22:13:07 +02:00
|
|
|
public:
|
2023-10-13 08:40:59 +02:00
|
|
|
static T* instance() {
|
|
|
|
if (!m_instance) {
|
2023-10-26 22:13:07 +02:00
|
|
|
m_instance = std::make_unique<T>();
|
2023-10-13 08:40:59 +02:00
|
|
|
}
|
|
|
|
return m_instance;
|
|
|
|
}
|
|
|
|
|
2023-10-26 22:13:07 +02:00
|
|
|
protected:
|
2023-10-13 08:40:59 +02:00
|
|
|
singleton();
|
|
|
|
~singleton();
|
|
|
|
|
2023-10-26 22:13:07 +02:00
|
|
|
private:
|
|
|
|
static inline std::unique_ptr<T> m_instance{};
|
|
|
|
};
|