AssetContainer
This commit is contained in:
@@ -6,11 +6,7 @@
|
||||
*********************************************************************/
|
||||
#ifndef BIGFOOT_UTILS_SINGLETON_HPP
|
||||
#define BIGFOOT_UTILS_SINGLETON_HPP
|
||||
#include <EASTL/array.h>
|
||||
#include <EASTL/bit.h>
|
||||
#include <EASTL/optional.h>
|
||||
#include <EASTL/type_traits.h>
|
||||
#include <EASTL/utility.h>
|
||||
|
||||
namespace Bigfoot
|
||||
{
|
||||
@@ -51,9 +47,6 @@ class Singleton
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* Initializes the singleton; this lifetime owns the instance and
|
||||
* finalizes it on destruction.
|
||||
*
|
||||
* \param p_args Arguments for the singleton
|
||||
*/
|
||||
template<typename... ARGS>
|
||||
@@ -62,53 +55,16 @@ class Singleton
|
||||
Initialize(std::forward<ARGS>(p_args)...);
|
||||
}
|
||||
|
||||
struct EmptyLifetime
|
||||
{
|
||||
};
|
||||
|
||||
static inline constexpr EmptyLifetime EMPTY_LIFETIME;
|
||||
|
||||
/**
|
||||
* Non-owning constructor.
|
||||
*
|
||||
* Does not initialize the singleton and owns nothing. Such a lifetime
|
||||
* only becomes an owner if it later receives ownership through move
|
||||
* assignment.
|
||||
*/
|
||||
explicit Lifetime(EmptyLifetime) noexcept:
|
||||
m_owner(false)
|
||||
{
|
||||
}
|
||||
|
||||
Lifetime(const Lifetime& p_lifetime) = delete;
|
||||
|
||||
explicit Lifetime(Lifetime&& p_lifetime) noexcept:
|
||||
m_owner(eastl::exchange(p_lifetime.m_owner, false))
|
||||
{
|
||||
}
|
||||
Lifetime(Lifetime&& p_lifetime) = delete;
|
||||
|
||||
~Lifetime()
|
||||
{
|
||||
if (m_owner)
|
||||
{
|
||||
Finalize();
|
||||
}
|
||||
Finalize();
|
||||
}
|
||||
|
||||
Lifetime& operator=(const Lifetime& p_lifetime) = delete;
|
||||
|
||||
Lifetime& operator=(Lifetime&& p_lifetime) noexcept
|
||||
{
|
||||
m_owner = eastl::exchange(p_lifetime.m_owner, false);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
private:
|
||||
/**
|
||||
* Whether this lifetime owns the singleton instance or not.
|
||||
*/
|
||||
bool m_owner = true;
|
||||
Lifetime& operator=(Lifetime&& p_lifetime) noexcept = delete;
|
||||
};
|
||||
|
||||
Singleton& operator=(const Singleton& p_singleton) = delete;
|
||||
|
||||
Reference in New Issue
Block a user