Do not allow creating ReferenceBase
Bigfoot / Build & Test Debug with ./ConanProfiles/clang (Unity Build: OFF) (push) Canceled after 0s
Bigfoot / Build & Test Debug with ./ConanProfiles/clang (Unity Build: ON) (push) Canceled after 0s
Bigfoot / Build & Test Debug with ./ConanProfiles/clang_asan (Unity Build: OFF) (push) Canceled after 0s
Bigfoot / Build & Test Debug with ./ConanProfiles/clang_asan (Unity Build: ON) (push) Canceled after 0s
Bigfoot / Build & Test Release with ./ConanProfiles/clang (Unity Build: OFF) (push) Canceled after 0s
Bigfoot / Build & Test Release with ./ConanProfiles/clang (Unity Build: ON) (push) Canceled after 0s
Bigfoot / Build & Test Release with ./ConanProfiles/clang_asan (Unity Build: OFF) (push) Canceled after 0s
Bigfoot / Build & Test Release with ./ConanProfiles/clang_asan (Unity Build: ON) (push) Canceled after 0s
Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/clang (Unity Build: OFF) (push) Canceled after 0s
Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/clang (Unity Build: ON) (push) Canceled after 0s
Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/clang_asan (Unity Build: OFF) (push) Canceled after 0s
Bigfoot / Build & Test RelWithDebInfo with ./ConanProfiles/clang_asan (Unity Build: ON) (push) Canceled after 0s
Bigfoot / Clang Format Checks (push) Canceled after 0s
Bigfoot / Sonarqube (push) Skipped

This commit is contained in:
2026-08-18 18:12:05 +02:00
parent 1d572b9d09
commit d9f4a0e896
@@ -21,27 +21,6 @@ template<class DERIVED, class ASSET>
class ReferenceBase
{
public:
ReferenceBase() = default;
ReferenceBase(const UUID& p_uuid):
m_uuid(p_uuid)
{
Acquire();
}
ReferenceBase(const ReferenceBase& p_ref):
m_uuid(p_ref.m_uuid),
m_handle(p_ref.m_handle)
{
Acquire();
}
ReferenceBase(ReferenceBase&& p_ref) noexcept:
m_uuid(std::exchange(p_ref.m_uuid, UUID::NULL_UUID)),
m_handle(std::exchange(p_ref.m_handle, nullptr))
{
}
[[nodiscard]]
const UUID& GetUUID() const
{
@@ -65,33 +44,55 @@ class ReferenceBase
Release();
}
ReferenceBase& operator=(const ReferenceBase& p_ref)
ReferenceBase& operator=(const ReferenceBase& p_reference)
{
if (this != &p_ref)
if (this != &p_reference)
{
Release();
m_uuid = p_ref.m_uuid;
m_handle = p_ref.m_handle;
m_uuid = p_reference.m_uuid;
m_handle = p_reference.m_handle;
Acquire();
}
return *this;
}
ReferenceBase& operator=(ReferenceBase&& p_ref) noexcept
ReferenceBase& operator=(ReferenceBase&& p_reference) noexcept
{
if (this != &p_ref)
if (this != &p_reference)
{
Release();
m_uuid = std::exchange(p_ref.m_uuid, UUID::NULL_UUID);
m_handle = std::exchange(p_ref.m_handle, nullptr);
m_uuid = std::exchange(p_reference.m_uuid, UUID::NULL_UUID);
m_handle = std::exchange(p_reference.m_handle, nullptr);
}
return *this;
}
[[nodiscard]]
bool operator==(const ReferenceBase& p_ref) const
bool operator==(const ReferenceBase& p_reference) const
{
return m_uuid == p_reference.m_uuid;
}
protected:
ReferenceBase() = default;
ReferenceBase(const UUID& p_uuid):
m_uuid(p_uuid)
{
Acquire();
}
ReferenceBase(const ReferenceBase& p_reference):
m_uuid(p_reference.m_uuid),
m_handle(p_reference.m_handle)
{
Acquire();
}
ReferenceBase(ReferenceBase&& p_reference) noexcept:
m_uuid(std::exchange(p_reference.m_uuid, UUID::NULL_UUID)),
m_handle(std::exchange(p_reference.m_handle, nullptr))
{
return m_uuid == p_ref.m_uuid;
}
private:
@@ -128,6 +129,16 @@ class ReferenceBase
template<class ASSET>
class HardReference: public ReferenceBase<HardReference<ASSET>, ASSET>
{
using Base = ReferenceBase<HardReference<ASSET>, ASSET>;
public:
HardReference() = default;
HardReference(const UUID& p_uuid):
Base(p_uuid)
{
}
private:
static void IncrementCount(ContainerHandle& p_handle)
{
@@ -139,12 +150,22 @@ class HardReference: public ReferenceBase<HardReference<ASSET>, ASSET>
p_handle.DecrementHardRefCount();
}
friend ReferenceBase<HardReference<ASSET>, ASSET>;
friend Base;
};
template<class ASSET>
class SoftReference: public ReferenceBase<SoftReference<ASSET>, ASSET>
{
using Base = ReferenceBase<SoftReference<ASSET>, ASSET>;
public:
SoftReference() = default;
SoftReference(const UUID& p_uuid):
Base(p_uuid)
{
}
private:
static void IncrementCount(ContainerHandle& p_handle)
{
@@ -156,7 +177,7 @@ class SoftReference: public ReferenceBase<SoftReference<ASSET>, ASSET>
p_handle.DecrementSoftRefCount();
}
friend ReferenceBase<SoftReference<ASSET>, ASSET>;
friend Base;
};
} // namespace Bigfoot
#endif