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

#include <SharedPointer.h>

Public Member Functions

FORCEINLINE TWeakPtr (SharedPointerInternals::FNullTag *=nullptr)
 
template<typename OtherType , typename = typename TEnableIf<TPointerIsConvertibleFromTo<OtherType, ObjectType>::Value>::Type>
FORCEINLINE TWeakPtr (TSharedRef< OtherType, Mode > const &InSharedRef)
 
template<typename OtherType , typename = typename TEnableIf<TPointerIsConvertibleFromTo<OtherType, ObjectType>::Value>::Type>
FORCEINLINE TWeakPtr (TSharedPtr< OtherType, Mode > const &InSharedPtr)
 
template<typename OtherType , typename = typename TEnableIf<TPointerIsConvertibleFromTo<OtherType, ObjectType>::Value>::Type>
FORCEINLINE TWeakPtr (TWeakPtr< OtherType, Mode > const &InWeakPtr)
 
template<typename OtherType , typename = typename TEnableIf<TPointerIsConvertibleFromTo<OtherType, ObjectType>::Value>::Type>
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 = typename TEnableIf<TPointerIsConvertibleFromTo<OtherType, ObjectType>::Value>::Type>
FORCEINLINE TWeakPtroperator= (TWeakPtr< OtherType, Mode > const &InWeakPtr)
 
template<typename OtherType , typename = typename TEnableIf<TPointerIsConvertibleFromTo<OtherType, ObjectType>::Value>::Type>
FORCEINLINE TWeakPtroperator= (TWeakPtr< OtherType, Mode > &&InWeakPtr)
 
template<typename OtherType , typename = typename TEnableIf<TPointerIsConvertibleFromTo<OtherType, ObjectType>::Value>::Type>
FORCEINLINE TWeakPtroperator= (TSharedRef< OtherType, Mode > const &InSharedRef)
 
template<typename OtherType , typename = typename TEnableIf<TPointerIsConvertibleFromTo<OtherType, ObjectType>::Value>::Type>
FORCEINLINE TWeakPtroperator= (TSharedPtr< OtherType, Mode > const &InSharedPtr)
 
FORCEINLINE TSharedPtr< ObjectType, Mode > Pin () const
 
FORCEINLINE const bool IsValid () const
 
FORCEINLINE void Reset ()
 
FORCEINLINE bool HasSameObject (const void *InOtherPtr) const
 

Private Attributes

ObjectType * Object
 
SharedPointerInternals::FWeakReferencer< Mode > WeakReferenceCount
 

Friends

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

Detailed Description

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

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

Constructor & Destructor Documentation

◆ TWeakPtr() [1/7]

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

Constructs an empty TWeakPtr

Definition at line 919 of file SharedPointer.h.

◆ TWeakPtr() [2/7]

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

◆ TWeakPtr() [3/7]

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

◆ TWeakPtr() [4/7]

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

◆ TWeakPtr() [5/7]

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

Definition at line 972 of file SharedPointer.h.

◆ TWeakPtr() [6/7]

template<class ObjectType , int Mode>
FORCEINLINE TWeakPtr< ObjectType, Mode >::TWeakPtr ( TWeakPtr< ObjectType, Mode > const & InWeakPtr)
inline

Definition at line 979 of file SharedPointer.h.

◆ TWeakPtr() [7/7]

template<class ObjectType , int Mode>
FORCEINLINE TWeakPtr< ObjectType, Mode >::TWeakPtr ( TWeakPtr< ObjectType, Mode > && InWeakPtr)
inline

Definition at line 984 of file SharedPointer.h.

Member Function Documentation

◆ HasSameObject()

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

◆ IsValid()

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

◆ operator=() [1/7]

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

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

Definition at line 995 of file SharedPointer.h.

◆ operator=() [2/7]

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

◆ operator=() [3/7]

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

◆ operator=() [4/7]

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

Definition at line 1013 of file SharedPointer.h.

◆ operator=() [5/7]

template<class ObjectType , int Mode>
FORCEINLINE TWeakPtr & TWeakPtr< ObjectType, Mode >::operator= ( TWeakPtr< ObjectType, Mode > const & InWeakPtr)
inline

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

◆ operator=() [6/7]

template<class ObjectType , int Mode>
template<typename OtherType , typename = typename TEnableIf<TPointerIsConvertibleFromTo<OtherType, ObjectType>::Value>::Type>
FORCEINLINE TWeakPtr & TWeakPtr< ObjectType, Mode >::operator= ( TWeakPtr< OtherType, Mode > && InWeakPtr)
inline

Definition at line 1045 of file SharedPointer.h.

◆ operator=() [7/7]

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

◆ Pin()

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

◆ Reset()

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

Friends And Related Symbol Documentation

◆ GetTypeHash

template<class ObjectType , int Mode>
uint32 GetTypeHash ( const TWeakPtr< ObjectType, Mode > & InWeakPtr)
friend

Computes a hash code for this object

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

Definition at line 1135 of file SharedPointer.h.

◆ TSharedPtr

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

Definition at line 1144 of file SharedPointer.h.

◆ TWeakPtr

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

Definition at line 1141 of file SharedPointer.h.

Member Data Documentation

◆ Object

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

◆ WeakReferenceCount

template<class ObjectType , int Mode>
SharedPointerInternals::FWeakReferencer< Mode > TWeakPtr< ObjectType, Mode >::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 1154 of file SharedPointer.h.


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