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

#include <SharedPointer.h>

Public Types

using ElementType = ObjectType
 

Public Member Functions

template<typename OtherType , typename = decltype(ImplicitConv<ObjectType*>((OtherType*)nullptr))>
FORCEINLINE TSharedRef (OtherType *InObject)
 
template<typename OtherType , typename DeleterType , typename = decltype(ImplicitConv<ObjectType*>((OtherType*)nullptr))>
FORCEINLINE TSharedRef (OtherType *InObject, DeleterType &&InDeleter)
 
 TSharedRef ()
 
template<typename OtherType , typename = decltype(ImplicitConv<ObjectType*>((OtherType*)nullptr))>
FORCEINLINE TSharedRef (SharedPointerInternals::TRawPtrProxy< OtherType > const &InRawPtrProxy)
 
template<typename OtherType , typename DeleterType , typename = decltype(ImplicitConv<ObjectType*>((OtherType*)nullptr))>
FORCEINLINE TSharedRef (SharedPointerInternals::TRawPtrProxyWithDeleter< OtherType, DeleterType > const &InRawPtrProxy)
 
template<typename OtherType , typename DeleterType , typename = decltype(ImplicitConv<ObjectType*>((OtherType*)nullptr))>
FORCEINLINE TSharedRef (SharedPointerInternals::TRawPtrProxyWithDeleter< OtherType, DeleterType > &&InRawPtrProxy)
 
template<typename OtherType , typename = decltype(ImplicitConv<ObjectType*>((OtherType*)nullptr))>
FORCEINLINE TSharedRef (TSharedRef< OtherType, Mode > const &InSharedRef)
 
template<typename OtherType >
FORCEINLINE TSharedRef (TSharedRef< OtherType, Mode > const &InSharedRef, SharedPointerInternals::FStaticCastTag)
 
template<typename OtherType >
FORCEINLINE TSharedRef (TSharedRef< OtherType, Mode > const &InSharedRef, SharedPointerInternals::FConstCastTag)
 
template<typename OtherType >
FORCEINLINE TSharedRef (TSharedRef< OtherType, Mode > const &OtherSharedRef, ObjectType *InObject)
 
FORCEINLINE TSharedRef (TSharedRef const &InSharedRef)
 
FORCEINLINE TSharedRef (TSharedRef &&InSharedRef)
 
FORCEINLINE TSharedRefoperator= (TSharedRef const &InSharedRef)
 
FORCEINLINE TSharedRefoperator= (TSharedRef &&InSharedRef)
 
template<typename OtherType , typename = decltype(ImplicitConv<ObjectType*>((OtherType*)nullptr))>
FORCEINLINE TSharedRefoperator= (SharedPointerInternals::TRawPtrProxy< OtherType > const &InRawPtrProxy)
 
template<typename OtherType , typename DeleterType , typename = decltype(ImplicitConv<ObjectType*>((OtherType*)nullptr))>
FORCEINLINE TSharedRefoperator= (SharedPointerInternals::TRawPtrProxyWithDeleter< OtherType, DeleterType > const &InRawPtrProxy)
 
template<typename OtherType , typename DeleterType , typename = decltype(ImplicitConv<ObjectType*>((OtherType*)nullptr))>
FORCEINLINE TSharedRefoperator= (SharedPointerInternals::TRawPtrProxyWithDeleter< OtherType, DeleterType > &&InRawPtrProxy)
 
FORCEINLINE TSharedPtr< ObjectType, ModeToSharedPtr () const
 
FORCEINLINE TWeakPtr< ObjectType, ModeToWeakPtr () const
 
FORCEINLINE ObjectTypeGet () const
 
FORCEINLINE ObjectTypeoperator* () const
 
FORCEINLINE ObjectTypeoperator-> () const
 
FORCEINLINE int32 GetSharedReferenceCount () const
 
FORCEINLINE bool IsUnique () const
 

