28 #ifndef BERSERK_REF_HPP
29 #define BERSERK_REF_HPP
52 mObject = AddRef(
object);
57 mObject = AddRef(other.mObject);
61 mObject = other.mObject;
62 other.mObject =
nullptr;
72 this->
Reset(SafeAddRef(other.
Get()));
78 this->
Reset(other.Release());
83 return mObject == other.mObject;
87 return mObject != other.mObject;
91 return mObject ==
nullptr;
108 explicit operator bool()
const {
109 return mObject !=
nullptr;
120 return mObject ? mObject->IsUnique() :
false;
134 [[nodiscard]]
bool Is()
const {
135 return !mObject ||
dynamic_cast<G *
>(mObject);
145 return Ref<G>(
dynamic_cast<G *
>(mObject));
154 T *mObject =
nullptr;
#define BRK_NS_END
Definition: Config.hpp:48
Automates reference counting and behaves as shared smart pointer.
Definition: Ref.hpp:46
T * Get() const
Definition: Ref.hpp:129
bool Is() const
Definition: Ref.hpp:134
T * operator->() const
Definition: Ref.hpp:98
bool IsNotNull() const
Definition: Ref.hpp:94
bool IsUnique() const
Definition: Ref.hpp:119
Ref< T > & operator=(const Ref &other)
Definition: Ref.hpp:70
bool operator==(const Ref &other) const
Definition: Ref.hpp:82
bool IsNull() const
Definition: Ref.hpp:90
Ref< G > Cast() const
Definition: Ref.hpp:144
~Ref()
Definition: Ref.hpp:65
T * Release()
Definition: Ref.hpp:123
Ref< G > ForceCast() const
Definition: Ref.hpp:149
Ref< G > As() const
Definition: Ref.hpp:139
Ref(T *object)
Definition: Ref.hpp:50
Ref< T > & operator=(Ref &&other) noexcept
Definition: Ref.hpp:76
void Reset(T *ptr=nullptr)
Definition: Ref.hpp:112
Ref(const Ref &other)
Definition: Ref.hpp:55
Ref(Ref &&other) noexcept
Definition: Ref.hpp:60
bool operator!=(const Ref &other) const
Definition: Ref.hpp:86
T & operator*() const
Definition: Ref.hpp:103
Definition: GLDevice.cpp:46