Ark Server API (ASA) - Wiki
Loading...
Searching...
No Matches
TSharedPtr< ObjectType, InMode > Class Template Reference

#include <SharedPointer.h>

Public Types

using ElementType = ObjectType
 

Public Member Functions

FORCEINLINE TSharedPtr (SharedPointerInternals::FNullTag *=nullptr)
 
template<typename OtherType , typename = decltype(ImplicitConv<ObjectType*>((OtherType*)nullptr))>
FORCEINLINE TSharedPtr (OtherType *InObject)
 
template<typename OtherType , typename DeleterType , typename = decltype(ImplicitConv<ObjectType*>((OtherType*)nullptr))>
FORCEINLINE TSharedPtr (OtherType *InObject, DeleterType &&InDeleter)
 
template<typename OtherType , typename = decltype(ImplicitConv<ObjectType*>((OtherType*)nullptr))>
FORCEINLINE TSharedPtr (SharedPointerInternals::TRawPtrProxy< OtherType > const &InRawPtrProxy)
 
template<typename OtherType , typename DeleterType , typename = decltype(ImplicitConv<ObjectType*>((OtherType*)nullptr))>
FORCEINLINE TSharedPtr (SharedPointerInternals::TRawPtrProxyWithDeleter< OtherType, DeleterType > const &InRawPtrProxy)
 
template<typename OtherType , typename DeleterType , typename = decltype(ImplicitConv<ObjectType*>((OtherType*)nullptr))>
FORCEINLINE TSharedPtr (SharedPointerInternals::TRawPtrProxyWithDeleter< OtherType, DeleterType > &&InRawPtrProxy)
 
template<typename OtherType , typename = decltype(ImplicitConv<ObjectType*>((OtherType*)nullptr))>
FORCEINLINE TSharedPtr (TSharedPtr< OtherType, Mode > const &InSharedPtr)
 
FORCEINLINE TSharedPtr (TSharedPtr const &InSharedPtr)
 
FORCEINLINE TSharedPtr (TSharedPtr &&InSharedPtr)
 
template<typename OtherType , typename = decltype(ImplicitConv<ObjectType*>((OtherType*)nullptr))>
FORCEINLINE TSharedPtr (TSharedRef< OtherType, Mode > const &InSharedRef)
 
template<typename OtherType >
FORCEINLINE TSharedPtr (TSharedPtr< OtherType, Mode > const &InSharedPtr, SharedPointerInternals::FStaticCastTag)
 
template<typename OtherType >
FORCEINLINE TSharedPtr (TSharedPtr< OtherType, Mode > const &InSharedPtr, SharedPointerInternals::FConstCastTag)
 
template<typename OtherType >
FORCEINLINE TSharedPtr (TSharedPtr< OtherType, Mode > const &OtherSharedPtr, ObjectType *InObject)
 
template<typename OtherType >
FORCEINLINE TSharedPtr (TSharedPtr< OtherType, Mode > &&OtherSharedPtr, ObjectType *InObject)
 
template<typename OtherType >
FORCEINLINE TSharedPtr (TSharedRef< OtherType, Mode > const &OtherSharedRef, ObjectType *InObject)
 
FORCEINLINE TSharedPtroperator= (SharedPointerInternals::FNullTag *)
 
FORCEINLINE TSharedPtroperator= (TSharedPtr const &InSharedPtr)
 
FORCEINLINE TSharedPtroperator= (TSharedPtr &&InSharedPtr)
 
template<typename OtherType , typename = decltype(ImplicitConv<ObjectType*>((OtherType*)nullptr))>
FORCEINLINE TSharedPtroperator= (SharedPointerInternals::TRawPtrProxy< OtherType > const &InRawPtrProxy)
 
template<typename OtherType , typename DeleterType , typename = decltype(ImplicitConv<ObjectType*>((OtherType*)nullptr))>
FORCEINLINE TSharedPtroperator= (SharedPointerInternals::TRawPtrProxyWithDeleter< OtherType, DeleterType > const &InRawPtrProxy)
 
