8#include <fsdk/Types/RefBase.h>
11#ifndef DOXYGEN_SHOULD_SKIP_THIS
32 Ref() noexcept = default;
36 Ref(std::nullptr_t) noexcept {
43 FSDK_DEPRECATED(
"construction from raw pointer is deprecated, use make_ref function instead")
45 explicit
Ref(T* ptr) noexcept {
62 template <class D, typename = typename std::enable_if<std::is_convertible<D*, T*>::value>::type>
78 move(std::move(other));
89 template <class D, typename = typename std::enable_if<std::is_convertible<D*, T*>::value>::type>
92 move(std::move(other));
95#ifndef DOXYGEN_SHOULD_SKIP_THIS
100 Ref(
const WeakRef<T>& other)
noexcept {
127 this->
get()->release();
139 return this->
get() == other.get();
147 return !(*
this == other);
150#ifndef DOXYGEN_SHOULD_SKIP_THIS
173 template <class D, typename = typename std::enable_if<std::is_convertible<D*, T*>::value>::type>
189 return move(std::move(other));
201 template <class D, typename = typename std::enable_if<std::is_convertible<D*, T*>::value>::type>
203 return move(std::move(other));
211 FSDK_DEPRECATED(
"Assignment from raw pointer is deprecated, use make_ref function instead")
213 Ref& operator=(T* ptr) noexcept {
232 if(this->
get() != ptr) {
234 this->
get()->release();
239 this->
get()->retain();
249 if(this->
get() != ptr) {
251 this->
get()->release();
268 template <class D, typename = typename std::enable_if<std::is_convertible<D*, T*>::value>::type>
270 auto* ptr = other.
get();
271 if(this->
get() != ptr) {
273 this->
get()->release();
296 T* ptr = this->
get();
304 template <
typename S>
316 template <
typename T>
328 template <
typename S,
typename T>
332 return ref.template as<S>();
339 template <
typename T>
351 template <
typename S,
typename T>
354 ref.
acquire(
static_cast<S*
>(ptr));
SDK namespace.
Definition IAGSEstimator.h:8
Ref< S > acquire_as(T *ptr) noexcept
Acquire ownership of IRefCounted based object with a cast to a given type.
Definition Ref.h:352
Ref< S > make_ref_as(T *ptr) noexcept
Make smart reference to a IRefCounted based object without acquiring ownership.
Definition Ref.h:329
Ref< T > acquire(T *ptr) noexcept
Acquire ownership of IRefCounted based object.
Definition Ref.h:340
Ref< T > make_ref(T *ptr) noexcept
Make smart reference to a IRefCounted based object without acquiring ownership.
Definition Ref.h:317
Generic base class of a pointer for reference counted objects.
Definition RefBase.h:16
RefBase() noexcept=default
Initializes object pointer to nullptr.
bool isNull() const noexcept
Check for nullptr.
Definition RefBase.h:71
void set(T *ptr) noexcept
Replace object pointer without any checks or reference management.
Definition RefBase.h:102
T * m_ptr
Raw pointer.
Definition RefBase.h:107
T * get() const noexcept
Get current raw object pointer.
Definition RefBase.h:94
Smart pointer for reference counted objects.
Definition Ref.h:27
Ref(const Ref< D > &other)
Initializes object pointer with other and retains a reference.
Definition Ref.h:63
Ref & operator=(std::nullptr_t) noexcept
Assign a nullptr_t.
Definition Ref.h:222
T * reset() noexcept
Reset reference counted object and assign nullptr to the pointer.
Definition Ref.h:295
Ref(const Ref &other)
Initializes object pointer with other and retains a reference.
Definition Ref.h:53
Ref() noexcept=default
Constructor. Initializes object pointer to nullptr.
Ref & operator=(Ref &&other) noexcept
Moves other's resource to this Ref instance. Leaves other Ref empty. Reference count of the resource ...
Definition Ref.h:188
bool operator==(const Ref &other) const noexcept
Check if two refs are the same.
Definition Ref.h:138
T * operator->() const noexcept
Access pointer.
Definition Ref.h:116
Ref & move(Ref< D > &&other) noexcept
Moves other's resource to this Ref instance. Leaves other Ref empty. Reference count of the resource ...
Definition Ref.h:269
Ref(Ref &&other) noexcept
Constructs Ref by moving other's resource to the new Ref instance. Leaves other Ref empty....
Definition Ref.h:76
bool operator!=(const Ref &other) const noexcept
Check if two refs are not the same.
Definition Ref.h:146
Ref(Ref< D > &&other) noexcept
Constructs Ref by moving other's resource to the new Ref instance. Leaves other Ref empty....
Definition Ref.h:90
~Ref() noexcept
Releases reference being held (if any).
Definition Ref.h:108
T ** getInitReference() noexcept
Access pointer for initialization.
Definition Ref.h:125
Ref & operator=(const Ref &other) noexcept
Assign a strong reference.
Definition Ref.h:164
Ref & operator=(Ref< D > &&other) noexcept
Moves other's resource to this Ref instance. Leaves other Ref empty. Reference count of the resource ...
Definition Ref.h:202
Ref & acquire(T *ptr) noexcept
Acquire ownership of the object.
Definition Ref.h:248
Ref & assign(T *ptr) noexcept
Assign an object. Presumes shared ownership, increases reference count.
Definition Ref.h:231
Ref & operator=(const Ref< D > &other) noexcept
Assign a strong reference.
Definition Ref.h:174
Ref & make_ref(T *ptr) noexcept
Create ref without acquiring ownership.
Definition Ref.h:288
Ref< S > as() const noexcept
Make smart reference with relative type.
Definition Ref.h:305