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

#include <SharedPointer.h>

Public Member Functions

FORCEINLINE TSharedPtr (SharedPointerInternals::FNullTag *=nullptr)
 
template<typename OtherType , typename = typename TEnableIf<TPointerIsConvertibleFromTo<OtherType, ObjectType>::Value>::Type>
FORCEINLINE TSharedPtr (OtherType *InObject)
 
template<typename OtherType , typename DeleterType , typename = typename TEnableIf<TPointerIsConvertibleFromTo<OtherType, ObjectType>::Value>::Type>
FORCEINLINE TSharedPtr (OtherType *InObject, DeleterType &&InDeleter)
 
template<typename OtherType , typename = typename TEnableIf<TPointerIsConvertibleFromTo<OtherType, ObjectType>::Value>::Type>
FORCEINLINE TSharedPtr (SharedPointerInternals::FRawPtrProxy< OtherType > const &InRawPtrProxy)
 
template<typename OtherType , typename = typename TEnableIf<TPointerIsConvertibleFromTo<OtherType, ObjectType>::Value>::Type>
FORCEINLINE TSharedPtr (TSharedPtr< OtherType, Mode > const &InSharedPtr)
 
FORCEINLINE TSharedPtr (TSharedPtr const &InSharedPtr)
 
FORCEINLINE TSharedPtr (TSharedPtr &&InSharedPtr)
 
template<typename OtherType , typename = typename TEnableIf<TPointerIsConvertibleFromTo<OtherType, ObjectType>::Value>::Type>
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 = typename TEnableIf<TPointerIsConvertibleFromTo<OtherType, ObjectType>::Value>::Type>
FORCEINLINE TSharedPtroperator= (SharedPointerInternals::FRawPtrProxy< OtherType > const &InRawPtrProxy)
 
FORCEINLINE TSharedRef< ObjectType, Mode > ToSharedRef () const
 
FORCEINLINE ObjectType * Get () const
 
FORCEINLINE const bool IsValid () const
 
FORCEINLINE FMakeReferenceTo< ObjectType >::Type operator* () const
 
FORCEINLINE ObjectType * operator-> () const
 
FORCEINLINE void Reset ()
 
FORCEINLINE const int32 GetSharedReferenceCount () const
 
FORCEINLINE const bool IsUnique () const
 

Private Member Functions

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

Private Attributes

ObjectType * Object
 
SharedPointerInternals::FSharedReferencer< Mode > SharedReferenceCount
 

Friends

template<class OtherType , int OtherMode>
class TSharedPtr
 
template<class OtherType , int OtherMode>
class TSharedRef
 
template<class OtherType , int OtherMode>
class TWeakPtr
 
template<class OtherType , int OtherMode>
class TSharedFromThis
 
uint32 GetTypeHash (const TSharedPtr< ObjectType, Mode > &InSharedPtr)
 

Detailed Description

template<class ObjectType, int Mode>
class TSharedPtr< ObjectType, Mode >

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 522 of file SharedPointer.h.

Constructor & Destructor Documentation

◆ TSharedPtr() [1/14]

template<class ObjectType , int Mode>
FORCEINLINE TSharedPtr< ObjectType, Mode >::TSharedPtr ( SharedPointerInternals::FNullTag * = nullptr)
inline

Constructs an empty shared pointer

Definition at line 530 of file SharedPointer.h.

◆ TSharedPtr() [2/14]

template<class ObjectType , int Mode>
template<typename OtherType , typename = typename TEnableIf<TPointerIsConvertibleFromTo<OtherType, ObjectType>::Value>::Type>
FORCEINLINE TSharedPtr< ObjectType, Mode >::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 545 of file SharedPointer.h.

◆ TSharedPtr() [3/14]

template<class ObjectType , int Mode>
template<typename OtherType , typename DeleterType , typename = typename TEnableIf<TPointerIsConvertibleFromTo<OtherType, ObjectType>::Value>::Type>
FORCEINLINE TSharedPtr< ObjectType, Mode >::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 566 of file SharedPointer.h.