template<typename OtherType , typename DeleterType , typename = decltype(ImplicitConv<ObjectType*>((OtherType*)nullptr))>
FORCEINLINE TSharedPtroperator= (SharedPointerInternals::TRawPtrProxyWithDeleter< OtherType, DeleterType > &&InRawPtrProxy)
 
FORCEINLINE TSharedRef< ObjectType, ModeToSharedRef () const &
 
FORCEINLINE TSharedRef< ObjectType, ModeToSharedRef () &&
 
FORCEINLINE TWeakPtr< ObjectType, ModeToWeakPtr () const
 
FORCEINLINE ObjectTypeGet () const
 
FORCEINLINE operator bool () const
 
FORCEINLINE const bool IsValid () const
 
FORCEINLINE FMakeReferenceTo< ObjectType >::Type operator* () const
 
FORCEINLINE ObjectTypeoperator-> () const
 
FORCEINLINE void Reset ()
 
FORCEINLINE int32 GetSharedReferenceCount () const
 
FORCEINLINE bool IsUnique () const
 

Static Public Attributes

static constexpr ESPMode Mode = InMode
 

Private Member Functions

template<typename OtherType , typename = decltype(ImplicitConv<ObjectType*>((OtherType*)nullptr))>
FORCEINLINE TSharedPtr (TWeakPtr< OtherType, Mode > const &InWeakPtr)
 
template<typename OtherType , typename = typename TEnableIf<TPointerIsConvertibleFromTo<OtherType, ObjectType>::Value>::Type>
FORCEINLINE TSharedPtr (TWeakPtr< OtherType, Mode > &&InWeakPtr)
 

Private Attributes

ObjectTypeObject
 
SharedPointerInternals::FSharedReferencer< ModeSharedReferenceCount
 

Friends

template<class OtherType , ESPMode OtherMode>
class TSharedPtr
 
template<class OtherType , ESPMode OtherMode>
class TSharedRef
 
template<class OtherType , ESPMode OtherMode>
class TWeakPtr
 
template<class OtherType , ESPMode OtherMode>
class TSharedFromThis
 

Detailed Description

template<class ObjectType, ESPMode InMode>
class TSharedPtr< ObjectType, InMode >

TSharedPtr is a non-intrusive reference-counted authoritative object pointer. This shared pointer will be conditionally thread-safe when the optional Mode template argument is set to ThreadSafe.

Definition at line 685 of file SharedPointer.h.

Member Typedef Documentation

◆ ElementType

template<class ObjectType , ESPMode InMode>
using TSharedPtr< ObjectType, InMode >::ElementType = ObjectType

Definition at line 688 of file SharedPointer.h.

Constructor & Destructor Documentation

◆ TSharedPtr() [1/17]

Constructs an empty shared pointer

Definition at line 695 of file SharedPointer.h.

◆ TSharedPtr() [2/17]

template<class ObjectType , ESPMode InMode>
template<typename OtherType , typename = decltype(ImplicitConv<ObjectType*>((OtherType*)nullptr))>
FORCEINLINE TSharedPtr< ObjectType, InMode >::TSharedPtr ( OtherType * InObject)
inlineexplicit

Constructs a shared pointer that owns the specified object. Note that passing nullptr here will still create a tracked reference to a nullptr pointer. (Consistent with std::shared_ptr)

Parameters
InObjectObject this shared pointer to retain a reference to

Definition at line 711 of file SharedPointer.h.

◆ TSharedPtr() [3/17]

template<class ObjectType , ESPMode InMode>
template<typename OtherType , typename DeleterType , typename = decltype(ImplicitConv<ObjectType*>((OtherType*)nullptr))>
FORCEINLINE TSharedPtr< ObjectType, InMode >::TSharedPtr ( OtherType * InObject,
DeleterType && InDeleter )
inline

Constructs a shared pointer that owns the specified object. Note that passing nullptr here will still create a tracked reference to a nullptr pointer. (Consistent with std::shared_ptr)

Parameters
InObjectObject this shared pointer to retain a reference to
InDeleterDeleter object used to destroy the object when it is no longer referenced.

Definition at line 734 of file SharedPointer.h.

◆ TSharedPtr() [4/17]

