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

#include <SharedPointer.h>

Public Member Functions

TSharedRef< ObjectType, Mode > AsShared ()
 
TSharedRef< ObjectType const, Mode > AsShared () const
 
template<class SharedPtrType , class OtherType >
FORCEINLINE void UpdateWeakReferenceInternal (TSharedPtr< SharedPtrType, Mode > const *InSharedPtr, OtherType *InObject) const
 
template<class SharedRefType , class OtherType >
FORCEINLINE void UpdateWeakReferenceInternal (TSharedRef< SharedRefType, Mode > const *InSharedRef, OtherType *InObject) const
 
FORCEINLINE bool DoesSharedInstanceExist () const
 

Protected Member Functions

 TSharedFromThis ()
 
 TSharedFromThis (TSharedFromThis const &)
 
FORCEINLINE TSharedFromThisoperator= (TSharedFromThis const &)
 
 ~TSharedFromThis ()
 

Static Protected Member Functions

template<class OtherType >
static FORCEINLINE TSharedRef< OtherType, Mode > SharedThis (OtherType *ThisPtr)
 
template<class OtherType >
static FORCEINLINE TSharedRef< OtherType const, Mode > SharedThis (const OtherType *ThisPtr)
 

Private Attributes

TWeakPtr< ObjectType, Mode > WeakThis
 

Detailed Description

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

Derive your class from TSharedFromThis to enable access to a TSharedRef directly from an object instance that's already been allocated. Use the optional Mode template argument for thread-safety.

Definition at line 1165 of file SharedPointer.h.

Constructor & Destructor Documentation

◆ TSharedFromThis() [1/2]

template<class ObjectType , int Mode>
TSharedFromThis< ObjectType, Mode >::TSharedFromThis ( )
inlineprotected

Hidden stub constructor

Definition at line 1298 of file SharedPointer.h.

◆ TSharedFromThis() [2/2]

template<class ObjectType , int Mode>
TSharedFromThis< ObjectType, Mode >::TSharedFromThis ( TSharedFromThis< ObjectType, Mode > const & )
inlineprotected

Hidden stub copy constructor

Definition at line 1301 of file SharedPointer.h.

◆ ~TSharedFromThis()

template<class ObjectType , int Mode>
TSharedFromThis< ObjectType, Mode >::~TSharedFromThis ( )
inlineprotected

Hidden destructor

Definition at line 1310 of file SharedPointer.h.

Member Function Documentation

◆ AsShared() [1/2]

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

Provides access to a shared reference to this object. Note that is only valid to call this after a shared reference (or shared pointer) to the object has already been created. Also note that it is illegal to call this in the object's destructor.

Returns
Returns this object as a shared pointer

Definition at line 1176 of file SharedPointer.h.

◆ AsShared() [2/2]

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

Provides access to a shared reference to this object (const.) Note that is only valid to call this after a shared reference (or shared pointer) to the object has already been created. Also note that it is illegal to call this in the object's destructor.

Returns
Returns this object as a shared pointer (const)

Definition at line 1203 of file SharedPointer.h.

◆ DoesSharedInstanceExist()

template<class ObjectType , int Mode>
FORCEINLINE bool TSharedFromThis< ObjectType, Mode >::DoesSharedInstanceExist ( ) const
inline

Checks whether our referenced instance is valid (ie, whether it's safe to call AsShared). If this returns false, it means that your instance has either:

  • Not yet been assigned to a shared pointer (via MakeShared or MakeShareable).
  • Is currently within its constructor (so the shared instance isn't yet available).
  • Is currently within its destructor (so the shared instance is no longer available).

Definition at line 1290 of file SharedPointer.h.

◆ operator=()

template<class ObjectType , int Mode>
FORCEINLINE TSharedFromThis & TSharedFromThis< ObjectType, Mode >::operator= ( TSharedFromThis< ObjectType, Mode > const & )
inlineprotected

Hidden stub assignment operator

Definition at line 1304 of file SharedPointer.h.

◆ SharedThis() [1/2]

template<class ObjectType , int Mode>
template<class OtherType >
static FORCEINLINE TSharedRef< OtherType const, Mode > TSharedFromThis< ObjectType, Mode >::SharedThis ( const OtherType * ThisPtr)
inlinestaticprotected

Provides access to a shared reference to an object, given the object's 'this' pointer. Uses the 'this' pointer to derive the object's actual type, then casts and returns an appropriately typed shared reference. Intentionally declared 'protected', as should only be called when the 'this' pointer can be passed.

Returns
Returns this object as a shared pointer (const)

Definition at line 1248 of file SharedPointer.h.

◆ SharedThis() [2/2]

template<class ObjectType , int Mode>
template<class OtherType >
static FORCEINLINE TSharedRef< OtherType, Mode > TSharedFromThis< ObjectType, Mode >::SharedThis ( OtherType * ThisPtr)
inlinestaticprotected

Provides access to a shared reference to an object, given the object's 'this' pointer. Uses the 'this' pointer to derive the object's actual type, then casts and returns an appropriately typed shared reference. Intentionally declared 'protected', as should only be called when the 'this' pointer can be passed.

Returns
Returns this object as a shared pointer

Definition at line 1234 of file SharedPointer.h.

◆ UpdateWeakReferenceInternal() [1/2]

template<class ObjectType , int Mode>
template<class SharedPtrType , class OtherType >
FORCEINLINE void TSharedFromThis< ObjectType, Mode >::UpdateWeakReferenceInternal ( TSharedPtr< SharedPtrType, Mode > const * InSharedPtr,
OtherType * InObject ) const
inline

INTERNAL USE ONLY – Do not call this method. Freshens the internal weak pointer object using the supplied object pointer along with the authoritative shared reference to the object. Note that until this function is called, calls to AsShared() will result in an empty pointer.

Definition at line 1261 of file SharedPointer.h.

◆ UpdateWeakReferenceInternal() [2/2]

template<class ObjectType , int Mode>
template<class SharedRefType , class OtherType >
FORCEINLINE void TSharedFromThis< ObjectType, Mode >::UpdateWeakReferenceInternal ( TSharedRef< SharedRefType, Mode > const * InSharedRef,
OtherType * InObject ) const
inline

INTERNAL USE ONLY – Do not call this method. Freshens the internal weak pointer object using the supplied object pointer along with the authoritative shared reference to the object. Note that until this function is called, calls to AsShared() will result in an empty pointer.

Definition at line 1275 of file SharedPointer.h.

Member Data Documentation

◆ WeakThis

template<class ObjectType , int Mode>
TWeakPtr< ObjectType, Mode > TSharedFromThis< ObjectType, Mode >::WeakThis
mutableprivate

Weak reference to ourselves. If we're destroyed then this weak pointer reference will be destructed with ourselves. Note this is declared mutable only so that UpdateWeakReferenceInternal() can update it.

Definition at line 1316 of file SharedPointer.h.


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