11 #ifndef DOXYGEN_SHOULD_SKIP_THIS
14 template<
typename T>
struct WeakRef;
31 Ref() noexcept =
default;
35 Ref(std::nullptr_t) noexcept {}
41 FSDK_DEPRECATED(
"construction from raw pointer is deprecated, use make_ref function instead")
42 explicit
Ref(T* ptr) noexcept { *
this = ptr; }
54 template<class D, typename = typename std::enable_if<std::is_convertible<D*, T*>::value>::type>
57 #ifndef DOXYGEN_SHOULD_SKIP_THIS
62 Ref(
const WeakRef<T>& other) noexcept { *
this = other; }
87 this->
get()->release();
99 return this->
get() == other.get();
107 return !(*
this == other);
110 #ifndef DOXYGEN_SHOULD_SKIP_THIS
133 template<class D, typename = typename std::enable_if<std::is_convertible<D*, T*>::value>::type>
144 FSDK_DEPRECATED(
"Assignment from raw pointer is deprecated, use make_ref function instead")
145 Ref& operator = (T* ptr) noexcept {
164 if(this->
get() != ptr)
167 this->
get()->release();
172 this->
get()->retain();
182 if(this->
get() != ptr)
185 this->
get()->release();
204 T* ptr = this->
get();
214 ref.
make_ref(static_cast<S*>(this->
get()));
237 template<
typename S,
typename T>
241 return ref.template as<S>();
262 template<
typename S,
typename T>
265 ref.
acquire(static_cast<S*>(ptr));
bool operator==(const Ref &other) const noexcept
Check if two refs are the same.
Definition: Ref.h:98
Ref & operator=(const Ref &other) noexcept
Assign a strong reference.
Definition: Ref.h:124
Ref & acquire(T *ptr) noexcept
Acquire ownership of the object.
Definition: Ref.h:181
Ref< T > make_ref(T *ptr) noexcept
Make smart reference to a IRefCounted based object without acquiring ownership.
Definition: Ref.h:225
Ref< S > as() const noexcept
Make smart reference with relative type.
Definition: Ref.h:212
Smart pointer for reference counted objects.
Definition: Ref.h:26
~Ref() noexcept
Releases reference being held (if any).
Definition: Ref.h:68
T * reset() noexcept
Reset reference counted object and assign nullptr to the pointer.
Definition: Ref.h:203
bool operator!=(const Ref &other) const noexcept
Check if two refs are not the same.
Definition: Ref.h:106
Ref() noexcept=default
Constructor. Initializes object pointer to nullptr.
Generic base class of a pointer for reference counted objects.
Definition: RefBase.h:17
T * m_ptr
Raw pointer.
Definition: RefBase.h:106
void set(T *ptr) noexcept
Replace object pointer without any checks or reference management.
Definition: RefBase.h:101
Ref(std::nullptr_t) noexcept
Initializes object pointer to nullptr.
Definition: Ref.h:35
bool isNull() const noexcept
Check for nullptr.
Definition: RefBase.h:70
Ref & make_ref(T *ptr) noexcept
Create ref without acquiring ownership.
Definition: Ref.h:196
Ref(const Ref< D > &other)
Initializes object pointer with other and retains a reference.
Definition: Ref.h:55
Ref(const Ref &other)
Initializes object pointer with other and retains a reference.
Definition: Ref.h:48
Ref< S > acquire_as(T *ptr) noexcept
Acquire ownership of IRefCounted based object with a cast to a given type.
Definition: Ref.h:263
Ref & assign(T *ptr) noexcept
Assign an object. Presumes shared ownership, increases reference count.
Definition: Ref.h:163
T ** getInitReference() noexcept
Access pointer for initialization.
Definition: Ref.h:85
T * operator->() const noexcept
Access pointer.
Definition: Ref.h:76
Ref< S > make_ref_as(T *ptr) noexcept
Make smart reference to a IRefCounted based object without acquiring ownership.
Definition: Ref.h:238
Ref< T > acquire(T *ptr) noexcept
Acquire ownership of IRefCounted based object.
Definition: Ref.h:250