template<class ObjectType , ESPMode InMode>
template<typename OtherType , typename = decltype(ImplicitConv<ObjectType*>((OtherType*)nullptr))>
FORCEINLINE TSharedPtr< ObjectType, InMode >::TSharedPtr ( SharedPointerInternals::TRawPtrProxy< OtherType > const & InRawPtrProxy)
inline

Constructs a shared pointer using a proxy reference to a raw pointer. (See MakeShareable())

Parameters
InRawPtrProxyProxy raw pointer that contains the object that the new shared pointer will reference

Definition at line 755 of file SharedPointer.h.

◆ TSharedPtr() [5/17]

template<class ObjectType , ESPMode InMode>
template<typename OtherType , typename DeleterType , typename = decltype(ImplicitConv<ObjectType*>((OtherType*)nullptr))>
FORCEINLINE TSharedPtr< ObjectType, InMode >::TSharedPtr ( SharedPointerInternals::TRawPtrProxyWithDeleter< OtherType, DeleterType > const & InRawPtrProxy)
inline

Constructs a shared pointer using a proxy reference to a raw pointer. (See MakeShareable())

Parameters
InRawPtrProxyProxy raw pointer that contains the object that the new shared pointer will reference

Definition at line 777 of file SharedPointer.h.

◆ TSharedPtr() [6/17]

template<class ObjectType , ESPMode InMode>
template<typename OtherType , typename DeleterType , typename = decltype(ImplicitConv<ObjectType*>((OtherType*)nullptr))>
FORCEINLINE TSharedPtr< ObjectType, InMode >::TSharedPtr ( SharedPointerInternals::TRawPtrProxyWithDeleter< OtherType, DeleterType > && InRawPtrProxy)
inline

Constructs a shared pointer using a proxy reference to a raw pointer. (See MakeShareable())

Parameters
InRawPtrProxyProxy raw pointer that contains the object that the new shared pointer will reference

Definition at line 799 of file SharedPointer.h.

◆ TSharedPtr() [7/17]

template<class ObjectType , ESPMode InMode>
template<typename OtherType , typename = decltype(ImplicitConv<ObjectType*>((OtherType*)nullptr))>
FORCEINLINE TSharedPtr< ObjectType, InMode >::TSharedPtr ( TSharedPtr< OtherType, Mode > const & InSharedPtr)
inline

Constructs a shared pointer as a shared reference to an existing shared pointer's object. This constructor is needed so that we can implicitly upcast to base classes.

Parameters
InSharedPtrThe shared pointer whose object we should create an additional reference to

Definition at line 820 of file SharedPointer.h.

◆ TSharedPtr() [8/17]

Definition at line 826 of file SharedPointer.h.

◆ TSharedPtr() [9/17]

Definition at line 832 of file SharedPointer.h.

◆ TSharedPtr() [10/17]

template<class ObjectType , ESPMode InMode>
template<typename OtherType , typename = decltype(ImplicitConv<ObjectType*>((OtherType*)nullptr))>
FORCEINLINE TSharedPtr< ObjectType, InMode >::TSharedPtr ( TSharedRef< OtherType, Mode > const & InSharedRef)
inline

Implicitly converts a shared reference to a shared pointer, adding a reference to the object. NOTE: We allow an implicit conversion from TSharedRef to TSharedPtr because it's always a safe conversion.

Parameters
InSharedRefThe shared reference that will be converted to a shared pointer

Definition at line 850 of file SharedPointer.h.

◆ TSharedPtr() [11/17]

Special constructor used internally to statically cast one shared pointer type to another. You should never call this constructor directly. Instead, use the StaticCastSharedPtr() function. This constructor creates a shared pointer as a shared reference to an existing shared pointer after statically casting that pointer's object. This constructor is needed for static casts.

Parameters
InSharedPtrThe shared pointer whose object we should create an additional reference to

Definition at line 867 of file SharedPointer.h.

◆ TSharedPtr() [12/17]

Special constructor used internally to cast a 'const' shared pointer a 'mutable' pointer. You should never call this constructor directly. Instead, use the ConstCastSharedPtr() function. This constructor creates a shared pointer as a shared reference to an existing shared pointer after const casting that pointer's object. This constructor is needed for const casts.