Static Public Attributes

static constexpr ESPMode Mode = InMode
 

Private Member Functions

template<class OtherType >
void Init (OtherType *InObject)
 
template<typename OtherType , typename = decltype(ImplicitConv<ObjectType*>((OtherType*)nullptr))>
FORCEINLINE TSharedRef (TSharedPtr< OtherType, Mode > const &InSharedPtr)
 
template<typename OtherType , typename = decltype(ImplicitConv<ObjectType*>((OtherType*)nullptr))>
FORCEINLINE TSharedRef (TSharedPtr< OtherType, Mode > &&InSharedPtr)
 
FORCEINLINE bool IsValid () const
 
FORCEINLINE TSharedRef (ObjectType *InObject, SharedPointerInternals::TReferenceControllerBase< Mode > *InSharedReferenceCount)
 

Private Attributes

ObjectTypeObject
 
SharedPointerInternals::FSharedReferencer< ModeSharedReferenceCount
 

Friends

template<class OtherType , ESPMode OtherMode>
class TSharedRef
 
template<class OtherType , ESPMode OtherMode>
class TSharedPtr
 
template<class OtherType , ESPMode OtherMode>
class TWeakPtr
 
TSharedRef UE::Core::Private::MakeSharedRef (ObjectType *InObject, SharedPointerInternals::TReferenceControllerBase< Mode > *InSharedReferenceCount)
 

Detailed Description

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

TSharedRef is a non-nullable, non-intrusive reference-counted authoritative object reference.

This shared reference will be conditionally thread-safe when the optional Mode template argument is set to ThreadSafe.

Definition at line 162 of file SharedPointer.h.

Member Typedef Documentation

◆ ElementType

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

Definition at line 165 of file SharedPointer.h.

Constructor & Destructor Documentation

◆ TSharedRef() [1/15]

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

Constructs a shared reference that owns the specified object. Must not be nullptr.

Parameters
InObjectObject this shared reference to retain a reference to

Definition at line 180 of file SharedPointer.h.

◆ TSharedRef() [2/15]

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

Constructs a shared reference that owns the specified object. Must not be nullptr.

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

◆ TSharedRef() [3/15]

template<class ObjectType , ESPMode InMode>
TSharedRef< ObjectType, InMode >::TSharedRef ( )
inline

Constructs default shared reference that owns the default object for specified type.

Used internally only. Please do not use!

Definition at line 214 of file SharedPointer.h.

◆ TSharedRef() [4/15]

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

Constructs a shared reference using a proxy reference to a raw pointer. (See MakeShareable()) Must not be nullptr.

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

Definition at line 233 of file SharedPointer.h.

◆ TSharedRef() [5/15]

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

Constructs a shared reference using a proxy reference to a raw pointer. (See MakeShareable()) Must not be nullptr.

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

Definition at line 260 of file SharedPointer.h.

◆ TSharedRef() [6/15]

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

Constructs a shared reference using a proxy reference to a raw pointer. (See MakeShareable()) Must not be nullptr.

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

Definition at line 287 of file SharedPointer.h.

◆ TSharedRef() [7/15]

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

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

Parameters
InSharedRefThe shared reference whose object we should create an additional reference to

Definition at line 312 of file SharedPointer.h.

◆ TSharedRef() [8/15]

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

Parameters
InSharedRefThe shared reference whose object we should create an additional reference to

Definition at line 327 of file SharedPointer.h.

◆ TSharedRef() [9/15]

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

Parameters
InSharedRefThe shared reference whose object we should create an additional reference to

Definition at line 342 of file SharedPointer.h.

◆ TSharedRef() [10/15]

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

Aliasing constructor used to create a shared reference 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 356 of file SharedPointer.h.

◆ TSharedRef() [11/15]

Definition at line 365 of file SharedPointer.h.

◆ TSharedRef() [12/15]

Definition at line 370 of file SharedPointer.h.

