Seregon/ShadPKG

A tool for deriving PKG packet encryption keys for ps4 written in c++

C++/47.3 KB/No license
common/singleton.h
ShadPKG / common / singleton.h
1// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
2// SPDX-License-Identifier: GPL-2.0-or-later
3 
4#pragma once
5 
6#include <memory>
7 
8namespace Common {
9 
10template <class T>
11class Singleton {
12public:
13 static T* Instance() {
14 if (!m_instance) {
15 m_instance = std::make_unique<T>();
16 }
17 return m_instance.get();
18 }
19 
20protected:
21 Singleton();
22 ~Singleton();
23 
24private:
25 static inline std::unique_ptr<T> m_instance{};
26};
27 
28} // namespace Common
29