diff options
| author | 2021-10-15 17:57:58 -0400 | |
|---|---|---|
| committer | 2021-10-15 17:57:58 -0400 | |
| commit | dc385b7392df2b2c301b6df908483beadbb5eb3b (patch) | |
| tree | f03cf5293b06159cfc9325ee4527a4ea15685c25 /src/core/core.h | |
| parent | Merge pull request #7183 from FearlessTobi/translation-ci (diff) | |
| parent | bootmanager: Forward declare System and SystemResultStatus (diff) | |
| download | yuzu-dc385b7392df2b2c301b6df908483beadbb5eb3b.tar.gz yuzu-dc385b7392df2b2c301b6df908483beadbb5eb3b.tar.xz yuzu-dc385b7392df2b2c301b6df908483beadbb5eb3b.zip | |
Merge pull request #7182 from Morph1984/system
yuzu: Remove all remaining global system instances
Diffstat (limited to 'src/core/core.h')
| -rw-r--r-- | src/core/core.h | 57 |
1 files changed, 24 insertions, 33 deletions
diff --git a/src/core/core.h b/src/core/core.h index a796472b2..c1234ef77 100644 --- a/src/core/core.h +++ b/src/core/core.h | |||
| @@ -104,55 +104,49 @@ struct PerfStatsResults; | |||
| 104 | FileSys::VirtualFile GetGameFileFromPath(const FileSys::VirtualFilesystem& vfs, | 104 | FileSys::VirtualFile GetGameFileFromPath(const FileSys::VirtualFilesystem& vfs, |
| 105 | const std::string& path); | 105 | const std::string& path); |
| 106 | 106 | ||
| 107 | /// Enumeration representing the return values of the System Initialize and Load process. | ||
| 108 | enum class SystemResultStatus : u32 { | ||
| 109 | Success, ///< Succeeded | ||
| 110 | ErrorNotInitialized, ///< Error trying to use core prior to initialization | ||
| 111 | ErrorGetLoader, ///< Error finding the correct application loader | ||
| 112 | ErrorSystemFiles, ///< Error in finding system files | ||
| 113 | ErrorSharedFont, ///< Error in finding shared font | ||
| 114 | ErrorVideoCore, ///< Error in the video core | ||
| 115 | ErrorUnknown, ///< Any other error | ||
| 116 | ErrorLoader, ///< The base for loader errors (too many to repeat) | ||
| 117 | }; | ||
| 118 | |||
| 107 | class System { | 119 | class System { |
| 108 | public: | 120 | public: |
| 109 | using CurrentBuildProcessID = std::array<u8, 0x20>; | 121 | using CurrentBuildProcessID = std::array<u8, 0x20>; |
| 110 | 122 | ||
| 123 | explicit System(); | ||
| 124 | |||
| 125 | ~System(); | ||
| 126 | |||
| 111 | System(const System&) = delete; | 127 | System(const System&) = delete; |
| 112 | System& operator=(const System&) = delete; | 128 | System& operator=(const System&) = delete; |
| 113 | 129 | ||
| 114 | System(System&&) = delete; | 130 | System(System&&) = delete; |
| 115 | System& operator=(System&&) = delete; | 131 | System& operator=(System&&) = delete; |
| 116 | 132 | ||
| 117 | ~System(); | ||
| 118 | |||
| 119 | /** | ||
| 120 | * Gets the instance of the System singleton class. | ||
| 121 | * @returns Reference to the instance of the System singleton class. | ||
| 122 | */ | ||
| 123 | [[deprecated("Use of the global system instance is deprecated")]] static System& GetInstance(); | ||
| 124 | |||
| 125 | static void InitializeGlobalInstance(); | ||
| 126 | |||
| 127 | /// Enumeration representing the return values of the System Initialize and Load process. | ||
| 128 | enum class ResultStatus : u32 { | ||
| 129 | Success, ///< Succeeded | ||
| 130 | ErrorNotInitialized, ///< Error trying to use core prior to initialization | ||
| 131 | ErrorGetLoader, ///< Error finding the correct application loader | ||
| 132 | ErrorSystemFiles, ///< Error in finding system files | ||
| 133 | ErrorSharedFont, ///< Error in finding shared font | ||
| 134 | ErrorVideoCore, ///< Error in the video core | ||
| 135 | ErrorUnknown, ///< Any other error | ||
| 136 | ErrorLoader, ///< The base for loader errors (too many to repeat) | ||
| 137 | }; | ||
| 138 | |||
| 139 | /** | 133 | /** |
| 140 | * Run the OS and Application | 134 | * Run the OS and Application |
| 141 | * This function will start emulation and run the relevant devices | 135 | * This function will start emulation and run the relevant devices |
| 142 | */ | 136 | */ |
| 143 | [[nodiscard]] ResultStatus Run(); | 137 | [[nodiscard]] SystemResultStatus Run(); |
| 144 | 138 | ||
| 145 | /** | 139 | /** |
| 146 | * Pause the OS and Application | 140 | * Pause the OS and Application |
| 147 | * This function will pause emulation and stop the relevant devices | 141 | * This function will pause emulation and stop the relevant devices |
| 148 | */ | 142 | */ |
| 149 | [[nodiscard]] ResultStatus Pause(); | 143 | [[nodiscard]] SystemResultStatus Pause(); |
| 150 | 144 | ||
| 151 | /** | 145 | /** |
| 152 | * Step the CPU one instruction | 146 | * Step the CPU one instruction |
| 153 | * @return Result status, indicating whether or not the operation succeeded. | 147 | * @return Result status, indicating whether or not the operation succeeded. |
| 154 | */ | 148 | */ |
| 155 | [[nodiscard]] ResultStatus SingleStep(); | 149 | [[nodiscard]] SystemResultStatus SingleStep(); |
| 156 | 150 | ||
| 157 | /** | 151 | /** |
| 158 | * Invalidate the CPU instruction caches | 152 | * Invalidate the CPU instruction caches |
| @@ -172,10 +166,11 @@ public: | |||
| 172 | * input. | 166 | * input. |
| 173 | * @param filepath String path to the executable application to load on the host file system. | 167 | * @param filepath String path to the executable application to load on the host file system. |
| 174 | * @param program_index Specifies the index within the container of the program to launch. | 168 | * @param program_index Specifies the index within the container of the program to launch. |
| 175 | * @returns ResultStatus code, indicating if the operation succeeded. | 169 | * @returns SystemResultStatus code, indicating if the operation succeeded. |
| 176 | */ | 170 | */ |
| 177 | [[nodiscard]] ResultStatus Load(Frontend::EmuWindow& emu_window, const std::string& filepath, | 171 | [[nodiscard]] SystemResultStatus Load(Frontend::EmuWindow& emu_window, |
| 178 | u64 program_id = 0, std::size_t program_index = 0); | 172 | const std::string& filepath, u64 program_id = 0, |
| 173 | std::size_t program_index = 0); | ||
| 179 | 174 | ||
| 180 | /** | 175 | /** |
| 181 | * Indicates if the emulated system is powered on (all subsystems initialized and able to run an | 176 | * Indicates if the emulated system is powered on (all subsystems initialized and able to run an |
| @@ -301,7 +296,7 @@ public: | |||
| 301 | /// Gets the name of the current game | 296 | /// Gets the name of the current game |
| 302 | [[nodiscard]] Loader::ResultStatus GetGameName(std::string& out) const; | 297 | [[nodiscard]] Loader::ResultStatus GetGameName(std::string& out) const; |
| 303 | 298 | ||
| 304 | void SetStatus(ResultStatus new_status, const char* details); | 299 | void SetStatus(SystemResultStatus new_status, const char* details); |
| 305 | 300 | ||
| 306 | [[nodiscard]] const std::string& GetStatusDetails() const; | 301 | [[nodiscard]] const std::string& GetStatusDetails() const; |
| 307 | 302 | ||
| @@ -403,12 +398,8 @@ public: | |||
| 403 | void ApplySettings(); | 398 | void ApplySettings(); |
| 404 | 399 | ||
| 405 | private: | 400 | private: |
| 406 | System(); | ||
| 407 | |||
| 408 | struct Impl; | 401 | struct Impl; |
| 409 | std::unique_ptr<Impl> impl; | 402 | std::unique_ptr<Impl> impl; |
| 410 | |||
| 411 | inline static std::unique_ptr<System> s_instance{}; | ||
| 412 | }; | 403 | }; |
| 413 | 404 | ||
| 414 | } // namespace Core | 405 | } // namespace Core |