7#include <fsdk/Types/RefBase.h>
10#ifndef DOXYGEN_SHOULD_SKIP_THIS
31 Ref() noexcept = default;
35 Ref(std::nullptr_t) noexcept {
42 FSDK_DEPRECATED(
"construction from raw pointer is deprecated, use make_ref function instead")
44 explicit
Ref(T* ptr) noexcept {
61 template <class D, typename = typename std::enable_if<std::is_convertible<D*, T*>::value>::type>
67#ifndef DOXYGEN_SHOULD_SKIP_THIS
72 Ref(
const WeakRef<T>& other)
noexcept {
99 this->
get()->release();
111 return this->
get() == other.get();
119 return !(*
this == other);
122#ifndef DOXYGEN_SHOULD_SKIP_THIS
145 template <class D, typename = typename std::enable_if<std::is_convertible<D*, T*>::value>::type>
156 FSDK_DEPRECATED(
"Assignment from raw pointer is deprecated, use make_ref function instead")
158 Ref& operator=(T* ptr) noexcept {
177 if(this->
get() != ptr) {
179 this->
get()->release();
184 this->
get()->retain();
194 if(this->
get() != ptr) {
196 this->
get()->release();
215 T* ptr = this->
get();
223 template <
typename S>
235 template <
typename T>
247 template <
typename S,
typename T>
251 return ref.template as<S>();
258 template <
typename T>
270 template <
typename S,
typename T>
273 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:271
Ref< S > make_ref_as(T *ptr) noexcept
Make smart reference to a IRefCounted based object without acquiring ownership.
Definition Ref.h:248
Ref< T > acquire(T *ptr) noexcept
Acquire ownership of IRefCounted based object.
Definition Ref.h:259
Ref< T > make_ref(T *ptr) noexcept
Make smart reference to a IRefCounted based object without acquiring ownership.
Definition Ref.h:236
Generic base class of a pointer for reference counted objects.
Definition RefBase.h:16
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:26
Ref(const Ref< D > &other)
Initializes object pointer with other and retains a reference.
Definition Ref.h:62
Ref & operator=(std::nullptr_t) noexcept
Assign a nullptr_t.
Definition Ref.h:167
T * reset() noexcept
Reset reference counted object and assign nullptr to the pointer.
Definition Ref.h:214
Ref(const Ref &other)
Initializes object pointer with other and retains a reference.
Definition Ref.h:52
Ref() noexcept=default
Constructor. Initializes object pointer to nullptr.
bool operator==(const Ref &other) const noexcept
Check if two refs are the same.
Definition Ref.h:110
T * operator->() const noexcept
Access pointer.
Definition Ref.h:88
bool operator!=(const Ref &other) const noexcept
Check if two refs are not the same.
Definition Ref.h:118
~Ref() noexcept
Releases reference being held (if any).
Definition Ref.h:80
T ** getInitReference() noexcept
Access pointer for initialization.
Definition Ref.h:97
Ref & operator=(const Ref &other) noexcept
Assign a strong reference.
Definition Ref.h:136
Ref & acquire(T *ptr) noexcept
Acquire ownership of the object.
Definition Ref.h:193
Ref & assign(T *ptr) noexcept
Assign an object. Presumes shared ownership, increases reference count.
Definition Ref.h:176
Ref & operator=(const Ref< D > &other) noexcept
Assign a strong reference.
Definition Ref.h:146
Ref & make_ref(T *ptr) noexcept
Create ref without acquiring ownership.
Definition Ref.h:207
Ref< S > as() const noexcept
Make smart reference with relative type.
Definition Ref.h:224