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

#include <SharedPointer.h>

Public Types

using ElementType = ObjectType
 

Public Member Functions

FORCEINLINE TWeakPtr (SharedPointerInternals::FNullTag *=nullptr)
 
template<typename OtherType , typename = decltype(ImplicitConv<ObjectType*>((OtherType*)nullptr))>
FORCEINLINE TWeakPtr (TSharedRef< OtherType, Mode > const &InSharedRef)
 
template<typename OtherType , typename = decltype(ImplicitConv<ObjectType*>((OtherType*)nullptr))>
FORCEINLINE TWeakPtr (TSharedPtr< OtherType, Mode > const &InSharedPtr)
 
template<typename OtherType >
FORCEINLINE TWeakPtr (TWeakPtr< OtherType, Mode > const &InWeakPtr, SharedPointerInternals::FStaticCastTag)
 
template<typename OtherType >
FORCEINLINE TWeakPtr (TWeakPtr< OtherType, Mode > const &InWeakPtr, SharedPointerInternals::FConstCastTag)
 
template<typename OtherType , typename = decltype(ImplicitConv<ObjectType*>((OtherType*)nullptr))>
FORCEINLINE TWeakPtr (TWeakPtr< OtherType, Mode > const &InWeakPtr)
 
template<typename OtherType , typename = decltype(ImplicitConv<ObjectType*>((OtherType*)nullptr))>
FORCEINLINE TWeakPtr (TWeakPtr< OtherType, Mode > &&InWeakPtr)
 
FORCEINLINE TWeakPtr (TWeakPtr const &InWeakPtr)
 
FORCEINLINE TWeakPtr (TWeakPtr &&InWeakPtr)
 
FORCEINLINE TWeakPtroperator= (SharedPointerInternals::FNullTag *)
 
FORCEINLINE TWeakPtroperator= (TWeakPtr const &InWeakPtr)
 
FORCEINLINE TWeakPtroperator= (TWeakPtr &&InWeakPtr)
 
template<typename OtherType , typename = decltype(ImplicitConv<ObjectType*>((OtherType*)nullptr))>
FORCEINLINE TWeakPtroperator= (TWeakPtr< OtherType, Mode > const &InWeakPtr)
 
template<typename OtherType , typename = decltype(ImplicitConv<ObjectType*>((OtherType*)nullptr))>
FORCEINLINE TWeakPtroperator= (TWeakPtr< OtherType, Mode > &&InWeakPtr)
 
template<typename OtherType , typename = decltype(ImplicitConv<ObjectType*>((OtherType*)nullptr))>
FORCEINLINE TWeakPtroperator= (TSharedRef< OtherType, Mode > const &InSharedRef)
 
template<typename OtherType , typename = decltype(ImplicitConv<ObjectType*>((OtherType*)nullptr))>
FORCEINLINE TWeakPtroperator= (TSharedPtr< OtherType, Mode > const &InSharedPtr)
 
FORCEINLINE TSharedPtr< ObjectType, ModePin () const &
 
FORCEINLINE TSharedPtr< ObjectType, ModePin () &&
 
FORCEINLINE bool IsValid () const
 
FORCEINLINE void Reset ()
 
FORCEINLINE bool HasSameObject (const void *InOtherPtr) const
 
FORCEINLINE uint32 GetWeakPtrTypeHash () const
 

Static Public Attributes

static constexpr ESPMode Mode = InMode
 

Private Attributes

ObjectTypeObject
 
SharedPointerInternals::FWeakReferencer< ModeWeakReferenceCount
 

Friends

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

Detailed Description

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

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

Definition at line 1245 of file SharedPointer.h.

Member Typedef Documentation

◆ ElementType

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

Definition at line 1248 of file SharedPointer.h.

Constructor & Destructor Documentation

◆ TWeakPtr() [1/9]

Constructs an empty TWeakPtr

Definition at line 1253 of file SharedPointer.h.

◆ TWeakPtr() [2/9]

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

Constructs a weak pointer from a shared reference

Parameters
InSharedRefThe shared reference to create a weak pointer from

Definition at line 1269 of file SharedPointer.h.

◆ TWeakPtr() [3/9]

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

Constructs a weak pointer from a shared pointer

Parameters
InSharedPtrThe shared pointer to create a weak pointer from

Definition at line 1284 of file SharedPointer.h.

