Веб-сайт самохостера Lotigara

summaryrefslogtreecommitdiff
path: root/source/base/StarRootBase.cpp
diff options
context:
space:
mode:
authorKae <80987908+Novaenia@users.noreply.github.com>2024-03-25 03:46:21 +1100
committerKae <80987908+Novaenia@users.noreply.github.com>2024-03-25 03:46:21 +1100
commit560ae08424956bb495bc2453973467d138029c7c (patch)
treef506d79185388e7217af75a43074884f17349cb2 /source/base/StarRootBase.cpp
parentff6e349aef9c5504896d1249b2d4a3b862c37d09 (diff)
Add support for directly setting image assets and processing Image userdata
Diffstat (limited to 'source/base/StarRootBase.cpp')
-rw-r--r--source/base/StarRootBase.cpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/source/base/StarRootBase.cpp b/source/base/StarRootBase.cpp
new file mode 100644
index 0000000..e6bd99d
--- /dev/null
+++ b/source/base/StarRootBase.cpp
@@ -0,0 +1,23 @@
+#include "StarRootBase.hpp"
+
+namespace Star {
+ atomic<RootBase*> RootBase::s_singleton;
+
+ RootBase* RootBase::singletonPtr() {
+ return s_singleton.load();
+ }
+
+ RootBase& RootBase::singleton() {
+ auto ptr = s_singleton.load();
+ if (!ptr)
+ throw RootException("RootBase::singleton() called with no Root instance available");
+ else
+ return *ptr;
+ }
+
+ RootBase::RootBase() {
+ RootBase* oldRoot = nullptr;
+ if (!s_singleton.compare_exchange_strong(oldRoot, this))
+ throw RootException("Singleton Root has been constructed twice");
+ }
+} \ No newline at end of file