From b6719094e69bba468ecbc275fd892c4d412b92a3 Mon Sep 17 00:00:00 2001 From: Morph <39850852+Morph1984@users.noreply.github.com> Date: Thu, 14 Oct 2021 14:21:15 -0400 Subject: [PATCH] core: Remove static system instance --- src/core/core.cpp | 15 +-------------- src/core/core.h | 18 ++++-------------- 2 files changed, 5 insertions(+), 28 deletions(-) diff --git a/src/core/core.cpp b/src/core/core.cpp index bb268a3197..ae1d56b27c 100644 --- a/src/core/core.cpp +++ b/src/core/core.cpp @@ -428,22 +428,9 @@ struct System::Impl { }; System::System() : impl{std::make_unique(*this)} {} + System::~System() = default; -System& System::GetInstance() { - if (!s_instance) { - throw std::runtime_error("Using System instance before its initialization"); - } - return *s_instance; -} - -void System::InitializeGlobalInstance() { - if (s_instance) { - throw std::runtime_error("Reinitializing Global System instance."); - } - s_instance = std::unique_ptr(new System); -} - CpuManager& System::GetCpuManager() { return impl->cpu_manager; } diff --git a/src/core/core.h b/src/core/core.h index a796472b22..cae578c69c 100644 --- a/src/core/core.h +++ b/src/core/core.h @@ -108,22 +108,16 @@ class System { public: using CurrentBuildProcessID = std::array; + explicit System(); + + ~System(); + System(const System&) = delete; System& operator=(const System&) = delete; System(System&&) = delete; System& operator=(System&&) = delete; - ~System(); - - /** - * Gets the instance of the System singleton class. - * @returns Reference to the instance of the System singleton class. - */ - [[deprecated("Use of the global system instance is deprecated")]] static System& GetInstance(); - - static void InitializeGlobalInstance(); - /// Enumeration representing the return values of the System Initialize and Load process. enum class ResultStatus : u32 { Success, ///< Succeeded @@ -403,12 +397,8 @@ public: void ApplySettings(); private: - System(); - struct Impl; std::unique_ptr impl; - - inline static std::unique_ptr s_instance{}; }; } // namespace Core