◆ TWeakPtr() [4/9]

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

Parameters
InWeakPtrThe weak pointer whose object we should create an additional reference to

Definition at line 1299 of file SharedPointer.h.

◆ TWeakPtr() [5/9]

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

Parameters
InWeakPtrThe weak pointer whose object we should create an additional reference to

Definition at line 1314 of file SharedPointer.h.

◆ TWeakPtr() [6/9]

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

Constructs a weak pointer from a weak pointer of another type. This constructor is intended to allow derived-to-base conversions.

Parameters
InWeakPtrThe weak pointer to create a weak pointer from

Definition at line 1330 of file SharedPointer.h.

◆ TWeakPtr() [7/9]

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

Definition at line 1340 of file SharedPointer.h.

◆ TWeakPtr() [8/9]

Definition at line 1347 of file SharedPointer.h.

◆ TWeakPtr() [9/9]

template<class ObjectType , ESPMode InMode>
FORCEINLINE TWeakPtr< ObjectType, InMode >::TWeakPtr ( TWeakPtr< ObjectType, InMode > && InWeakPtr)
inline

Definition at line 1353 of file SharedPointer.h.

Member Function Documentation

◆ GetWeakPtrTypeHash()

template<class ObjectType , ESPMode InMode>
FORCEINLINE uint32 TWeakPtr< ObjectType, InMode >::GetWeakPtrTypeHash ( ) const
inline

Definition at line 1508 of file SharedPointer.h.

◆ HasSameObject()

template<class ObjectType , ESPMode InMode>
FORCEINLINE bool TWeakPtr< ObjectType, InMode >::HasSameObject ( const void * InOtherPtr) const
inline

Returns true if the object this weak pointer points to is the same as the specified object pointer.

Definition at line 1503 of file SharedPointer.h.

◆ IsValid()

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

Checks to see if this weak pointer actually has a valid reference to an object

Returns
True if the weak pointer is valid and a pin operator would have succeeded

Definition at line 1486 of file SharedPointer.h.

◆ operator=() [1/7]

Assignment to a nullptr pointer. Clears this weak pointer's reference.

Definition at line 1364 of file SharedPointer.h.

◆ operator=() [2/7]

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

Assignment operator sets this weak pointer from a shared pointer

Parameters
InSharedPtrThe shared pointer used to assign to this weak pointer

Definition at line 1448 of file SharedPointer.h.

◆ operator=() [3/7]

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

Assignment operator sets this weak pointer from a shared reference

Parameters
InSharedRefThe shared reference used to assign to this weak pointer

Definition at line 1432 of file SharedPointer.h.

◆ operator=() [4/7]

Definition at line 1382 of file SharedPointer.h.

◆ operator=() [5/7]

Assignment operator adds a weak reference to the object referenced by the specified weak pointer

Parameters
InWeakPtrThe weak pointer for the object to assign

Definition at line 1375 of file SharedPointer.h.

◆ operator=() [6/7]

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

Definition at line 1414 of file SharedPointer.h.

◆ operator=() [7/7]

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

Assignment operator adds a weak reference to the object referenced by the specified weak pointer. This assignment operator is intended to allow derived-to-base conversions.

Parameters
InWeakPtrThe weak pointer for the object to assign

Definition at line 1403 of file SharedPointer.h.

◆ Pin() [1/2]

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

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

Returns
Shared pointer for this object (will only be valid if still referenced!)

Definition at line 1476 of file SharedPointer.h.

◆ Pin() [2/2]

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

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

Returns
Shared pointer for this object (will only be valid if still referenced!)

Definition at line 1463 of file SharedPointer.h.

◆ Reset()

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

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

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

◆ TWeakPtr

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

Definition at line 1516 of file SharedPointer.h.

Member Data Documentation

◆ Mode

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

Definition at line 1249 of file SharedPointer.h.

◆ Object

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

The object we have a weak reference to. Can be nullptr. Also, it's important to note that because this is a weak reference, the object this pointer points to may have already been destroyed.

Definition at line 1525 of file SharedPointer.h.

◆ WeakReferenceCount

template<class ObjectType , ESPMode InMode>
SharedPointerInternals::FWeakReferencer< Mode > TWeakPtr< ObjectType, InMode >::WeakReferenceCount
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 1529 of file SharedPointer.h.


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