From 560ae08424956bb495bc2453973467d138029c7c Mon Sep 17 00:00:00 2001 From: Kae <80987908+Novaenia@users.noreply.github.com> Date: Mon, 25 Mar 2024 03:46:21 +1100 Subject: Add support for directly setting image assets and processing Image userdata --- source/base/StarRootBase.cpp | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 source/base/StarRootBase.cpp (limited to 'source/base/StarRootBase.cpp') 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::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 -- cgit v1.2.3