◆ TSharedPtr() [4/14]

template<class ObjectType , int Mode>
template<typename OtherType , typename = typename TEnableIf<TPointerIsConvertibleFromTo<OtherType, ObjectType>::Value>::Type>
FORCEINLINE TSharedPtr< ObjectType, Mode >::TSharedPtr ( SharedPointerInternals::FRawPtrProxy< 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 585 of file SharedPointer.h.

◆ TSharedPtr() [5/14]

template<class ObjectType , int Mode>
template<typename OtherType , typename = typename TEnableIf<TPointerIsConvertibleFromTo<OtherType, ObjectType>::Value>::Type>
FORCEINLINE TSharedPtr< ObjectType, Mode >::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 604 of file SharedPointer.h.

◆ TSharedPtr() [6/14]

template<class ObjectType , int Mode>
FORCEINLINE TSharedPtr< ObjectType, Mode >::TSharedPtr ( TSharedPtr< ObjectType, Mode > const & InSharedPtr)
inline

Definition at line 609 of file SharedPointer.h.

◆ TSharedPtr() [7/14]

template<class ObjectType , int Mode>
FORCEINLINE TSharedPtr< ObjectType, Mode >::TSharedPtr ( TSharedPtr< ObjectType, Mode > && InSharedPtr)
inline

Definition at line 614 of file SharedPointer.h.

◆ TSharedPtr() [8/14]

template<class ObjectType , int Mode>
template<typename OtherType , typename = typename TEnableIf<TPointerIsConvertibleFromTo<OtherType, ObjectType>::Value>::Type>
FORCEINLINE TSharedPtr< ObjectType, Mode >::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 632 of file SharedPointer.h.

◆ TSharedPtr() [9/14]

template<class ObjectType , int Mode>
template<typename OtherType >
FORCEINLINE TSharedPtr< ObjectType, Mode >::TSharedPtr ( TSharedPtr< OtherType, Mode > const & InSharedPtr,
SharedPointerInternals::FStaticCastTag  )
inline

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 649 of file SharedPointer.h.

◆ TSharedPtr() [10/14]

template<class ObjectType , int Mode>
template<typename OtherType >
FORCEINLINE TSharedPtr< ObjectType, Mode >::TSharedPtr ( TSharedPtr< OtherType, Mode > const & InSharedPtr,
SharedPointerInternals::FConstCastTag  )
inline

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 663 of file SharedPointer.h.

◆ TSharedPtr() [11/14]

template<class ObjectType , int Mode>
template<typename OtherType >
FORCEINLINE TSharedPtr< ObjectType, Mode >::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 676 of file SharedPointer.h.

◆ TSharedPtr() [12/14]

template<class ObjectType , int Mode>
template<typename OtherType >
FORCEINLINE TSharedPtr< ObjectType, Mode >::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 689 of file SharedPointer.h.

◆ TSharedPtr() [13/14]

template<class ObjectType , int Mode>
template<typename OtherType >
FORCEINLINE TSharedPtr< ObjectType, Mode >::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 704 of file SharedPointer.h.

◆ TSharedPtr() [14/14]

template<class ObjectType , int Mode>
template<typename OtherType , typename = typename TEnableIf<TPointerIsConvertibleFromTo<OtherType, ObjectType>::Value>::Type>
FORCEINLINE TSharedPtr< ObjectType, Mode >::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 866 of file SharedPointer.h.

Member Function Documentation

◆ Get()

template<class ObjectType , int Mode>
FORCEINLINE ObjectType * TSharedPtr< ObjectType, Mode >::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 782 of file SharedPointer.h.

+ Here is the caller graph for this function:

◆ GetSharedReferenceCount()

template<class ObjectType , int Mode>
FORCEINLINE const int32 TSharedPtr< ObjectType, Mode >::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 834 of file SharedPointer.h.

◆ IsUnique()

template<class ObjectType , int Mode>
FORCEINLINE const bool TSharedPtr< ObjectType, Mode >::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 846 of file SharedPointer.h.

◆ IsValid()

template<class ObjectType , int Mode>
FORCEINLINE const bool TSharedPtr< ObjectType, Mode >::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 792 of file SharedPointer.h.

◆ operator*()

template<class ObjectType , int Mode>
FORCEINLINE FMakeReferenceTo< ObjectType >::Type TSharedPtr< ObjectType, Mode >::operator* ( ) const
inline

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

Returns
Reference to the object

Definition at line 802 of file SharedPointer.h.

◆ operator->()

template<class ObjectType , int Mode>
FORCEINLINE ObjectType * TSharedPtr< ObjectType, Mode >::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 813 of file SharedPointer.h.

◆ operator=() [1/4]

template<class ObjectType , int Mode>
FORCEINLINE TSharedPtr & TSharedPtr< ObjectType, Mode >::operator= ( SharedPointerInternals::FNullTag * )
inline

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 714 of file SharedPointer.h.

◆ operator=() [2/4]

template<class ObjectType , int Mode>
template<typename OtherType , typename = typename TEnableIf<TPointerIsConvertibleFromTo<OtherType, ObjectType>::Value>::Type>
FORCEINLINE TSharedPtr & TSharedPtr< ObjectType, Mode >::operator= ( SharedPointerInternals::FRawPtrProxy< 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 757 of file SharedPointer.h.

◆ operator=() [3/4]

template<class ObjectType , int Mode>
FORCEINLINE TSharedPtr & TSharedPtr< ObjectType, Mode >::operator= ( TSharedPtr< ObjectType, Mode > && InSharedPtr)
inline

Definition at line 734 of file SharedPointer.h.

◆ operator=() [4/4]

template<class ObjectType , int Mode>
FORCEINLINE TSharedPtr & TSharedPtr< ObjectType, Mode >::operator= ( TSharedPtr< ObjectType, Mode > const & InSharedPtr)
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
InSharedPtrShared pointer to replace with

Definition at line 727 of file SharedPointer.h.

◆ Reset()

template<class ObjectType , int Mode>
FORCEINLINE void TSharedPtr< ObjectType, Mode >::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 823 of file SharedPointer.h.

◆ ToSharedRef()

template<class ObjectType , int Mode>
FORCEINLINE TSharedRef< ObjectType, Mode > TSharedPtr< ObjectType, Mode >::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 769 of file SharedPointer.h.

Friends And Related Symbol Documentation

◆ GetTypeHash

template<class ObjectType , int Mode>
uint32 GetTypeHash ( const TSharedPtr< ObjectType, Mode > & InSharedPtr)
friend

Computes a hash code for this object

Parameters
InSharedPtrShared pointer to compute hash code for
Returns
Hash code value

Definition at line 885 of file SharedPointer.h.

◆ TSharedFromThis

template<class ObjectType , int Mode>
template<class OtherType , int OtherMode>
friend class TSharedFromThis
friend

Definition at line 896 of file SharedPointer.h.

◆ TSharedPtr

template<class ObjectType , int Mode>
template<class OtherType , int OtherMode>
friend class TSharedPtr
friend

Definition at line 891 of file SharedPointer.h.

◆ TSharedRef

template<class ObjectType , int Mode>
template<class OtherType , int OtherMode>
friend class TSharedRef
friend

Definition at line 894 of file SharedPointer.h.

◆ TWeakPtr

template<class ObjectType , int Mode>
template<class OtherType , int OtherMode>
friend class TWeakPtr
friend

Definition at line 895 of file SharedPointer.h.

Member Data Documentation

◆ Object

template<class ObjectType , int Mode>
ObjectType* TSharedPtr< ObjectType, Mode >::Object
private

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

Definition at line 899 of file SharedPointer.h.

◆ SharedReferenceCount

template<class ObjectType , int Mode>
SharedPointerInternals::FSharedReferencer< Mode > TSharedPtr< ObjectType, Mode >::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 903 of file SharedPointer.h.


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