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

#include <SharedPointer.h>

Public Member Functions

template<typename OtherType , typename = typename TEnableIf<TPointerIsConvertibleFromTo<OtherType, ObjectType>::Value>::Type>
FORCEINLINE TSharedRef (OtherType *InObject)
 
template<typename OtherType , typename DeleterType , typename = typename TEnableIf<TPointerIsConvertibleFromTo<OtherType, ObjectType>::Value>::Type>
FORCEINLINE TSharedRef (OtherType *InObject, DeleterType &&InDeleter)
 
 TSharedRef ()
 
template<typename OtherType , typename = typename TEnableIf<TPointerIsConvertibleFromTo<OtherType, ObjectType>::Value>::Type>
FORCEINLINE TSharedRef (SharedPointerInternals::FRawPtrProxy< OtherType > const &InRawPtrProxy)
 
template<typename OtherType , typename = typename TEnableIf<TPointerIsConvertibleFromTo<OtherType, ObjectType>::Value>::Type>
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 = typename TEnableIf<TPointerIsConvertibleFromTo<OtherType, ObjectType>::Value>::Type>
FORCEINLINE TSharedRefoperator= (SharedPointerInternals::FRawPtrProxy< OtherType > const &InRawPtrProxy)
 
FORCEINLINE ObjectType & Get () const
 
FORCEINLINE ObjectType & operator* () const
 
FORCEINLINE ObjectType * operator-> () const
 
FORCEINLINE const int32 GetSharedReferenceCount () const
 
FORCEINLINE const bool IsUnique () const
 

Private Member Functions

template<class OtherType >
void Init (OtherType *InObject)
 
template<typename OtherType , typename = typename TEnableIf<TPointerIsConvertibleFromTo<OtherType, ObjectType>::Value>::Type>
FORCEINLINE TSharedRef (TSharedPtr< OtherType, Mode > const &InSharedPtr)
 
template<typename OtherType , typename = typename TEnableIf<TPointerIsConvertibleFromTo<OtherType, ObjectType>::Value>::Type>
FORCEINLINE TSharedRef (TSharedPtr< OtherType, Mode > &&InSharedPtr)
 
FORCEINLINE const bool IsValid () const
 
FORCEINLINE TSharedRef (ObjectType *InObject, SharedPointerInternals::FReferenceControllerBase *InSharedReferenceCount)
 

Private Attributes

ObjectType * Object
 
SharedPointerInternals::FSharedReferencer< Mode > SharedReferenceCount
 

Friends

template<class OtherType , int OtherMode>
class TSharedRef
 
template<class OtherType , int OtherMode>
class TSharedPtr
 
template<class OtherType , int OtherMode>
class TWeakPtr
 
uint32 GetTypeHash (const TSharedRef< ObjectType, Mode > &InSharedRef)
 
TSharedRef UE4SharedPointer_Private::MakeSharedRef (ObjectType *InObject, SharedPointerInternals::FReferenceControllerBase *InSharedReferenceCount)
 

Detailed Description

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

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

Constructor & Destructor Documentation

◆ TSharedRef() [1/13]

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

◆ TSharedRef() [2/13]

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

◆ TSharedRef() [3/13]

template<class ObjectType , int Mode>
TSharedRef< ObjectType, Mode >::TSharedRef ( )
inline

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

Used internally only. Please do not use!

Definition at line 187 of file SharedPointer.h.

◆ TSharedRef() [4/13]

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

◆ TSharedRef() [5/13]

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

◆ TSharedRef() [6/13]

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

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

◆ TSharedRef() [7/13]

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

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

◆ TSharedRef() [8/13]

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

◆ TSharedRef() [9/13]

template<class ObjectType , int Mode>
FORCEINLINE TSharedRef< ObjectType, Mode >::TSharedRef ( TSharedRef< ObjectType, Mode > const & InSharedRef)
inline

Definition at line 278 of file SharedPointer.h.

◆ TSharedRef() [10/13]

template<class ObjectType , int Mode>
FORCEINLINE TSharedRef< ObjectType, Mode >::TSharedRef ( TSharedRef< ObjectType, Mode > && InSharedRef)
inline

Definition at line 283 of file SharedPointer.h.

◆ TSharedRef() [11/13]

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

◆ TSharedRef() [12/13]

template<class ObjectType , int Mode>
template<typename OtherType , typename = typename TEnableIf<TPointerIsConvertibleFromTo<OtherType, ObjectType>::Value>::Type>
FORCEINLINE TSharedRef< ObjectType, Mode >::TSharedRef ( TSharedPtr< OtherType, Mode > && InSharedPtr)
inlineexplicitprivate

Definition at line 429 of file SharedPointer.h.

◆ TSharedRef() [13/13]

template<class ObjectType , int Mode>
FORCEINLINE TSharedRef< ObjectType, Mode >::TSharedRef ( ObjectType * InObject,
SharedPointerInternals::FReferenceControllerBase * InSharedReferenceCount )
inlineexplicitprivate

Definition at line 491 of file SharedPointer.h.

Member Function Documentation

◆ Get()

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

◆ GetSharedReferenceCount()

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

◆ Init()

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

Definition at line 395 of file SharedPointer.h.

◆ IsUnique()

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

◆ IsValid()

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

◆ operator*()

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

◆ operator->()

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

◆ operator=() [1/3]

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

◆ operator=() [2/3]

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

Definition at line 306 of file SharedPointer.h.

◆ operator=() [3/3]

template<class ObjectType , int Mode>
FORCEINLINE TSharedRef & TSharedRef< ObjectType, Mode >::operator= ( TSharedRef< ObjectType, Mode > const & InSharedRef)
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.

Parameters
InSharedRefShared reference to replace with

Definition at line 299 of file SharedPointer.h.

Friends And Related Symbol Documentation

◆ GetTypeHash

template<class ObjectType , int Mode>
uint32 GetTypeHash ( const TSharedRef< ObjectType, Mode > & InSharedRef)
friend

Computes a hash code for this object

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

Definition at line 458 of file SharedPointer.h.

◆ TSharedPtr

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

Definition at line 467 of file SharedPointer.h.

◆ TSharedRef

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

Definition at line 464 of file SharedPointer.h.

◆ TWeakPtr

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

Definition at line 468 of file SharedPointer.h.

◆ UE4SharedPointer_Private::MakeSharedRef

template<class ObjectType , int Mode>
TSharedRef UE4SharedPointer_Private::MakeSharedRef ( ObjectType * InObject,
SharedPointerInternals::FReferenceControllerBase * InSharedReferenceCount )
friend

Member Data Documentation

◆ Object

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

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

Definition at line 473 of file SharedPointer.h.

◆ SharedReferenceCount

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


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