FWeakObjectPtr is a weak pointer to a UObject. 更多...
#include <WeakObjectPtr.h>
Public 成员函数 | |
| FORCEINLINE | FWeakObjectPtr () |
| Null constructor | |
| FORCEINLINE | FWeakObjectPtr (const class UObject *Object) |
| Construct from an object pointer 更多... | |
| FWeakObjectPtr (const FWeakObjectPtr &Other)=default | |
| Construct from another weak pointer 更多... | |
| COREUOBJECT_API class UObject * | Get () const |
| Dereference the weak pointer. 更多... | |
| COREUOBJECT_API class UObject * | Get (bool bEvenIfPendingKill) const |
| Dereference the weak pointer. 更多... | |
| COREUOBJECT_API class UObject * | GetEvenIfUnreachable () const |
| Dereference the weak pointer even if it is RF_PendingKill or RF_Unreachable | |
| FORCEINLINE bool | HasSameIndexAndSerialNumber (const FWeakObjectPtr &Other) const |
| Returns true if two weak pointers were originally set to the same object, even if they are now stale 更多... | |
| FORCEINLINE bool | IsExplicitlyNull () const |
| Returns true if this pointer was explicitly assigned to null, was reset, or was never initialized. 更多... | |
| COREUOBJECT_API bool | IsStale (bool bIncludingIfPendingKill=true, bool bThreadsafeTest=false) const |
| Slightly different than !IsValid(), returns true if this used to point to a UObject, but doesn't any more and has not been assigned or reset in the mean time. 更多... | |
| COREUOBJECT_API bool | IsValid () const |
| Test if this points to a live UObject. 更多... | |
| COREUOBJECT_API bool | IsValid (bool bEvenIfPendingKill, bool bThreadsafeTest=false) const |
| Test if this points to a live UObject 更多... | |
| FORCEINLINE bool | operator!= (const FWeakObjectPtr &Other) const |
| Compare weak pointers for inequality 更多... | |
| COREUOBJECT_API void | operator= (const class UObject *Object) |
| Copy from an object pointer 更多... | |
| FWeakObjectPtr & | operator= (const FWeakObjectPtr &Other)=default |
| Construct from another weak pointer 更多... | |
| FORCEINLINE bool | operator== (const FWeakObjectPtr &Other) const |
| Compare weak pointers for equality. 更多... | |
| FORCEINLINE void | Reset () |
| Reset the weak pointer back to the null state | |
| COREUOBJECT_API void | Serialize (FArchive &Ar) |
| Weak object pointer serialization. 更多... | |
友元 | |
| struct | FObjectKey |
| uint32 | GetTypeHash (const FWeakObjectPtr &WeakObjectPtr) |
| Hash function. | |
| template<typename ReferenceProcessorType , typename CollectorType , typename ArrayPoolType , EFastReferenceCollectorOptions Options> | |
| class | TFastReferenceCollector |
FWeakObjectPtr is a weak pointer to a UObject.
It can return nullptr later if the object is garbage collected. It has no impact on if the object is garbage collected or not. It can't be directly used across a network.
Most often it is used when you explicitly do NOT want to prevent something from being garbage collected.
|
inline |
Construct from an object pointer
| Object | object to create a weak pointer to |
|
default |
Construct from another weak pointer
| Other | weak pointer to copy from |
| COREUOBJECT_API class UObject * FWeakObjectPtr::Get | ( | ) | const |
Dereference the weak pointer.
This is an optimized version implying bEvenIfPendingKill=false.
| COREUOBJECT_API class UObject * FWeakObjectPtr::Get | ( | bool | bEvenIfPendingKill | ) | const |
Dereference the weak pointer.
| bEvenIfPendingKill | if this is true, pendingkill objects are considered valid |
|
inline |
Returns true if two weak pointers were originally set to the same object, even if they are now stale
| Other | weak pointer to compare to |
|
inline |
| COREUOBJECT_API bool FWeakObjectPtr::IsStale | ( | bool | bIncludingIfPendingKill = true, |
| bool | bThreadsafeTest = false |
||
| ) | const |
Slightly different than !IsValid(), returns true if this used to point to a UObject, but doesn't any more and has not been assigned or reset in the mean time.
| bIncludingIfPendingKill | if this is false, pendingkill objects are not considered stale |
| bThreadsafeTest | set it to true when testing outside of Game Thread. Results in false if WeakObjPtr point to an existing object (no flags checked) |
| COREUOBJECT_API bool FWeakObjectPtr::IsValid | ( | ) | const |
| COREUOBJECT_API bool FWeakObjectPtr::IsValid | ( | bool | bEvenIfPendingKill, |
| bool | bThreadsafeTest = false |
||
| ) | const |
Test if this points to a live UObject
| bEvenIfPendingKill | if this is true, pendingkill are not considered invalid |
| bThreadsafeTest | if true then function will just give you information whether referenced UObject is gone forever (return false) or if it is still there (return true, no object flags checked). |
|
inline |
Compare weak pointers for inequality
| Other | weak pointer to compare to |
| COREUOBJECT_API void FWeakObjectPtr::operator= | ( | const class UObject * | Object | ) |
Copy from an object pointer
| Object | object to create a weak pointer to |
|
default |
Construct from another weak pointer
| Other | weak pointer to copy from |
|
inline |
Compare weak pointers for equality.
If both pointers would return nullptr from Get() they count as equal even if they were not initialized to the same object.
| Other | weak pointer to compare to |
| COREUOBJECT_API void FWeakObjectPtr::Serialize | ( | FArchive & | Ar | ) |
Weak object pointer serialization.
Weak object pointers only have weak references to objects and won't serialize the object when gathering references for garbage collection. So in many cases, you don't need to bother serializing weak object pointers. However, serialization is required if you want to load and save your object.