diff options
Diffstat (limited to 'src/core/core.cpp')
| -rw-r--r-- | src/core/core.cpp | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/core/core.cpp b/src/core/core.cpp index b0dc594d4..5893a86bf 100644 --- a/src/core/core.cpp +++ b/src/core/core.cpp | |||
| @@ -4,6 +4,7 @@ | |||
| 4 | 4 | ||
| 5 | #include <array> | 5 | #include <array> |
| 6 | #include <atomic> | 6 | #include <atomic> |
| 7 | #include <exception> | ||
| 7 | #include <memory> | 8 | #include <memory> |
| 8 | #include <utility> | 9 | #include <utility> |
| 9 | 10 | ||
| @@ -423,9 +424,16 @@ struct System::Impl { | |||
| 423 | System::System() : impl{std::make_unique<Impl>(*this)} {} | 424 | System::System() : impl{std::make_unique<Impl>(*this)} {} |
| 424 | System::~System() = default; | 425 | System::~System() = default; |
| 425 | 426 | ||
| 427 | System& System::GetInstance() { | ||
| 428 | if (!s_instance) { | ||
| 429 | throw std::runtime_error("Using System instance before its initialization"); | ||
| 430 | } | ||
| 431 | return *s_instance; | ||
| 432 | } | ||
| 433 | |||
| 426 | void System::InitializeGlobalInstance() { | 434 | void System::InitializeGlobalInstance() { |
| 427 | if (s_instance) { | 435 | if (s_instance) { |
| 428 | abort(); | 436 | throw std::runtime_error("Reinitializing Global System instance."); |
| 429 | } | 437 | } |
| 430 | s_instance = std::unique_ptr<System>(new System); | 438 | s_instance = std::unique_ptr<System>(new System); |
| 431 | } | 439 | } |