◆ TSharedRef() [13/15]

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

Converts a shared pointer to a shared reference. The pointer must be valid or an assertion will trigger. NOTE: This explicit conversion constructor is intentionally private. Use 'ToSharedRef()' instead.

Returns
Reference to the object

Definition at line 573 of file SharedPointer.h.

◆ TSharedRef() [14/15]

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

Definition at line 586 of file SharedPointer.h.

◆ TSharedRef() [15/15]

template<class ObjectType , ESPMode InMode>
FORCEINLINE TSharedRef< ObjectType, InMode >::TSharedRef ( ObjectType * InObject,
SharedPointerInternals::TReferenceControllerBase< Mode > * InSharedReferenceCount )
inlineexplicitprivate

Definition at line 636 of file SharedPointer.h.

Member Function Documentation

◆ Get()

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

Returns a C++ reference to the object this shared reference is referencing

Returns
The object owned by this shared reference

Definition at line 492 of file SharedPointer.h.

◆ GetSharedReferenceCount()

template<class ObjectType , ESPMode InMode>
FORCEINLINE int32 TSharedRef< 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 529 of file SharedPointer.h.

◆ Init()

template<class ObjectType , ESPMode InMode>
template<class OtherType >
void TSharedRef< ObjectType, InMode >::Init ( OtherType * InObject)
inlineprivate

Definition at line 552 of file SharedPointer.h.

◆ IsUnique()

template<class ObjectType , ESPMode InMode>
FORCEINLINE bool TSharedRef< 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: This has different behavior to GetSharedReferenceCount() == 1 in a multithreaded context. The expectation is that this will be used when a user wants exclusive write-access to an otherwise-immutable object. Care still needs to be taken when pinning TWeakPtrs to make new shared references.

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

Definition at line 545 of file SharedPointer.h.

◆ IsValid()

template<class ObjectType , ESPMode InMode>
FORCEINLINE bool TSharedRef< ObjectType, InMode >::IsValid ( ) const
inlineprivate

Checks to see if this shared reference is actually pointing to an object. NOTE: This validity test is intentionally private because shared references must always be valid.

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

Definition at line 603 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 504 of file SharedPointer.h.

◆ operator->()

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

Arrow operator returns a pointer to this shared reference's object

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

Definition at line 516 of file SharedPointer.h.

◆ operator=() [1/5]

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

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

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

Definition at line 411 of file SharedPointer.h.

◆ operator=() [2/5]

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

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

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

Definition at line 457 of file SharedPointer.h.

◆ operator=() [3/5]

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

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

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

Definition at line 434 of file SharedPointer.h.

◆ operator=() [4/5]

Definition at line 393 of file SharedPointer.h.

◆ operator=() [5/5]

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

Parameters
InSharedRefShared reference to replace with

Definition at line 386 of file SharedPointer.h.

◆ ToSharedPtr()

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

Converts a shared reference to a shared pointer.

Returns
Shared pointer to the object

Definition at line 472 of file SharedPointer.h.

◆ ToWeakPtr()

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

Converts a shared reference to a weak ptr.

Returns
Weak pointer to the object

Definition at line 482 of file SharedPointer.h.

Friends And Related Symbol Documentation

◆ TSharedPtr

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

Definition at line 612 of file SharedPointer.h.

◆ TSharedRef

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

Definition at line 609 of file SharedPointer.h.

◆ TWeakPtr

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

Definition at line 613 of file SharedPointer.h.

◆ UE::Core::Private::MakeSharedRef

Member Data Documentation

◆ Mode

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

Definition at line 166 of file SharedPointer.h.

◆ Object

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

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

Definition at line 618 of file SharedPointer.h.

◆ SharedReferenceCount

template<class ObjectType , ESPMode InMode>
SharedPointerInternals::FSharedReferencer< Mode > TSharedRef< 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 622 of file SharedPointer.h.


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