Parameters
InSharedPtrThe shared pointer whose object we should create an additional reference to

Definition at line 882 of file SharedPointer.h.

◆ TSharedPtr() [13/17]

template<class ObjectType , ESPMode InMode>
template<typename OtherType >
FORCEINLINE TSharedPtr< ObjectType, InMode >::TSharedPtr ( TSharedPtr< OtherType, Mode > const & OtherSharedPtr,
ObjectType * InObject )
inline

Aliasing constructor used to create a shared pointer which shares its reference count with another shared object, but pointing to a different object, typically a subobject.

Parameters
OtherSharedPtrThe shared pointer whose reference count should be shared.
InObjectThe object pointer to use (instead of the incoming shared pointer's object)

Definition at line 896 of file SharedPointer.h.

◆ TSharedPtr() [14/17]

template<class ObjectType , ESPMode InMode>
template<typename OtherType >
FORCEINLINE TSharedPtr< ObjectType, InMode >::TSharedPtr ( TSharedPtr< OtherType, Mode > && OtherSharedPtr,
ObjectType * InObject )
inline

Aliasing constructor used to create a shared pointer which shares its reference count with another shared object, but pointing to a different object, typically a subobject.

Parameters
OtherSharedPtrThe shared pointer whose reference count should be shared.
InObjectThe object pointer to use (instead of the incoming shared pointer's object)

Definition at line 910 of file SharedPointer.h.

◆ TSharedPtr() [15/17]

template<class ObjectType , ESPMode InMode>
template<typename OtherType >
FORCEINLINE TSharedPtr< ObjectType, InMode >::TSharedPtr ( TSharedRef< OtherType, Mode > const & OtherSharedRef,
ObjectType * InObject )
inline

Aliasing constructor used to create a shared pointer which shares its reference count with another shared object, but pointing to a different object, typically a subobject.

Parameters
OtherSharedRefThe shared reference whose reference count should be shared.
InObjectThe object pointer to use (instead of the incoming shared pointer's object)

Definition at line 925 of file SharedPointer.h.

◆ TSharedPtr() [16/17]

template<class ObjectType , ESPMode InMode>
template<typename OtherType , typename = decltype(ImplicitConv<ObjectType*>((OtherType*)nullptr))>
FORCEINLINE TSharedPtr< ObjectType, InMode >::TSharedPtr ( TWeakPtr< OtherType, Mode > const & InWeakPtr)
inlineexplicitprivate

Constructs a shared pointer from a weak pointer, allowing you to access the object (if it hasn't expired yet.) Remember, if there are no more shared references to the object, the shared pointer will not be valid. You should always check to make sure this shared pointer is valid before trying to dereference the shared pointer!

NOTE: This constructor is private to force users to be explicit when converting a weak pointer to a shared pointer. Use the weak pointer's Pin() method instead!

Definition at line 1160 of file SharedPointer.h.

◆ TSharedPtr() [17/17]

template<class ObjectType , ESPMode InMode>
template<typename OtherType , typename = typename TEnableIf<TPointerIsConvertibleFromTo<OtherType, ObjectType>::Value>::Type>
FORCEINLINE TSharedPtr< ObjectType, InMode >::TSharedPtr ( TWeakPtr< OtherType, Mode > && InWeakPtr)
inlineexplicitprivate

Constructs a shared pointer from a weak pointer, allowing you to access the object (if it hasn't expired yet.) Remember, if there are no more shared references to the object, the shared pointer will not be valid. You should always check to make sure this shared pointer is valid before trying to dereference the shared pointer!

NOTE: This constructor is private to force users to be explicit when converting a weak pointer to a shared pointer. Use the weak pointer's Pin() method instead!

Definition at line 1185 of file SharedPointer.h.

Member Function Documentation

◆ Get()

template<class ObjectType , ESPMode InMode>
FORCEINLINE ObjectType * TSharedPtr< ObjectType, InMode >::Get ( ) const
inline

Returns the object referenced by this pointer, or nullptr if no object is reference

Returns
The object owned by this shared pointer, or nullptr

Definition at line 1066 of file SharedPointer.h.

◆ GetSharedReferenceCount()

template<class ObjectType , ESPMode InMode>
FORCEINLINE int32 TSharedPtr< ObjectType, InMode >::GetSharedReferenceCount ( ) const
inline

Returns the number of shared references to this object (including this reference.) IMPORTANT: Not necessarily fast! Should only be used for debugging purposes!

Returns
Number of shared references to the object (including this reference.)

Definition at line 1128 of file SharedPointer.h.

◆ IsUnique()

template<class ObjectType , ESPMode InMode>
FORCEINLINE bool TSharedPtr< ObjectType, InMode >::IsUnique ( ) const
inline

Returns true if this is the only shared reference to this object. Note that there may be outstanding weak references left. IMPORTANT: Not necessarily fast! Should only be used for debugging purposes!

Returns
True if there is only one shared reference to the object, and this is it!

Definition at line 1140 of file SharedPointer.h.

◆ IsValid()

template<class ObjectType , ESPMode InMode>
FORCEINLINE const bool TSharedPtr< ObjectType, InMode >::IsValid ( ) const
inline

Checks to see if this shared pointer is actually pointing to an object

Returns
True if the shared pointer is valid and can be dereferenced

Definition at line 1086 of file SharedPointer.h.

◆ operator bool()

template<class ObjectType , ESPMode InMode>
FORCEINLINE TSharedPtr< ObjectType, InMode >::operator bool ( ) const
inlineexplicit

Checks to see if this shared pointer is actually pointing to an object

Returns
True if the shared pointer is valid and can be dereferenced

Definition at line 1076 of file SharedPointer.h.

◆ operator*()

Dereference operator returns a reference to the object this shared pointer points to

Returns
Reference to the object

Definition at line 1096 of file SharedPointer.h.

◆ operator->()

template<class ObjectType , ESPMode InMode>
FORCEINLINE ObjectType * TSharedPtr< ObjectType, InMode >::operator-> ( ) const
inline

Arrow operator returns a pointer to the object this shared pointer references

Returns
Returns a pointer to the object referenced by this shared pointer

Definition at line 1107 of file SharedPointer.h.

◆ operator=() [1/6]

Assignment to a nullptr pointer. The object currently referenced by this shared pointer will no longer be referenced and will be deleted if there are no other referencers.

Definition at line 936 of file SharedPointer.h.

◆ operator=() [2/6]

template<class ObjectType , ESPMode InMode>
template<typename OtherType , typename = decltype(ImplicitConv<ObjectType*>((OtherType*)nullptr))>
FORCEINLINE TSharedPtr & TSharedPtr< ObjectType, InMode >::operator= ( SharedPointerInternals::TRawPtrProxy< OtherType > const & InRawPtrProxy)
inline

Assignment operator replaces this shared pointer with the specified shared pointer. The object currently referenced by this shared pointer will no longer be referenced and will be deleted if there are no other referencers.

Parameters
InRawPtrProxyProxy object used to assign the object (see MakeShareable helper function)

Definition at line 979 of file SharedPointer.h.

◆ operator=() [3/6]

template<class ObjectType , ESPMode InMode>
template<typename OtherType , typename DeleterType , typename = decltype(ImplicitConv<ObjectType*>((OtherType*)nullptr))>
FORCEINLINE TSharedPtr & TSharedPtr< ObjectType, InMode >::operator= ( SharedPointerInternals::TRawPtrProxyWithDeleter< OtherType, DeleterType > && InRawPtrProxy)
inline

Assignment operator replaces this shared pointer with the specified shared pointer. The object currently referenced by this shared pointer will no longer be referenced and will be deleted if there are no other referencers.

Parameters
InRawPtrProxyProxy object used to assign the object (see MakeShareable helper function)

Definition at line 1017 of file SharedPointer.h.

◆ operator=() [4/6]

template<class ObjectType , ESPMode InMode>
template<typename OtherType , typename DeleterType , typename = decltype(ImplicitConv<ObjectType*>((OtherType*)nullptr))>
FORCEINLINE TSharedPtr & TSharedPtr< ObjectType, InMode >::operator= ( SharedPointerInternals::TRawPtrProxyWithDeleter< OtherType, DeleterType > const & InRawPtrProxy)
inline

Assignment operator replaces this shared pointer with the specified shared pointer. The object currently referenced by this shared pointer will no longer be referenced and will be deleted if there are no other referencers.

Parameters
InRawPtrProxyProxy object used to assign the object (see MakeShareable helper function)

Definition at line 998 of file SharedPointer.h.

◆ operator=() [5/6]

Definition at line 956 of file SharedPointer.h.

◆ operator=() [6/6]

Assignment operator replaces this shared pointer with the specified shared pointer. The object currently referenced by this shared pointer will no longer be referenced and will be deleted if there are no other referencers.

Parameters
InSharedPtrShared pointer to replace with

Definition at line 949 of file SharedPointer.h.

◆ Reset()

template<class ObjectType , ESPMode InMode>
FORCEINLINE void TSharedPtr< ObjectType, InMode >::Reset ( )
inline

Resets this shared pointer, removing a reference to the object. If there are no other shared references to the object then it will be destroyed.

Definition at line 1117 of file SharedPointer.h.

◆ ToSharedRef() [1/2]

template<class ObjectType , ESPMode InMode>
FORCEINLINE TSharedRef< ObjectType, Mode > TSharedPtr< ObjectType, InMode >::ToSharedRef ( ) &&
inline

Converts a shared pointer to a shared reference. The pointer must be valid or an assertion will trigger.

Returns
Reference to the object

Definition at line 1043 of file SharedPointer.h.

◆ ToSharedRef() [2/2]

template<class ObjectType , ESPMode InMode>
FORCEINLINE TSharedRef< ObjectType, Mode > TSharedPtr< ObjectType, InMode >::ToSharedRef ( ) const &
inline

Converts a shared pointer to a shared reference. The pointer must be valid or an assertion will trigger.

Returns
Reference to the object

Definition at line 1029 of file SharedPointer.h.

◆ ToWeakPtr()

template<class ObjectType , ESPMode InMode>
FORCEINLINE TWeakPtr< ObjectType, Mode > TSharedPtr< ObjectType, InMode >::ToWeakPtr ( ) const
inline

Converts a shared pointer to a weak ptr.

Returns
Weak pointer to the object

Definition at line 1056 of file SharedPointer.h.

Friends And Related Symbol Documentation

◆ TSharedFromThis

template<class ObjectType , ESPMode InMode>
template<class OtherType , ESPMode OtherMode>
friend class TSharedFromThis
friend

Definition at line 1204 of file SharedPointer.h.

◆ TSharedPtr

template<class ObjectType , ESPMode InMode>
template<class OtherType , ESPMode OtherMode>
friend class TSharedPtr
friend

Definition at line 1199 of file SharedPointer.h.

◆ TSharedRef

template<class ObjectType , ESPMode InMode>
template<class OtherType , ESPMode OtherMode>
friend class TSharedRef
friend

Definition at line 1202 of file SharedPointer.h.

◆ TWeakPtr

template<class ObjectType , ESPMode InMode>
template<class OtherType , ESPMode OtherMode>
friend class TWeakPtr
friend

Definition at line 1203 of file SharedPointer.h.

Member Data Documentation

◆ Mode

template<class ObjectType , ESPMode InMode>
constexpr ESPMode TSharedPtr< ObjectType, InMode >::Mode = InMode
staticconstexpr

Definition at line 689 of file SharedPointer.h.

◆ Object

template<class ObjectType , ESPMode InMode>
ObjectType* TSharedPtr< ObjectType, InMode >::Object
private

The object we're holding a reference to. Can be nullptr.

Definition at line 1209 of file SharedPointer.h.

◆ SharedReferenceCount

template<class ObjectType , ESPMode InMode>
SharedPointerInternals::FSharedReferencer< Mode > TSharedPtr< ObjectType, InMode >::SharedReferenceCount
private

Interface to the reference counter for this object. Note that the actual reference controller object is shared by all shared and weak pointers that refer to the object

Definition at line 1213 of file SharedPointer.h.


The documentation for this class was generated from the following file: