Ark Server API (ASA) - Wiki
Loading...
Searching...
No Matches
ObjectPtr.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#include "HAL/Platform.h"
6#include "Serialization/StructuredArchive.h"
7//#include "UObject/Class.h"
8//#include "UObject/Object.h"
9//#include "UObject/ObjectHandle.h"
10
11#include <type_traits>
12
13#define UE_WITH_OBJECT_PTR_DEPRECATIONS 0
15 #define UE_OBJPTR_DEPRECATED(Version, Message) UE_DEPRECATED(Version, Message)
16#else
17 #define UE_OBJPTR_DEPRECATED(Version, Message)
18#endif
19
20/**
21 * Wrapper macro for use in places where code needs to allow for a pointer type that could be a TObjectPtr<T> or a raw object pointer during a transitional period.
22 * The coding standard disallows general use of the auto keyword, but in wrapping it in this macro, we have a record
23 * of the explicit type meant to be used, and an avenue to go back and change these instances to an explicit
24 * TObjectPtr<T> after the transition is complete and the type won't be toggling back and forth anymore.
25 */
26#define UE_TRANSITIONAL_OBJECT_PTR(Type) auto
27#define UE_TRANSITIONAL_OBJECT_PTR_TEMPLATE(Templ, Type) auto
28#define UE_TRANSITIONAL_OBJECT_PTR_TEMPLATE_SUFFIXED(Templ, Type, Suffix) auto
29#define UE_TRANSITIONAL_OBJECT_PTR_TEMPLATE2_ARG1(Templ, Type1, Type2) auto
30#define UE_TRANSITIONAL_OBJECT_PTR_TEMPLATE2_ARG1_SUFFIXED(Templ, Type1, Type2, Suffix) auto
31#define UE_TRANSITIONAL_OBJECT_PTR_TEMPLATE2_ARG2(Templ, Type1, Type2) auto
32#define UE_TRANSITIONAL_OBJECT_PTR_TEMPLATE2_ARG2_SUFFIXED(Templ, Type1, Type2, Suffix) auto
33#define UE_TRANSITIONAL_OBJECT_PTR_TEMPLATE2_ARG_BOTH(Templ, Type1, Type2) auto
34#define UE_TRANSITIONAL_OBJECT_PTR_TEMPLATE2_ARG_BOTH_SUFFIXED(Templ, Type1, Type2, Suffix) auto
35
36#if PLATFORM_MICROSOFT && defined(_MSC_EXTENSIONS)
37 /**
38 * Non-conformance mode in MSVC has issues where the presence of a conversion operator to bool (even an explicit one)
39 * leads to operator ambiguity for operator== and operator!= with a NULL (not nullptr). This macro controls the presence
40 * of code to deal with this issue.
41 */
42 #define UE_OBJECT_PTR_NONCONFORMANCE_SUPPORT 1
43#else
44 #define UE_OBJECT_PTR_NONCONFORMANCE_SUPPORT 0
45#endif
46
47template <typename T>
48struct TObjectPtr;
49
50/**
51 * FObjectPtr is the basic, minimally typed version of TObjectPtr
52 */
53namespace UE::CoreUObject::Private
54{
55 struct FObjectHandlePrivate;
56}
57
58using FObjectHandle = UE::CoreUObject::Private::FObjectHandlePrivate;
59
60namespace UE::CoreUObject::Private
61{
62 inline FObjectHandle MakeObjectHandle(UObject* Object)
63 {
64#if UE_WITH_OBJECT_HANDLE_LATE_RESOLVE
65 { return { UPTRINT(Object) }; }
66#else
67 return Object;
68#endif
69 }
70
71 inline UObject* ResolveObjectHandle(FObjectHandle& Handle)
72 {
73#if UE_WITH_OBJECT_HANDLE_LATE_RESOLVE || UE_WITH_OBJECT_HANDLE_TRACKING
74 UObject* ResolvedObject = ResolveObjectHandleNoRead(Handle);
75 UE::CoreUObject::Private::OnHandleRead(ResolvedObject);
76 return ResolvedObject;
77#else
78 return ReadObjectHandlePointerNoCheck(Handle);
79#endif
80 }
81
82#if UE_WITH_OBJECT_HANDLE_LATE_RESOLVE
84 {
85 return { Handle.PointerOrRef };
86 }
87#endif
88
89 inline UClass* ResolveObjectHandleClass(FObjectHandle Handle)
90 {
91#if UE_WITH_OBJECT_HANDLE_LATE_RESOLVE
92 if (IsObjectHandleResolved(Handle))
93 {
94 UObject* Obj = ReadObjectHandlePointerNoCheck(Handle);
95 return Obj != nullptr ? Obj->GetClass() : nullptr;
96 }
97 else
98 {
99 // @TODO: OBJPTR: This should be cached somewhere instead of resolving on every call
100 FPackedObjectRef PackedObjectRef = ReadObjectHandlePackedObjectRefNoCheck(Handle);
101 FObjectRef ObjectRef = MakeObjectRef(PackedObjectRef);
102 return ObjectRef.ResolveObjectRefClass();
103 }
104#else
105 UObject* Obj = ReadObjectHandlePointerNoCheck(Handle);
106 return Obj != nullptr ? Obj->GetClass() : nullptr;
107#endif
108 }
109
110 inline UObject* ResolveObjectHandleNoRead(FObjectHandle& Handle)
111 {
112#if UE_WITH_OBJECT_HANDLE_LATE_RESOLVE
113 FObjectHandle LocalHandle = Handle;
114 if (IsObjectHandleResolved(LocalHandle))
115 {
116 UObject* ResolvedObject = ReadObjectHandlePointerNoCheck(LocalHandle);
117 return ResolvedObject;
118 }
119 else
120 {
121 FPackedObjectRef PackedObjectRef = ReadObjectHandlePackedObjectRefNoCheck(LocalHandle);
122 FObjectRef ObjectRef = MakeObjectRef(PackedObjectRef);
123 UObject* ResolvedObject = ObjectRef.Resolve();
124 Handle = MakeObjectHandle(ResolvedObject);
125 return ResolvedObject;
126 }
127#else
128 return ReadObjectHandlePointerNoCheck(Handle);
129#endif
130 }
131
132
133 inline UObject* ResolveObjectHandleNoReadNoCheck(FObjectHandle& Handle)
134 {
135#if UE_WITH_OBJECT_HANDLE_LATE_RESOLVE
136 FObjectHandle LocalHandle = Handle;
137 FPackedObjectRef PackedObjectRef = ReadObjectHandlePackedObjectRefNoCheck(LocalHandle);
138 FObjectRef ObjectRef = MakeObjectRef(PackedObjectRef);
139 UObject* ResolvedObject = ObjectRef.Resolve();
140 LocalHandle = MakeObjectHandle(ResolvedObject);
141 Handle = LocalHandle;
142 return ResolvedObject;
143#else
144 return ReadObjectHandlePointerNoCheck(Handle);
145#endif
146 }
147
148 inline UObject* ReadObjectHandlePointerNoCheck(FObjectHandle Handle)
149 {
150#if UE_WITH_OBJECT_HANDLE_LATE_RESOLVE
151 return reinterpret_cast<UObject*>(Handle.PointerOrRef);
152#else
153 return Handle;
154#endif
155 }
156
157 //Natvis structs
159 {
164 };
165
167 {
170 };
171
172 constexpr uint32 PackageIdShift = 33;
173 constexpr uint32 ObjectPathIdShift = 1;
174 constexpr uint32 ObjectPathIdMask = 0x00FF'FFFF;
175 constexpr uint32 DataClassDescriptorIdShift = 25;
176 constexpr uint32 DataClassDescriptorIdMask = 0x0000'00FF;
177 constexpr uint32 PackageIdMask = 0x7FFF'FFFF;
178
179#if UE_WITH_OBJECT_HANDLE_LATE_RESOLVE
180 //forward declarations
185#endif
186}
187
189{
190private:
191
192public:
195 {
196 }
197
199 {
200 }
201
202 FORCEINLINE FObjectPtr(TYPE_OF_NULLPTR)
204 {
205 }
206
209 {
210 }
211
212 UE_OBJPTR_DEPRECATED(5.0, "Construction with incomplete type pointer is deprecated. Please update this code to use MakeObjectPtrUnsafe.")
213 explicit FORCEINLINE FObjectPtr(void* IncompleteObject)
215 {
216 }
217
218#if UE_WITH_OBJECT_HANDLE_LATE_RESOLVE
220 : Handle(Handle)
221 {
222 }
223#endif
224
225
227 {
228 return UE::CoreUObject::Private::ResolveObjectHandle(Handle);
229 }
230
232 {
233 return UE::CoreUObject::Private::ResolveObjectHandleClass(Handle);
234 }
235
236 FObjectPtr(FObjectPtr&&) = default;
237 FObjectPtr(const FObjectPtr&) = default;
239 FObjectPtr& operator=(const FObjectPtr&) = default;
240
242 {
243 Handle = UE::CoreUObject::Private::MakeObjectHandle(Other);
244 return *this;
245 }
246
247 UE_OBJPTR_DEPRECATED(5.0, "Assignment with incomplete type pointer is deprecated. Please update this code to use MakeObjectPtrUnsafe.")
248 FObjectPtr& operator=(void* IncompleteOther)
249 {
250 Handle = UE::CoreUObject::Private::MakeObjectHandle(reinterpret_cast<UObject*>(IncompleteOther));
251 return *this;
252 }
253
254 FObjectPtr& operator=(TYPE_OF_NULLPTR)
255 {
256 Handle = UE::CoreUObject::Private::MakeObjectHandle(nullptr);
257 return *this;
258 }
259
260 FORCEINLINE bool operator==(FObjectPtr Other) const { return (Handle == Other.Handle); }
261 FORCEINLINE bool operator!=(FObjectPtr Other) const { return (Handle != Other.Handle); }
262
263 UE_OBJPTR_DEPRECATED(5.0, "Use of ToTObjectPtr is unsafe and is deprecated.")
265 UE_OBJPTR_DEPRECATED(5.0, "Use of ToTObjectPtr is unsafe and is deprecated.")
267
268 FORCEINLINE UObject* operator->() const { return Get(); }
269 FORCEINLINE UObject& operator*() const { return *Get(); }
270
271 UE_DEPRECATED(5.1, "IsNull is deprecated, please use operator bool instead.")
272 FORCEINLINE bool IsNull() const { return UE::CoreUObject::Private::ResolveObjectHandleNoRead(Handle) == nullptr; }
273
274 UE_DEPRECATED(5.1, "IsNullNoResolve is deprecated, please use operator bool instead.")
275 FORCEINLINE bool IsNullNoResolve() const { return IsObjectHandleNull(Handle); }
276
277 FORCEINLINE bool operator!() const { return IsObjectHandleNull(Handle); }
278 explicit FORCEINLINE operator bool() const { return !IsObjectHandleNull(Handle); }
279
280 FORCEINLINE bool IsResolved() const { return IsObjectHandleResolved(Handle); }
281
282 // Gets the PathName of the object without resolving the object reference.
283 // @TODO OBJPTR: Deprecate this.
284 FString GetPath() const { return GetPathName(); }
285
286#if UE_WITH_OBJECT_HANDLE_LATE_RESOLVE
287 // Gets the PathName of the object without resolving the object reference.
289
290 // Gets the FName of the object without resolving the object reference.
292
293 // Gets the string name of the object without resolving the object reference.
295 {
296 return GetFName().ToString();
297 }
298
299 /** Returns the full name for the object in the form: Class ObjectPath */
301#else
303 {
304 const UObject* ResolvedObject = Get();
305 return ResolvedObject ? ResolvedObject->GetPathName() : TEXT("None");
306 }
307
309 {
310 const UObject* ResolvedObject = Get();
311 return ResolvedObject ? ResolvedObject->GetFName() : NAME_None;
312 }
313
315 {
316 return GetFName().ToString();
317 }
318
319 /**
320 * Returns the fully qualified pathname for this object as well as the name of the class, in the format:
321 * 'ClassName Outermost.[Outer:]Name'.
322 */
323 FString GetFullName(EObjectFullNameFlags Flags = EObjectFullNameFlags::None) const
324 {
325 // UObjectBaseUtility::GetFullName is safe to call on null objects.
326 return Get()->GetFullName(nullptr, Flags);
327 }
328#endif
329
330 FORCEINLINE FObjectHandle GetHandle() const { return Handle; }
331 FORCEINLINE FObjectHandle& GetHandleRef() const { return Handle; }
332
333 FORCEINLINE bool IsA(const UClass* SomeBase) const
334 {
335 checkfSlow(SomeBase, TEXT("IsA(NULL) cannot yield meaningful results"));
336
337 if (const UClass* ThisClass = GetClass())
338 {
339 return ThisClass->IsChildOf(SomeBase);
340 }
341
342 return false;
343 }
344
345 template <typename T>
346 FORCEINLINE bool IsA() const
347 {
348 return IsA(T::StaticClass());
349 }
350
351private:
352 friend FORCEINLINE uint32 GetTypeHash(const FObjectPtr& Object)
353 {
354 return GetTypeHash(Object.Handle);
355 }
356
357 union
358 {
359 mutable FObjectHandle Handle;
360 // DebugPtr allows for easier dereferencing of a resolved FObjectPtr in watch windows of debuggers. If the address in the pointer
361 // is an odd/uneven number, that means the object reference is unresolved and you will not be able to dereference it successfully.
363 };
364};
365
366template <typename T>
367struct TPrivateObjectPtr;
368
369template <typename T>
371{
372 enum { Value = false };
373};
374
376{
377 /** Coerce to pointer through implicit conversion to const T* (overload through less specific "const T*" parameter to avoid ambiguity with other coercion options that may also exist. */
378 template <typename T>
379 FORCEINLINE const T* CoerceToPointer(const T* Other)
380 {
381 return Other;
382 }
383
385 /**
386 * Force acceptance of explicitly TYPE_OF_NULL to avoid ambiguity issues triggered by the presence of a type conversion operator to bool.
387 * This has the negative consequence of making it possible to coerce an arbitrary integer for the purpose of use in the comparison operators.
388 */
389 template <typename T>
390 UE_OBJPTR_DEPRECATED(5.0, "Coercing a NULL for operations with a TObjectPtr is deprecated when running in a non-standards conforming compiler mode.")
391 constexpr const T* CoerceToPointer(TYPE_OF_NULL Other)
392 {
393 checkfSlow(Other == 0, TEXT("TObjectPtr cannot be compared to a non-zero NULL type value."));
394 return nullptr;
395 }
396#endif
397
398 /** Coerce to pointer through implicit conversion to CommonPointerType where CommonPointerType is deduced, and must be a C++ pointer, not a wrapper type. */
399 template <
400 typename T,
401 typename U,
402 typename CommonPointerType = decltype(std::declval<bool>() ? std::declval<const T*>() : std::declval<U>()),
403 std::enable_if_t<
404 std::is_pointer<CommonPointerType>::value
405 >* = nullptr
406 >
407 FORCEINLINE auto CoerceToPointer(U&& Other) -> CommonPointerType
408 {
409 return Other;
410 }
411
412 /** Coerce to pointer through the use of a ".Get()" member, which is the convention within Unreal smart pointer types. */
413 template <
414 typename T,
415 typename U,
416 std::enable_if_t<
417 !TIsTObjectPtr<std::decay_t<U>>::Value,
418 decltype(std::declval<U>().Get())
419 >* = nullptr
420 >
421 FORCEINLINE auto CoerceToPointer(U&& Other) -> decltype(std::declval<U>().Get())
422 {
423 return Other.Get();
424 }
425
426 template <typename T, typename U>
427 bool IsObjectPtrEqualToRawPtrOfRelatedType(const TObjectPtr<T>& Ptr, const U* Other)
428 {
429#if UE_WITH_OBJECT_HANDLE_LATE_RESOLVE
430 if (Ptr.IsResolved())
431 {
432 return Ptr.GetNoResolveNoCheck() == Other;
433 }
434 else if (!Other) //avoids resolving if Other is null
435 {
436 return !Ptr;
437 }
438#endif
439 return Ptr.GetNoReadNoCheck() == Other;
440 }
441
442 /** Perform shallow equality check between a TObjectPtr and another (non TObjectPtr) type that we can coerce to a pointer. */
443 template <
444 typename T,
445 typename U,
446 std::enable_if_t<
447 !TIsTObjectPtr<std::decay_t<U>>::Value,
448 decltype(CoerceToPointer<T>(std::declval<U>()) == std::declval<const T*>())
449 >* = nullptr
450 >
451 bool IsObjectPtrEqual(const TObjectPtr<T>& Ptr, U&& Other)
452 {
453 // This function deliberately avoids the tracking code path as we are only doing
454 // a shallow pointer comparison.
456 }
457
458 template <typename T, int = sizeof(T)>
459 char (&ResolveTypeIsComplete(int))[2];
460
461 template <typename T>
462 char (&ResolveTypeIsComplete(...))[1];
463
464 struct Friend;
465};
466
467/**
468 * TObjectPtr is a type of pointer to a UObject that is meant to function as a drop-in replacement for raw pointer
469 * member properties. It is size equivalent to a 64-bit pointer and supports access tracking and optional lazy load
470 * behavior in editor builds. It stores either the address to the referenced object or (in editor builds) an index in
471 * the object handle table that describes a referenced object that hasn't been loaded yet. It is serialized
472 * identically to a raw pointer to a UObject. When resolved, its participation in garbage collection is identical to a
473 * raw pointer to a UObject.
474 *
475 * This is useful for automatic replacement of raw pointers to support advanced cook-time dependency tracking and
476 * editor-time lazy load use cases. See UnrealObjectPtrTool for tooling to automatically replace raw pointer members
477 * with FObjectPtr/TObjectPtr members instead.
478 */
479template <typename T>
480struct TObjectPtr
481{
482#ifndef PLATFORM_COMPILER_IWYU
483 // TObjectPtr should only be used on types T that are EITHER:
484 // - incomplete (ie: forward declared and we have not seen their definition yet)
485 // - complete and derived from UObject
486 // This means that the following are invalid and must fail to compile:
487 // - TObjectPtr<int>
488 // - TObjectPtr<IInterface>
489 static_assert(std::disjunction<std::negation<std::bool_constant<sizeof(ObjectPtr_Private::ResolveTypeIsComplete<T>(1)) == 2>>, std::is_base_of<UObject, T>>::value, "TObjectPtr<T> can only be used with types derived from UObject");
490#endif
491
492public:
493 using ElementType = T;
494
496 : ObjectPtr()
497 {
498 }
499
500 TObjectPtr(TObjectPtr<T>&& Other) = default;
501 TObjectPtr(const TObjectPtr<T>& Other) = default;
502
505 {
506 }
507
508 FORCEINLINE TObjectPtr(TYPE_OF_NULLPTR)
509 : ObjectPtr(nullptr)
510 {
511 }
512
513 template <
514 typename U,
515 decltype(ImplicitConv<T*>(std::declval<U*>()))* = nullptr
516 >
519 {
521 }
522
523 template <
524 typename U,
525 std::enable_if_t<
526 !TIsTObjectPtr<std::decay_t<U>>::Value,
527 decltype(ImplicitConv<T*>(std::declval<U>()))
528 >* = nullptr
529 >
531 : ObjectPtr(const_cast<std::remove_const_t<T>*>(ImplicitConv<T*>(Object)))
532 {
533 }
534
535 explicit FORCEINLINE TObjectPtr(TPrivateObjectPtr<T>&& PrivatePtr)
536 : ObjectPtr(const_cast<UObject*>(PrivatePtr.Pointer))
537 {
538 }
539
540 TObjectPtr<T>& operator=(TObjectPtr<T>&&) = default;
541 TObjectPtr<T>& operator=(const TObjectPtr<T>&) = default;
542
543 FORCEINLINE TObjectPtr<T>& operator=(TYPE_OF_NULLPTR)
544 {
545 ObjectPtr = nullptr;
546 return *this;
547 }
548
549 template <
550 typename U,
551 decltype(ImplicitConv<T*>(std::declval<U*>()))* = nullptr
552 >
554 {
557 return *this;
558 }
559
560 template <
561 typename U,
562 std::enable_if_t<
563 !TIsTObjectPtr<std::decay_t<U>>::Value,
564 decltype(ImplicitConv<T*>(std::declval<U>()))
565 >* = nullptr
566 >
568 {
569 ObjectPtr = const_cast<std::remove_const_t<T>*>(ImplicitConv<T*>(Object));
570 return *this;
571 }
572
573 FORCEINLINE TObjectPtr<T>& operator=(TPrivateObjectPtr<T>&& PrivatePtr)
574 {
575 ObjectPtr = const_cast<UObject*>(PrivatePtr.Pointer);
576 return *this;
577 }
578
579 // Equality/Inequality comparisons against other TObjectPtr
580 template <
581 typename U,
582 typename Base = std::decay_t<decltype(false ? std::declval<std::decay_t<T*>>() : std::declval<std::decay_t<U*>>())>
583 >
584 FORCEINLINE bool operator==(const TObjectPtr<U>& Other) const
585 {
586 return ObjectPtr == Other.ObjectPtr;
587 }
588
589 // Equality/Inequality comparisons against nullptr
590 FORCEINLINE bool operator==(TYPE_OF_NULLPTR) const
591 {
592 return !ObjectPtr.operator bool();
593 }
594
595 // Equality/Inequality comparisons against another type that can be implicitly converted to the pointer type kept in a TObjectPtr
596 template <
597 typename U,
598 typename = decltype(ObjectPtr_Private::IsObjectPtrEqual(std::declval<const TObjectPtr<T>&>(), std::declval<U&&>()))
599 >
600 FORCEINLINE bool operator==(U&& Other) const
601 {
603 }
604
605#if __cplusplus < 202002L
606 template <
607 typename U,
608 typename Base = std::decay_t<decltype(false ? std::declval<std::decay_t<T*>>() : std::declval<std::decay_t<U*>>())>
609 >
610 FORCEINLINE bool operator!=(const TObjectPtr<U>& Other) const
611 {
612 return ObjectPtr != Other.ObjectPtr;
613 }
614
615 FORCEINLINE bool operator!=(TYPE_OF_NULLPTR) const
616 {
617 return ObjectPtr.operator bool();
618 }
619
620 template <
621 typename U,
622 typename = decltype(ObjectPtr_Private::IsObjectPtrEqual(std::declval<const TObjectPtr<T>&>(), std::declval<U&&>()))
623 >
624 FORCEINLINE bool operator!=(U&& Other) const
625 {
627 }
628#endif
629
630 // @TODO: OBJPTR: There is a risk that the FObjectPtr is storing a reference to the wrong type. This could
631 // happen if data was serialized at a time when a pointer field was declared to be of type A, but then the declaration
632 // changed and the pointer field is now of type B. Upon deserialization of pre-existing data, we'll be holding
633 // a reference to the wrong type of object which we'll just send back static_casted as the wrong type. Doing
634 // a check or checkSlow here could catch this, but it would be better if the check could happen elsewhere that
635 // isn't called as frequently.
636 FORCEINLINE T* Get() const { return (T*)(ObjectPtr.Get()); }
638
639 FORCEINLINE operator T* () const { return Get(); }
640 template <typename U>
641 UE_OBJPTR_DEPRECATED(5.0, "Explicit cast to other raw pointer types is deprecated. Please use the Cast API or get the raw pointer with ToRawPtr and cast that instead.")
642 explicit FORCEINLINE operator U* () const { return (U*)Get(); }
643 explicit FORCEINLINE operator UPTRINT() const { return (UPTRINT)Get(); }
644 FORCEINLINE T* operator->() const { return Get(); }
645 FORCEINLINE T& operator*() const { return *Get(); }
646
647 UE_OBJPTR_DEPRECATED(5.0, "Conversion to a mutable pointer is deprecated. Please pass a TObjectPtr<T>& instead so that assignment can be tracked accurately.")
648 explicit FORCEINLINE operator T*& () { return GetInternalRef(); }
649
650 UE_DEPRECATED(5.1, "IsNull is deprecated, please use operator bool instead. if (!MyObjectPtr) { ... }")
651 FORCEINLINE bool IsNull() const { return !ObjectPtr.operator bool(); }
652
653 UE_DEPRECATED(5.1, "IsNullNoResolve is deprecated, please use operator bool instead. if (!MyObjectPtr) { ... }")
654 FORCEINLINE bool IsNullNoResolve() const { return !ObjectPtr.operator bool(); }
655
656 FORCEINLINE bool operator!() const { return ObjectPtr.operator!(); }
657 explicit FORCEINLINE operator bool() const { return ObjectPtr.operator bool(); }
658 FORCEINLINE bool IsResolved() const { return ObjectPtr.IsResolved(); }
663 FORCEINLINE FString GetFullName(EObjectFullNameFlags Flags = EObjectFullNameFlags::None) const { return ObjectPtr.GetFullName(Flags); }
664 FORCEINLINE FObjectHandle GetHandle() const { return ObjectPtr.GetHandle(); }
665 FORCEINLINE bool IsA(const UClass* SomeBase) const { return ObjectPtr.IsA(SomeBase); }
666 template <typename U> FORCEINLINE bool IsA() const { return ObjectPtr.IsA<U>(); }
667
669 {
670 return GetTypeHash(ObjectPtr);
671 }
672
673 FORCEINLINE void SerializePtrStructured(FStructuredArchiveSlot Slot)
674 {
675 Slot << ObjectPtr;
676 }
677
679 friend struct FObjectPtr;
680 template <typename U> friend struct TObjectPtr;
681 template <typename U, typename V> friend bool ObjectPtr_Private::IsObjectPtrEqualToRawPtrOfRelatedType(const TObjectPtr<U>& Ptr, const V* Other);
682
683private:
686
687 // @TODO: OBJPTR: There is a risk of a gap in access tracking here. The caller may get a mutable pointer, write to it, then
688 // read from it. That last read would happen without an access being recorded. Not sure if there is a good way
689 // to handle this case without forcing the calling code to be modified.
691 {
692 ObjectPtr.Get();
693 return (T*&)ObjectPtr.GetHandleRef();
694 }
695
696 union
697 {
699 // DebugPtr allows for easier dereferencing of a resolved TObjectPtr in watch windows of debuggers. If the address in the pointer
700 // is an odd/uneven number, that means the object reference is unresolved and you will not be able to dereference it successfully.
702 };
703};
704
705// Equals against nullptr to optimize comparing against nullptr as it avoids resolving
706
707template <typename T> struct TIsTObjectPtr< TObjectPtr<T>> { enum { Value = true }; };
708template <typename T> struct TIsTObjectPtr<const TObjectPtr<T>> { enum { Value = true }; };
709template <typename T> struct TIsTObjectPtr< volatile TObjectPtr<T>> { enum { Value = true }; };
710template <typename T> struct TIsTObjectPtr<const volatile TObjectPtr<T>> { enum { Value = true }; };
711
712template <typename T>
714{
715 typedef T Type;
716};
717template <typename T>
719{
720 typedef T Type;
721};
722
723namespace ObjectPtr_Private
724{
725 template <typename T> struct TRawPointerType { using Type = T; };
726 template <typename T> struct TRawPointerType< TObjectPtr<T>> { using Type = T*; };
727 template <typename T> struct TRawPointerType<const TObjectPtr<T>> { using Type = T*; };
728 template <typename T> struct TRawPointerType< volatile TObjectPtr<T>> { using Type = T*; };
729 template <typename T> struct TRawPointerType<const volatile TObjectPtr<T>> { using Type = T*; };
730 struct Friend
731 {
732 template <typename T>
733 FORCEINLINE static uint32 GetPtrTypeHash(const TObjectPtr<T>& InObjectPtr)
734 {
736 }
737
738 template <typename T>
739 FORCEINLINE static FArchive& Serialize(FArchive& Ar, TObjectPtr<T>& InObjectPtr)
740 {
742 return Ar;
743 }
744
745 template <typename T>
746 FORCEINLINE static void SerializePtrStructured(FStructuredArchiveSlot Slot, TObjectPtr<T>& InObjectPtr)
747 {
749 }
750 };
751}
752
753template <typename T>
754FORCEINLINE uint32 GetTypeHash(const TObjectPtr<T>& InObjectPtr)
755{
756 return ObjectPtr_Private::Friend::GetPtrTypeHash(InObjectPtr);
757}
758
759template <typename T>
760FORCEINLINE FArchive& operator<<(FArchive& Ar, TObjectPtr<T>& InObjectPtr)
761{
762 return ObjectPtr_Private::Friend::Serialize(Ar, InObjectPtr);
763}
764
765template <typename T>
766FORCEINLINE void operator<<(FStructuredArchiveSlot Slot, TObjectPtr<T>& InObjectPtr)
767{
768 ObjectPtr_Private::Friend::SerializePtrStructured(Slot, InObjectPtr);
769}
770
772// Equality/Inequality comparisons against another type that can be implicitly converted to the pointer type kept in a TObjectPtr
773template <
774 typename T,
775 typename U,
776 decltype(ObjectPtr_Private::IsObjectPtrEqual(std::declval<const TObjectPtr<T>&>(), std::declval<U&&>()))* = nullptr
777>
778FORCEINLINE bool operator==(U&& Other, const TObjectPtr<T>& Ptr)
779{
780 return ObjectPtr_Private::IsObjectPtrEqual(Ptr, Other);
781}
782template <
783 typename T,
784 typename U,
785 decltype(ObjectPtr_Private::IsObjectPtrEqual(std::declval<const TObjectPtr<T>&>(), std::declval<U&&>()))* = nullptr
786>
787FORCEINLINE bool operator!=(U&& Other, const TObjectPtr<T>& Ptr)
788{
789 return !ObjectPtr_Private::IsObjectPtrEqual(Ptr, Other);
790}
791#endif
792
793template <typename T>
794TPrivateObjectPtr<T> MakeObjectPtrUnsafe(const UObject* Obj);
795
796template <typename T>
797struct TPrivateObjectPtr
798{
799public:
800 TPrivateObjectPtr(const TPrivateObjectPtr<T>& Other) = default;
801
802private:
803 /** Only for use by MakeObjectPtrUnsafe */
804 explicit TPrivateObjectPtr(const UObject* InPointer)
805 : Pointer(InPointer)
806 {
807 }
808
810 friend struct TObjectPtr<T>;
811 friend TPrivateObjectPtr MakeObjectPtrUnsafe<T>(const UObject* Obj);
812};
813
814/** Used to allow the caller to provide a pointer to an incomplete type of T that has explicitly cast to a UObject. */
815template <typename T>
816TPrivateObjectPtr<T> MakeObjectPtrUnsafe(const UObject* Obj)
817{
818 return TPrivateObjectPtr<T>{Obj};
819}
820
821template <typename T>
823{
824 return TObjectPtr<T>{Obj};
825}
826
827template <typename T>
829{
830 // NOTE: This is specifically not getting a reference to the internal pointer.
831 return Ptr.Get();
832}
833
834template <typename T>
836{
837 return Ptr;
838}
839
840template <typename T, SIZE_T Size>
842{
843#if UE_WITH_OBJECT_HANDLE_LATE_RESOLVE || UE_WITH_OBJECT_HANDLE_TRACKING
844 for (TObjectPtr<T>& Item : ArrayOfPtr)
845 {
846 // NOTE: Relying on the fact that the TObjectPtr will cache the resolved pointer in place after calling Get.
847 Item.Get();
848 }
849#endif
850 return reinterpret_cast<T**>(ArrayOfPtr);
851}
852
853template <typename T>
855{
856 return ArrayOfPtr;
857}
858
860template <
861 typename ArrayType,
862 typename ArrayTypeNoRef = std::remove_reference_t<ArrayType>,
863 std::enable_if_t<TIsTArray<ArrayTypeNoRef>::Value>* = nullptr
864>
865decltype(auto) ToRawPtrTArrayUnsafe(ArrayType&& Array)
866{
867 using ArrayElementType = typename ArrayTypeNoRef::ElementType;
868 using ArrayAllocatorType = typename ArrayTypeNoRef::AllocatorType;
869 using RawPointerType = typename ObjectPtr_Private::TRawPointerType<ArrayElementType>::Type;
870 using QualifiedRawPointerType = typename TCopyQualifiersFromTo<ArrayElementType, RawPointerType>::Type;
871 using NewArrayType = TArray<QualifiedRawPointerType, ArrayAllocatorType>;
872 using RefQualifiedNewArrayType = typename TCopyQualifiersAndRefsFromTo<ArrayType, NewArrayType>::Type;
873
874 return (RefQualifiedNewArrayType&)Array;
875}
877
878template <typename T>
880{
881 typedef T* ReinterpretType;
883
884 template <typename IterBeginType, typename IterEndType, typename OperatorType = std::remove_reference_t<decltype(*std::declval<IterBeginType>())>& (*)(IterBeginType&)>
885 UE_OBJPTR_DEPRECATED(5.0, "Reinterpretation between ranges of one type to another type is deprecated.")
886 static void ReinterpretRange(IterBeginType Iter, IterEndType IterEnd, OperatorType Operator = [](IterBeginType& InIt) -> decltype(auto) { return *InIt; })
887 {
888#if UE_WITH_OBJECT_HANDLE_LATE_RESOLVE || UE_WITH_OBJECT_HANDLE_TRACKING
889 while (Iter != IterEnd)
890 {
891 Operator(Iter).Get();
892 ++Iter;
893 }
894#endif
895 }
896
897 template <typename IterBeginType, typename IterEndType, typename SizeType, typename OperatorType = std::remove_reference_t<decltype(*std::declval<IterBeginType>())>& (*)(IterBeginType&)>
898 UE_OBJPTR_DEPRECATED(5.0, "Reinterpretation between ranges of one type to another type is deprecated.")
899 static void ReinterpretRangeContiguous(IterBeginType Iter, IterEndType IterEnd, SizeType Size, OperatorType Operator = [](IterBeginType& InIt) -> decltype(auto) { return *InIt; })
900 {
901#if UE_WITH_OBJECT_HANDLE_LATE_RESOLVE || UE_WITH_OBJECT_HANDLE_TRACKING
902 const TObjectPtr<T>* Begin = &*Iter;
903 while (Iter != IterEnd)
904 {
905 auto& Ptr = Operator(Iter);
906 const FObjectPtr& ObjPtr = reinterpret_cast<const FObjectPtr&>(Ptr);
908 ++Iter;
909 }
910 const UObject* const* ObjPtr = reinterpret_cast<const UObject* const*>(Begin);
912#endif
913 }
914
915 UE_OBJPTR_DEPRECATED(5.0, "Copying ranges of one type to another type is deprecated.")
916 static constexpr void CopyingFromOtherType() {}
917};
918
919template <typename T>
921{
922 typedef T* const ReinterpretType;
923 typedef T* const CopyFromOtherType;
924
925 template <typename IterBeginType, typename IterEndType, typename OperatorType = const std::remove_cv_t<std::remove_reference_t<decltype(*std::declval<IterBeginType>())>>&(*)(IterBeginType&)>
926 UE_OBJPTR_DEPRECATED(5.0, "Reinterpretation between ranges of one type to another type is deprecated.")
927 static void ReinterpretRange(IterBeginType Iter, IterEndType IterEnd, OperatorType Operator = [](IterBeginType& InIt) -> decltype(auto) { return *InIt; })
928 {
929#if UE_WITH_OBJECT_HANDLE_LATE_RESOLVE || UE_WITH_OBJECT_HANDLE_TRACKING
930 while (Iter != IterEnd)
931 {
932 Operator(Iter).Get();
933 ++Iter;
934 }
935#endif
936 }
937
938 template <typename IterBeginType, typename IterEndType, typename SizeType, typename OperatorType = std::remove_reference_t<decltype(*std::declval<IterBeginType>())>& (*)(IterBeginType&)>
939 UE_OBJPTR_DEPRECATED(5.0, "Reinterpretation between ranges of one type to another type is deprecated.")
940 static void ReinterpretRangeContiguous(IterBeginType Iter, IterEndType IterEnd, SizeType Size, OperatorType Operator = [](IterBeginType& InIt) -> decltype(auto) { return *InIt; })
941 {
942#if UE_WITH_OBJECT_HANDLE_LATE_RESOLVE || UE_WITH_OBJECT_HANDLE_TRACKING
943 const TObjectPtr<T>* Begin = &*Iter;
944 while (Iter != IterEnd)
945 {
946 auto& Ptr = Operator(Iter);
947 const FObjectPtr& ObjPtr = reinterpret_cast<const FObjectPtr&>(Ptr);
949 ++Iter;
950 }
951 const UObject* const* ObjPtr = reinterpret_cast<const UObject* const*>(Begin);
953#endif
954 }
955
956 UE_OBJPTR_DEPRECATED(5.0, "Copying ranges of one type to another type is deprecated.")
957 static constexpr void CopyingFromOtherType() {}
958};
959
960// Trait which allows TObjectPtr to be default constructed by memsetting to zero.
961template <typename T>
963{
964 enum { Value = true };
965};
966
967// Trait which allows TObjectPtr to be memcpy'able from pointers.
968template <typename T>
970{
971 enum { Value = true };
972};
973
974template <typename T, class PREDICATE_CLASS>
975struct TDereferenceWrapper<TObjectPtr<T>, PREDICATE_CLASS>
976{
977 const PREDICATE_CLASS& Predicate;
978
979 TDereferenceWrapper(const PREDICATE_CLASS& InPredicate)
981
982 /** Dereference pointers */
983 FORCEINLINE bool operator()(const TObjectPtr<T>& A, const TObjectPtr<T>& B) const
984 {
985 return Predicate(*A, *B);
986 }
987};
988
989template <typename T>
991{
992 using ConstPointerType = typename TCallTraitsParamTypeHelper<const TObjectPtr<const T>, true>::ConstParamType;
993};
994
995
996template <typename T>
998{
999 return TWeakObjectPtr<T>(Ptr);
1000}
1001
1003{
1004 return *reinterpret_cast<TObjectPtr<UObject>*>(this);
1005}
1006
1008{
1009 return *reinterpret_cast<const TObjectPtr<UObject>*>(this);
1010}
1011
1012/** Swap variants between TObjectPtr<T> and raw pointer to T */
1013template <typename T>
1014inline void Swap(TObjectPtr<T>& A, T*& B)
1015{
1016 Swap((T*&)A, B);
1017}
1018template <typename T>
1019inline void Swap(T*& A, TObjectPtr<T>& B)
1020{
1021 Swap(A, (T*&)B);
1022}
1023
1024/** Swap variants between TArray<TObjectPtr<T>> and TArray<T*> */
1025template <typename T>
1026inline void Swap(TArray<TObjectPtr<T>>& A, TArray<T*>& B)
1027{
1028 Swap(ToRawPtrTArrayUnsafe(A), B);
1029}
1030template <typename T>
1031inline void Swap(TArray<T*>& A, TArray<TObjectPtr<T>>& B)
1032{
1033 Swap(A, ToRawPtrTArrayUnsafe(B));
1034}
1035
1036/** Exchange variants between TObjectPtr<T> and raw pointer to T */
1037template <typename T>
1038inline void Exchange(TObjectPtr<T>& A, T*& B)
1039{
1040 Swap((T*&)A, B);
1041}
1042template <typename T>
1043inline void Exchange(T*& A, TObjectPtr<T>& B)
1044{
1045 Swap(A, (T*&)B);
1046}
1047
1048/** Exchange variants between TArray<TObjectPtr<T>> and TArray<T*> */
1049template <typename T>
1050inline void Exchange(TArray<TObjectPtr<T>>& A, TArray<T*>& B)
1051{
1052 Swap(ToRawPtrTArrayUnsafe(A), B);
1053}
1054template <typename T>
1055inline void Exchange(TArray<T*>& A, TArray<TObjectPtr<T>>& B)
1056{
1057 Swap(A, ToRawPtrTArrayUnsafe(B));
1058}
1059
1060/**
1061 * Returns a pointer to a valid object if the Test object passes IsValid() tests, otherwise null
1062 */
1063template <typename T>
1064T* GetValid(const TObjectPtr<T>& Test)
1065{
1066 T* TestPtr = ToRawPtr(Test);
1067 return IsValid(TestPtr) ? TestPtr : nullptr;
1068}
1069
1070//------------------------------------------------------------------------------
1071// Suppose you want to have a function that outputs an array of either T*'s or TObjectPtr<T>'s
1072// this template will make that possible to encode,
1073//
1074// template<typename InstanceClass>
1075// void GetItemInstances(TArray<InstanceClass>& OutInstances) const
1076// {
1077// static_assert(TIsPointerOrObjectPtrToBaseOf<InstanceClass, UBaseClass>::Value, "Output array must contain pointers or TObjectPtrs to a base of UBaseClass");
1078// }
1079//------------------------------------------------------------------------------
1080
1081template <typename T, typename DerivedType>
1083{
1084 enum { Value = false };
1085};
1086
1087template <typename T, typename DerivedType>
1089{
1090 enum { Value = std::is_base_of_v<DerivedType, T> };
1091};
1092
1093template <typename T, typename DerivedType>
1095{
1096 enum { Value = std::is_base_of_v<DerivedType, T> };
1097};
1098
1099template <typename T, typename DerivedType>
1101{
1102 enum { Value = TIsPointerOrObjectPtrToBaseOfImpl<std::remove_cv_t<T>, DerivedType>::Value };
1103};
1104
1105//------------------------------------------------------------------------------
1106// Suppose now that you have a templated function that takes in an array of either
1107// UBaseClass*'s or TObjectPtr<UBaseClass>'s, and you need to use that inner UBaseClass type
1108// for coding,
1109//
1110// This is how you can refer to that inner class. Where InstanceClass is the template
1111// argument for where TIsPointerOrObjectPtrToBaseOf is used,
1112//
1113// TPointedToType<InstanceClass>* Thing = new TPointedToType<InstanceClass>();
1114//------------------------------------------------------------------------------
1115
1116template <typename T>
1117struct TPointedToTypeImpl;
1118
1119template <typename T>
1120struct TPointedToTypeImpl<T*>
1121{
1122 using Type = T;
1123};
1124
1125template <typename T>
1126struct TPointedToTypeImpl<TObjectPtr<T>>
1127{
1128 using Type = T;
1129};
1130
1131template <typename T>
1132using TPointedToType = typename TPointedToTypeImpl<T>::Type;
1133
1134//------------------------------------------------------------------------------
#define checkfSlow(expr, format,...)
#define UE_DEPRECATED(Version, Message)
T * ToRawPtr(const TObjectPtr< T > &Ptr)
Definition ObjectPtr.h:828
#define PRAGMA_ENABLE_DEPRECATION_WARNINGS
#define PRAGMA_DISABLE_DEPRECATION_WARNINGS
FORCEINLINE T ** ToRawPtrArrayUnsafe(T **ArrayOfPtr)
Definition ObjectPtr.h:854
FORCEINLINE bool operator==(U &&Other, const TObjectPtr< T > &Ptr)
Definition ObjectPtr.h:778
void Exchange(TArray< TObjectPtr< T > > &A, TArray< T * > &B)
Definition ObjectPtr.h:1050
T * GetValid(const TObjectPtr< T > &Test)
Definition ObjectPtr.h:1064
TObjectPtr< T > ToObjectPtr(T *Obj)
Definition ObjectPtr.h:822
void Exchange(TObjectPtr< T > &A, T *&B)
Definition ObjectPtr.h:1038
void Swap(TObjectPtr< T > &A, T *&B)
Definition ObjectPtr.h:1014
FORCEINLINE uint32 GetTypeHash(const TObjectPtr< T > &InObjectPtr)
Definition ObjectPtr.h:754
FORCEINLINE T * ToRawPtr(T *Ptr)
Definition ObjectPtr.h:835
FORCEINLINE T ** ToRawPtrArrayUnsafe(TObjectPtr< T >(&ArrayOfPtr)[Size])
Definition ObjectPtr.h:841
FORCEINLINE TWeakObjectPtr< T > MakeWeakObjectPtr(TObjectPtr< T > Ptr)
Definition ObjectPtr.h:997
#define UE_OBJECT_PTR_NONCONFORMANCE_SUPPORT
Definition ObjectPtr.h:44
FORCEINLINE bool operator!=(U &&Other, const TObjectPtr< T > &Ptr)
Definition ObjectPtr.h:787
void Swap(TArray< TObjectPtr< T > > &A, TArray< T * > &B)
Definition ObjectPtr.h:1026
#define UE_OBJPTR_DEPRECATED(Version, Message)
Definition ObjectPtr.h:17
PRAGMA_DISABLE_DEPRECATION_WARNINGS decltype(auto) ToRawPtrTArrayUnsafe(ArrayType &&Array)
Definition ObjectPtr.h:865
void Exchange(T *&A, TObjectPtr< T > &B)
Definition ObjectPtr.h:1043
#define UE_WITH_OBJECT_PTR_DEPRECATIONS
Definition ObjectPtr.h:13
TPrivateObjectPtr< T > MakeObjectPtrUnsafe(const UObject *Obj)
Definition ObjectPtr.h:816
void Swap(T *&A, TObjectPtr< T > &B)
Definition ObjectPtr.h:1019
FORCEINLINE void operator<<(FStructuredArchiveSlot Slot, TObjectPtr< T > &InObjectPtr)
Definition ObjectPtr.h:766
#define TEXT(x)
Definition Platform.h:1108
#define FORCEINLINE
Definition Platform.h:644
#define PLATFORM_COMPILER_HAS_GENERATED_COMPARISON_OPERATORS
Definition Platform.h:250
#define PLATFORM_MICROSOFT
Definition Platform.h:62
#define IWYU_MARKUP_IMPLICIT_CAST(From, To)
bool IsObjectPtrEqual(const TObjectPtr< T > &Ptr, U &&Other)
Definition ObjectPtr.h:451
char(& ResolveTypeIsComplete(...))[1]
char(& ResolveTypeIsComplete(int))[2]
bool IsObjectPtrEqualToRawPtrOfRelatedType(const TObjectPtr< T > &Ptr, const U *Other)
Definition ObjectPtr.h:427
FORCEINLINE auto CoerceToPointer(U &&Other) -> decltype(std::declval< U >().Get())
Definition ObjectPtr.h:421
FORCEINLINE const T * CoerceToPointer(const T *Other)
Definition ObjectPtr.h:379
FORCEINLINE auto CoerceToPointer(U &&Other) -> CommonPointerType
Definition ObjectPtr.h:407
UObject * ReadObjectHandlePointerNoCheck(FObjectHandle Handle)
Definition ObjectPtr.h:148
UObject * ResolveObjectHandleNoReadNoCheck(FObjectHandle &Handle)
Definition ObjectPtr.h:133
UObject * ResolveObjectHandleNoRead(FObjectHandle &Handle)
Definition ObjectPtr.h:110
constexpr uint32 ObjectPathIdShift
Definition ObjectPtr.h:173
constexpr uint32 DataClassDescriptorIdShift
Definition ObjectPtr.h:175
constexpr uint32 ObjectPathIdMask
Definition ObjectPtr.h:174
FObjectHandle MakeObjectHandle(UObject *Object)
Definition ObjectPtr.h:62
UObject * ResolveObjectHandle(FObjectHandle &Handle)
Definition ObjectPtr.h:71
constexpr uint32 DataClassDescriptorIdMask
Definition ObjectPtr.h:176
UClass * ResolveObjectHandleClass(FObjectHandle Handle)
Definition ObjectPtr.h:89
constexpr uint32 PackageIdMask
Definition ObjectPtr.h:177
constexpr uint32 PackageIdShift
Definition ObjectPtr.h:172
Definition Vector.h:40
Definition json.hpp:4518
FORCEINLINE bool operator!=(FObjectPtr Other) const
Definition ObjectPtr.h:261
FORCEINLINE UObject * Get() const
Definition ObjectPtr.h:226
FORCEINLINE FObjectPtr(UObject *Object)
Definition ObjectPtr.h:207
FORCEINLINE FObjectPtr(TYPE_OF_NULLPTR)
Definition ObjectPtr.h:202
FORCEINLINE operator bool() const
Definition ObjectPtr.h:278
FORCEINLINE FObjectHandle & GetHandleRef() const
Definition ObjectPtr.h:331
FString GetPath() const
Definition ObjectPtr.h:284
FORCEINLINE TObjectPtr< UObject > & ToTObjectPtr()
Definition ObjectPtr.h:1002
FORCEINLINE bool IsNullNoResolve() const
Definition ObjectPtr.h:275
FObjectPtr(ENoInit)
Definition ObjectPtr.h:198
UObject * DebugPtr
Definition ObjectPtr.h:362
FObjectPtr & operator=(UObject *Other)
Definition ObjectPtr.h:241
FORCEINLINE bool IsA(const UClass *SomeBase) const
Definition ObjectPtr.h:333
FORCEINLINE bool operator==(FObjectPtr Other) const
Definition ObjectPtr.h:260
FObjectHandle Handle
Definition ObjectPtr.h:359
FObjectPtr & operator=(FObjectPtr &&)=default
FORCEINLINE bool IsResolved() const
Definition ObjectPtr.h:280
FORCEINLINE UClass * GetClass() const
Definition ObjectPtr.h:231
FORCEINLINE FObjectHandle GetHandle() const
Definition ObjectPtr.h:330
FORCEINLINE bool operator!() const
Definition ObjectPtr.h:277
FORCEINLINE bool IsA() const
Definition ObjectPtr.h:346
FObjectPtr & operator=(const FObjectPtr &)=default
FORCEINLINE const TObjectPtr< UObject > & ToTObjectPtr() const
Definition ObjectPtr.h:1007
FName GetFName() const
Definition ObjectPtr.h:308
FObjectPtr(const FObjectPtr &)=default
FObjectPtr & operator=(void *IncompleteOther)
Definition ObjectPtr.h:248
FObjectPtr(FObjectPtr &&)=default
friend FORCEINLINE uint32 GetTypeHash(const FObjectPtr &Object)
Definition ObjectPtr.h:352
FString GetName() const
Definition ObjectPtr.h:314
FORCEINLINE FObjectPtr(void *IncompleteObject)
Definition ObjectPtr.h:213
FString GetFullName(EObjectFullNameFlags Flags=EObjectFullNameFlags::None) const
Definition ObjectPtr.h:323
FString GetPathName() const
Definition ObjectPtr.h:302
FORCEINLINE bool IsNull() const
Definition ObjectPtr.h:272
FORCEINLINE UObject * operator->() const
Definition ObjectPtr.h:268
FORCEINLINE UObject & operator*() const
Definition ObjectPtr.h:269
FObjectPtr & operator=(TYPE_OF_NULLPTR)
Definition ObjectPtr.h:254
static FORCEINLINE uint32 GetPtrTypeHash(const TObjectPtr< T > &InObjectPtr)
Definition ObjectPtr.h:733
static FORCEINLINE FArchive & Serialize(FArchive &Ar, TObjectPtr< T > &InObjectPtr)
Definition ObjectPtr.h:739
static FORCEINLINE void SerializePtrStructured(FStructuredArchiveSlot Slot, TObjectPtr< T > &InObjectPtr)
Definition ObjectPtr.h:746
static void ReinterpretRange(IterBeginType Iter, IterEndType IterEnd, OperatorType Operator=[](IterBeginType &InIt) -> decltype(auto) { return *InIt;})
Definition ObjectPtr.h:886
static void ReinterpretRangeContiguous(IterBeginType Iter, IterEndType IterEnd, SizeType Size, OperatorType Operator=[](IterBeginType &InIt) -> decltype(auto) { return *InIt;})
Definition ObjectPtr.h:899
static void ReinterpretRangeContiguous(IterBeginType Iter, IterEndType IterEnd, SizeType Size, OperatorType Operator=[](IterBeginType &InIt) -> decltype(auto) { return *InIt;})
Definition ObjectPtr.h:940
static void ReinterpretRange(IterBeginType Iter, IterEndType IterEnd, OperatorType Operator=[](IterBeginType &InIt) -> decltype(auto) { return *InIt;})
Definition ObjectPtr.h:927
TDereferenceWrapper(const PREDICATE_CLASS &InPredicate)
Definition ObjectPtr.h:979
FORCEINLINE bool operator()(const TObjectPtr< T > &A, const TObjectPtr< T > &B) const
Definition ObjectPtr.h:983
FORCEINLINE bool IsResolved() const
Definition ObjectPtr.h:658
FORCEINLINE TObjectPtr(U &&Object)
Definition ObjectPtr.h:530
FORCEINLINE FString GetPathName() const
Definition ObjectPtr.h:660
FORCEINLINE T *& GetInternalRef()
Definition ObjectPtr.h:690
FORCEINLINE TObjectPtr< T > & operator=(U &&Object)
Definition ObjectPtr.h:567
FORCEINLINE bool IsNull() const
Definition ObjectPtr.h:651
FORCEINLINE UClass * GetClass() const
Definition ObjectPtr.h:637
FORCEINLINE T * GetNoResolveNoCheck() const
Definition ObjectPtr.h:685
FORCEINLINE T * GetNoReadNoCheck() const
Definition ObjectPtr.h:684
FORCEINLINE TObjectPtr(const TObjectPtr< U > &Other)
Definition ObjectPtr.h:517
TObjectPtr< T > & operator=(const TObjectPtr< T > &)=default
FORCEINLINE TObjectPtr< T > & operator=(TPrivateObjectPtr< T > &&PrivatePtr)
Definition ObjectPtr.h:573
FORCEINLINE operator T*() const
Definition UE.h:134
FORCEINLINE T * operator->() const
Definition UE.h:131
FORCEINLINE bool operator!=(TYPE_OF_NULLPTR) const
Definition ObjectPtr.h:615
TObjectPtr(TObjectPtr< T > &&Other)=default
FORCEINLINE FString GetName() const
Definition ObjectPtr.h:662
FORCEINLINE TObjectPtr(TPrivateObjectPtr< T > &&PrivatePtr)
Definition ObjectPtr.h:535
FORCEINLINE bool operator==(const TObjectPtr< U > &Other) const
Definition ObjectPtr.h:584
FORCEINLINE bool operator!=(U &&Other) const
Definition ObjectPtr.h:624
FORCEINLINE operator bool() const
Definition UE.h:133
FORCEINLINE bool operator==(U &&Other) const
Definition ObjectPtr.h:600
FORCEINLINE bool operator==(TYPE_OF_NULLPTR) const
Definition ObjectPtr.h:590
FORCEINLINE FObjectHandle GetHandle() const
Definition ObjectPtr.h:664
FORCEINLINE operator T*&()
Definition ObjectPtr.h:648
FORCEINLINE bool operator!=(const TObjectPtr< U > &Other) const
Definition ObjectPtr.h:610
FORCEINLINE T * Get() const
Definition UE.h:130
FORCEINLINE bool IsA(const UClass *SomeBase) const
Definition ObjectPtr.h:665
FORCEINLINE bool operator!() const
Definition ObjectPtr.h:656
TObjectPtr(const TObjectPtr< T > &Other)=default
FORCEINLINE uint32 GetPtrTypeHash() const
Definition ObjectPtr.h:668
FORCEINLINE TObjectPtr< T > & operator=(const TObjectPtr< U > &Other)
Definition ObjectPtr.h:553
FORCEINLINE bool IsA() const
Definition ObjectPtr.h:666
FORCEINLINE TObjectPtr< T > & operator=(TYPE_OF_NULLPTR)
Definition ObjectPtr.h:543
FObjectPtr ObjectPtr
Definition ObjectPtr.h:698
FORCEINLINE FString GetFullName(EObjectFullNameFlags Flags=EObjectFullNameFlags::None) const
Definition ObjectPtr.h:663
FORCEINLINE FString GetPath() const
Definition ObjectPtr.h:659
TObjectPtr< T > & operator=(TObjectPtr< T > &&)=default
FORCEINLINE operator UPTRINT() const
Definition ObjectPtr.h:643
FORCEINLINE operator U*() const
Definition ObjectPtr.h:642
friend bool ObjectPtr_Private::IsObjectPtrEqualToRawPtrOfRelatedType(const TObjectPtr< U > &Ptr, const V *Other)
FORCEINLINE TObjectPtr(ENoInit)
Definition ObjectPtr.h:503
FORCEINLINE FName GetFName() const
Definition ObjectPtr.h:661
FORCEINLINE void SerializePtrStructured(FStructuredArchiveSlot Slot)
Definition ObjectPtr.h:673
FORCEINLINE bool IsNullNoResolve() const
Definition ObjectPtr.h:654
FORCEINLINE TObjectPtr(TYPE_OF_NULLPTR)
Definition ObjectPtr.h:508
FORCEINLINE T & operator*() const
Definition UE.h:132
const UObject * Pointer
Definition ObjectPtr.h:809
TPrivateObjectPtr(const TPrivateObjectPtr< T > &Other)=default
TPrivateObjectPtr(const UObject *InPointer)
Definition ObjectPtr.h:804
Definition UE.h:589
Definition UE.h:432