6#include "Templates/IsPointer.h"
7#include "Templates/PointerIsConvertibleFromTo.h"
8#include "Templates/AndOrNot.h"
9#include "Templates/LosesQualifiersFromTo.h"
10#include "Containers/Map.h"
15
16
17
18
19
20
21
28
29
30template<
class T,
class TWeakObjectPtrBase>
31struct TWeakObjectPtr :
private TWeakObjectPtrBase
33 friend struct FFieldPath;
37 static_assert(
std::is_same_v<TWeakObjectPtrBase,
FWeakObjectPtr>,
"TWeakObjectPtrBase should not be overridden");
40 using ElementType = T;
44 TWeakObjectPtr&
operator=(
const TWeakObjectPtr&) =
default;
48
49
51 TWeakObjectPtrBase((UObject*)
nullptr)
56
57
58
61 decltype(ImplicitConv<T*>(
std::declval<U>()))* =
nullptr
64 TWeakObjectPtrBase((
const UObject*)Object)
68 static_assert(TPointerIsConvertibleFromTo<T,
const volatile UObject>::Value,
"TWeakObjectPtr can only be constructed with UObject types");
72
73
74
77 typename =
decltype(ImplicitConv<T*>((OtherT*)
nullptr))
80 TWeakObjectPtrBase(*(TWeakObjectPtrBase*)&Other)
85
86
89 TWeakObjectPtrBase::Reset();
93
94
95
99 T* TempObject = Object;
100 TWeakObjectPtrBase::operator=(TempObject);
105
106
107
110 typename =
decltype(ImplicitConv<T*>((OtherT*)
nullptr))
114 *(TWeakObjectPtrBase*)
this = *(TWeakObjectPtrBase*)&Other;
120
121
122
123
126 return (T*)TWeakObjectPtrBase::Get(bEvenIfPendingKill);
130
131
134 return (T*)TWeakObjectPtrBase::Get();
140 return (T*)TWeakObjectPtrBase::GetEvenIfUnreachable();
144
145
152
153
163
164
165
166
167
168
169
170
171
172
175 return TWeakObjectPtrBase::IsValid(bEvenIfPendingKill, bThreadsafeTest);
179
180
181
182
183
184
187 return TWeakObjectPtrBase::IsValid();
191
192
193
194
195
198 return TWeakObjectPtrBase::IsStale(bIncludingIfPendingKill, bThreadsafeTest);
202
203
204
207 return TWeakObjectPtrBase::IsExplicitlyNull();
211
212
213
216 return static_cast<
const TWeakObjectPtrBase&>(*
this).HasSameIndexAndSerialNumber(
static_cast<
const TWeakObjectPtrBase&>(Other));
220
221
224 Ar <<
static_cast<TWeakObjectPtrBase&>(*
this);
230 return static_cast<
const TWeakObjectPtrBase&>(*
this).GetTypeHash();
234
235
236
237
238 template <
typename RhsT,
typename =
decltype((T*)
nullptr == (RhsT*)
nullptr)>
241 return (
const TWeakObjectPtrBase&)*
this == (
const TWeakObjectPtrBase&)Rhs;
244 template <
typename RhsT,
typename =
decltype((T*)
nullptr == (RhsT*)
nullptr)>
248 return (
const TWeakObjectPtrBase&)*
this == TWeakObjectPtrBase(Rhs);
258
259
260
261 template <
typename RhsT,
typename =
decltype((T*)
nullptr != (RhsT*)
nullptr)>
264 return (
const TWeakObjectPtrBase&)*
this != (
const TWeakObjectPtrBase&)Rhs;
267 template <
typename RhsT,
typename =
decltype((T*)
nullptr != (RhsT*)
nullptr)>
271 return (
const TWeakObjectPtrBase&)*
this != TWeakObjectPtrBase(Rhs);
283
284
285
286
287template <
typename LhsT,
typename RhsT,
typename OtherTWeakObjectPtrBase,
typename =
decltype((LhsT*)
nullptr == (RhsT*)
nullptr)>
291 return OtherTWeakObjectPtrBase(Lhs) == (
const OtherTWeakObjectPtrBase&)Rhs;
293template <
typename RhsT,
typename OtherTWeakObjectPtrBase>
296 return !Rhs.IsValid();
300
301
302
303template <
typename LhsT,
typename RhsT,
typename OtherTWeakObjectPtrBase,
typename =
decltype((LhsT*)
nullptr != (RhsT*)
nullptr)>
307 return OtherTWeakObjectPtrBase(Lhs) != (
const OtherTWeakObjectPtrBase&)Rhs;
309template <
typename RhsT,
typename OtherTWeakObjectPtrBase>
312 return Rhs.IsValid();
320 return TWeakObjectPtr<T>(Ptr);
323template<
class T>
struct TIsPODType<TWeakObjectPtr<T> > {
enum { Value =
true }; };
324template<
class T>
struct TIsZeroConstructType<TWeakObjectPtr<T> > {
enum { Value =
true }; };
325template<
class T>
struct TIsWeakPointerType<TWeakObjectPtr<T> > {
enum { Value =
true }; };
329
330
331template <
typename ElementType,
bool bInAllowDuplicateKeys =
false>
348
349
350template <
typename KeyType,
typename ValueType,
bool bInAllowDuplicateKeys =
false>
367
368
374 UE_DEPRECATED(4.15,
"TAutoWeakObjectPtr has been deprecated - use TWeakObjectPtr instead")
379 UE_DEPRECATED(4.15,
"TAutoWeakObjectPtr has been deprecated - use TWeakObjectPtr instead")
385 UE_DEPRECATED(4.15,
"TAutoWeakObjectPtr has been deprecated - use TWeakObjectPtr instead")
390 UE_DEPRECATED(4.15,
"Implicit conversion from TAutoWeakObjectPtr to the pointer type has been deprecated - use Get() instead")
395 UE_DEPRECATED(4.15,
"Implicit conversion from TAutoWeakObjectPtr to the pointer type has been deprecated - use Get() instead")
398 return (
const T*)
this->
Get();
401 UE_DEPRECATED(4.15,
"Implicit conversion from TAutoWeakObjectPtr to the pointer type has been deprecated - use Get() instead")
404 return this->
Get() !=
nullptr;
413template<
typename DestArrayType,
typename SourceArrayType>
416 Dest.Empty(Src.Num());
417 for (int32 Index = 0; Index < Src.Num(); Index++)
419 if (
auto Value = Src[Index].Get())
430 return WeakObjectPtr.GetWeakPtrTypeHash();
435
436
437template<
class T,
class TWeakObjectPtrBase>
440 WeakObjectPtr.Serialize(Ar);
#define UE_DEPRECATED(Version, Message)
FORCEINLINE uint32 GetTypeHash(const TWeakObjectPtr< T > &WeakObjectPtr)
FORCENOINLINE bool operator!=(const LhsT *Lhs, const TWeakObjectPtr< RhsT, OtherTWeakObjectPtrBase > &Rhs)
FORCENOINLINE bool operator!=(TYPE_OF_NULLPTR, const TWeakObjectPtr< RhsT, OtherTWeakObjectPtrBase > &Rhs)
FORCENOINLINE bool operator==(const LhsT *Lhs, const TWeakObjectPtr< RhsT, OtherTWeakObjectPtrBase > &Rhs)
void CopyFromWeakArray(DestArrayType &Dest, const SourceArrayType &Src)
FORCENOINLINE bool operator==(TYPE_OF_NULLPTR, const TWeakObjectPtr< RhsT, OtherTWeakObjectPtrBase > &Rhs)
FORCEINLINE TWeakObjectPtr< T > MakeWeakObjectPtr(T *Ptr)
FORCEINLINE TAutoWeakObjectPtr(const TWeakObjectPtr< T > &Other)
FORCEINLINE operator T*() const
FORCEINLINE operator const T *() const
FORCEINLINE TAutoWeakObjectPtr()
FORCEINLINE operator bool() const
FORCEINLINE TAutoWeakObjectPtr(const T *Target)
FORCENOINLINE bool operator!=(const TWeakObjectPtr< RhsT, TWeakObjectPtrBase > &Rhs) const
FORCENOINLINE bool operator==(const RhsT *Rhs) const
FORCEINLINE bool IsValid(bool bEvenIfPendingKill, bool bThreadsafeTest=false) const
FORCEINLINE T * operator->() const
~TWeakObjectPtr()=default
FORCEINLINE void Serialize(FArchive &Ar)
FORCEINLINE T & operator*() const
FORCEINLINE uint32 GetWeakPtrTypeHash() const
TWeakObjectPtr(const TWeakObjectPtr &)=default
FORCEINLINE T * Get() const
FORCENOINLINE bool operator==(const TWeakObjectPtr< RhsT, TWeakObjectPtrBase > &Rhs) const
FORCEINLINE TWeakObjectPtr(TYPE_OF_NULLPTR)
FORCEINLINE TEnableIf<!TLosesQualifiersFromTo< U, T >::Value, TWeakObjectPtr & >::Type operator=(U *Object)
FORCEINLINE bool IsValid() const
FORCEINLINE bool IsStale(bool bIncludingIfPendingKill=true, bool bThreadsafeTest=false) const
FORCENOINLINE bool operator==(TYPE_OF_NULLPTR) const
FORCEINLINE TWeakObjectPtr(U Object)
TWeakObjectPtr & operator=(const TWeakObjectPtr &)=default
FORCENOINLINE bool operator!=(const RhsT *Rhs) const
FORCEINLINE T * Get(bool bEvenIfPendingKill) const
operator bool() const =delete
FORCEINLINE TWeakObjectPtr(const TWeakObjectPtr< OtherT, TWeakObjectPtrBase > &Other)
FORCEINLINE T * GetEvenIfUnreachable() const
FORCEINLINE bool IsExplicitlyNull() const
FORCEINLINE bool HasSameIndexAndSerialNumber(const TWeakObjectPtr &Other) const
FORCEINLINE TWeakObjectPtr & operator=(const TWeakObjectPtr< OtherT, TWeakObjectPtrBase > &Other)
FORCENOINLINE bool operator!=(TYPE_OF_NULLPTR) const
static FORCEINLINE uint32 GetKeyHash(KeyInitType Key)
TDefaultMapKeyFuncs< KeyType, ValueType, bInAllowDuplicateKeys >::KeyInitType KeyInitType
static FORCEINLINE bool Matches(KeyInitType A, KeyInitType B)
static FORCEINLINE uint32 GetKeyHash(KeyInitType Key)
static FORCEINLINE bool Matches(KeyInitType A, KeyInitType B)
DefaultKeyFuncs< ElementType, bInAllowDuplicateKeys >::KeyInitType KeyInitType