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
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:
@@ -21,27 +21,6 @@ template<class DERIVED, class ASSET>
|
|||||||
class ReferenceBase
|
class ReferenceBase
|
||||||
{
|
{
|
||||||
public:
|
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]]
|
[[nodiscard]]
|
||||||
const UUID& GetUUID() const
|
const UUID& GetUUID() const
|
||||||
{
|
{
|
||||||
@@ -65,33 +44,55 @@ class ReferenceBase
|
|||||||
Release();
|
Release();
|
||||||
}
|
}
|
||||||
|
|
||||||
ReferenceBase& operator=(const ReferenceBase& p_ref)
|
ReferenceBase& operator=(const ReferenceBase& p_reference)
|
||||||
{
|
{
|
||||||
if (this != &p_ref)
|
if (this != &p_reference)
|
||||||
{
|
{
|
||||||
Release();
|
Release();
|
||||||
m_uuid = p_ref.m_uuid;
|
m_uuid = p_reference.m_uuid;
|
||||||
m_handle = p_ref.m_handle;
|
m_handle = p_reference.m_handle;
|
||||||
Acquire();
|
Acquire();
|
||||||
}
|
}
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
ReferenceBase& operator=(ReferenceBase&& p_ref) noexcept
|
ReferenceBase& operator=(ReferenceBase&& p_reference) noexcept
|
||||||
{
|
{
|
||||||
if (this != &p_ref)
|
if (this != &p_reference)
|
||||||
{
|
{
|
||||||
Release();
|
Release();
|
||||||
m_uuid = std::exchange(p_ref.m_uuid, UUID::NULL_UUID);
|
m_uuid = std::exchange(p_reference.m_uuid, UUID::NULL_UUID);
|
||||||
m_handle = std::exchange(p_ref.m_handle, nullptr);
|
m_handle = std::exchange(p_reference.m_handle, nullptr);
|
||||||
}
|
}
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]]
|
[[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:
|
private:
|
||||||
@@ -128,6 +129,16 @@ class ReferenceBase
|
|||||||
template<class ASSET>
|
template<class ASSET>
|
||||||
class HardReference: public ReferenceBase<HardReference<ASSET>, 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:
|
private:
|
||||||
static void IncrementCount(ContainerHandle& p_handle)
|
static void IncrementCount(ContainerHandle& p_handle)
|
||||||
{
|
{
|
||||||
@@ -139,12 +150,22 @@ class HardReference: public ReferenceBase<HardReference<ASSET>, ASSET>
|
|||||||
p_handle.DecrementHardRefCount();
|
p_handle.DecrementHardRefCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
friend ReferenceBase<HardReference<ASSET>, ASSET>;
|
friend Base;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<class ASSET>
|
template<class ASSET>
|
||||||
class SoftReference: public ReferenceBase<SoftReference<ASSET>, 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:
|
private:
|
||||||
static void IncrementCount(ContainerHandle& p_handle)
|
static void IncrementCount(ContainerHandle& p_handle)
|
||||||
{
|
{
|
||||||
@@ -156,7 +177,7 @@ class SoftReference: public ReferenceBase<SoftReference<ASSET>, ASSET>
|
|||||||
p_handle.DecrementSoftRefCount();
|
p_handle.DecrementSoftRefCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
friend ReferenceBase<SoftReference<ASSET>, ASSET>;
|
friend Base;
|
||||||
};
|
};
|
||||||
} // namespace Bigfoot
|
} // namespace Bigfoot
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user