14 #define INVALID_OBJECT (UObject*)-1
17 typedef signed int int32;
19 enum { INDEX_NONE = -1 };
22 template<
typename Enum>
23 constexpr bool EnumHasAnyFlags(Enum Flags, Enum Contains)
25 return(((__underlying_type(Enum))Flags) & (__underlying_type(Enum))Contains) != 0;
37 CLASS_None = 0x00000000u,
39 CLASS_Abstract = 0x00000001u,
41 CLASS_DefaultConfig = 0x00000002u,
43 CLASS_Config = 0x00000004u,
45 CLASS_Transient = 0x00000008u,
47 CLASS_Optional = 0x00000010u,
49 CLASS_MatchedSerializers = 0x00000020u,
51 CLASS_ProjectUserConfig = 0x00000040u,
53 CLASS_Native = 0x00000080u,
57 CLASS_NotPlaceable = 0x00000200u,
59 CLASS_PerObjectConfig = 0x00000400u,
62 CLASS_ReplicationDataIsSetUp = 0x00000800u,
65 CLASS_EditInlineNew = 0x00001000u,
67 CLASS_CollapseCategories = 0x00002000u,
69 CLASS_Interface = 0x00004000u,
73 CLASS_Const = 0x00010000u,
76 CLASS_NeedsDeferredDependencyLoading = 0x00020000u,
79 CLASS_CompiledFromBlueprint = 0x00040000u,
82 CLASS_MinimalAPI = 0x00080000u,
85 CLASS_RequiredAPI = 0x00100000u,
88 CLASS_DefaultToInstanced = 0x00200000u,
91 CLASS_TokenStreamAssembled = 0x00400000u,
93 CLASS_HasInstancedReference = 0x00800000u,
95 CLASS_Hidden = 0x01000000u,
97 CLASS_Deprecated = 0x02000000u,
99 CLASS_HideDropDown = 0x04000000u,
101 CLASS_GlobalUserConfig = 0x08000000u,
103 CLASS_Intrinsic = 0x10000000u,
105 CLASS_Constructed = 0x20000000u,
107 CLASS_ConfigDoNotCheckDefaults = 0x40000000u,
109 CLASS_NewerVersionExists = 0x80000000u,
120 PKG_None = 0x00000000,
121 PKG_NewlyCreated = 0x00000001,
122 PKG_ClientOptional = 0x00000002,
123 PKG_ServerSideOnly = 0x00000004,
124 PKG_CompiledIn = 0x00000010,
125 PKG_ForDiffing = 0x00000020,
126 PKG_EditorOnly = 0x00000040,
127 PKG_Developer = 0x00000080,
128 PKG_UncookedOnly = 0x00000100,
129 PKG_Cooked = 0x00000200,
130 PKG_ContainsNoAsset = 0x00000400,
131 PKG_NotExternallyReferenceable = 0x00000800,
133 PKG_UnversionedProperties = 0x00002000,
134 PKG_ContainsMapData = 0x00004000,
135 PKG_IsSaving = 0x00008000,
136 PKG_Compiling = 0x00010000,
137 PKG_ContainsMap = 0x00020000,
138 PKG_RequiresLocalizationGather = 0x00040000,
140 PKG_PlayInEditor = 0x00100000,
141 PKG_ContainsScript = 0x00200000,
142 PKG_DisallowExport = 0x00400000,
147 PKG_CookGenerated = 0x08000000,
148 PKG_DynamicImports = 0x10000000,
149 PKG_RuntimeGenerated = 0x20000000,
150 PKG_ReloadingForCooker = 0x40000000,
151 PKG_FilterEditorOnly = 0x80000000,
154 PKG_TransientFlags = PKG_NewlyCreated | PKG_IsSaving | PKG_ReloadingForCooker,
164 RF_NoFlags = 0x00000000,
168 RF_Public = 0x00000001,
169 RF_Standalone = 0x00000002,
170 RF_MarkAsNative = 0x00000004,
171 RF_Transactional = 0x00000008,
172 RF_ClassDefaultObject = 0x00000010,
173 RF_ArchetypeObject = 0x00000020,
174 RF_Transient = 0x00000040,
177 RF_MarkAsRootSet = 0x00000080,
178 RF_TagGarbageTemp = 0x00000100,
181 RF_NeedInitialization = 0x00000200,
182 RF_NeedLoad = 0x00000400,
183 RF_KeepForCooker = 0x00000800,
184 RF_NeedPostLoad = 0x00001000,
185 RF_NeedPostLoadSubobjects = 0x00002000,
186 RF_NewerVersionExists = 0x00004000,
187 RF_BeginDestroyed = 0x00008000,
188 RF_FinishDestroyed = 0x00010000,
191 RF_BeingRegenerated = 0x00020000,
192 RF_DefaultSubObject = 0x00040000,
193 RF_WasLoaded = 0x00080000,
194 RF_TextExportTransient = 0x00100000,
195 RF_LoadCompleted = 0x00200000,
196 RF_InheritableComponentTemplate = 0x00400000,
197 RF_DuplicateTransient = 0x00800000,
198 RF_StrongRefOnFrame = 0x01000000,
199 RF_NonPIEDuplicateTransient = 0x02000000,
200 RF_Dynamic = 0x04000000,
201 RF_WillBeLoaded = 0x08000000,
202 RF_HasExternalPackage = 0x10000000,
209 RF_PendingKill = 0x20000000,
210 RF_Garbage = 0x40000000,
211 RF_AllocatedInSharedPage = 0x80000000
220 enum class EInternalObjectFlags : int32
224 LoaderImport = 1 << 20,
226 PersistentGarbage = 1 << 22,
227 ReachableInCluster = 1 << 23,
228 ClusterRoot = 1 << 24,
231 AsyncLoading = 1 << 27,
232 Unreachable = 1 << 28,
233 PendingKill = 1 << 29,
235 PendingConstruction = 1 << 31,
237 GarbageCollectionKeepFlags = Native | Async | AsyncLoading | LoaderImport,
238 MirroredFlags = Garbage | PendingKill,
241 AllFlags = LoaderImport | Garbage | PersistentGarbage | ReachableInCluster | ClusterRoot | Native | Async | AsyncLoading | Unreachable | PendingKill | RootSet | PendingConstruction
253 int32_t m_InternalFlags;
266 FORCEINLINE
void SetFlags(EInternalObjectFlags FlagsToSet)
268 KR_CORE_ASSERT((int32_t(FlagsToSet) & ~int32_t(EInternalObjectFlags::AllFlags)) == 0,
"");
270 m_InternalFlags = int32_t(FlagsToSet);
273 FORCEINLINE EInternalObjectFlags GetFlags()
const
276 return EInternalObjectFlags(m_InternalFlags);
279 FORCEINLINE
bool HasAnyFlags(EInternalObjectFlags InFlags)
const
281 return !!(m_InternalFlags & int32_t(InFlags));
317 m_CurrentObject(nullptr)
319 if (bOnlyGCedObjects)
333 m_Array(InIter.m_Array)
335 m_Index = m_Array.Num();
346 bool operator==(
const TIterator& Rhs)
const {
return m_Index == Rhs.m_Index; }
347 bool operator!=(
const TIterator& Rhs)
const {
return m_Index != Rhs.m_Index; }
350 FORCEINLINE
explicit operator bool()
const
352 return !!m_CurrentObject;
355 FORCEINLINE
bool operator !()
const
360 FORCEINLINE int32 GetIndex()
const
374 return m_CurrentObject;
385 m_CurrentObject =
nullptr;
386 while(++m_Index < m_Array.GetObjectsList().size())
388 NextObject = m_Array.GetObjectsList()[m_Index];
389 if (NextObject->m_Object)
391 m_CurrentObject = NextObject;
417 void AddUObject(
UObject* Object);
527namespace ECastCheckedType
545template <
class T,
class U>
550 T* Result =
static_cast<T*
>(Src);
553 KR_CORE_ERROR(
"Casting failed");
561 KR_CORE_ASSERT(
false,
"Attempting to cast nullptr");
576KARMA_API UObject* StaticConstructObject_Internal(
const FStaticConstructObjectParameters& Params);
594KARMA_API UObject* StaticAllocateObject(
const UClass* Class, UObject* InOuter,
const std::string& name, EObjectFlags SetFlags = EObjectFlags::RF_NoFlags, EInternalObjectFlags InternalSetFlags = EInternalObjectFlags::None);
612FUNCTION_NON_NULL_RETURN_START
613T* NewObject(UObject* Outer,
const UClass* Class, std::string name =
"No_Name", EObjectFlags Flags = RF_NoFlags, UObject* Template =
nullptr,
bool bCopyTransientsFromClassDefaults =
false)
614FUNCTION_NON_NULL_RETURN_END
618 KR_CORE_ASSERT(
false,
"NewObject with empty name can't be used to create default subobjects");
622 FStaticConstructObjectParameters Params;
623 Params.m_Class = Class;
624 Params.m_Outer = Outer;
625 Params.m_Name = name;
626 Params.m_SetFlags = Flags;
627 Params.m_Class = Class;
629 Params.m_bCopyTransientsFromClassDefaults = bCopyTransientsFromClassDefaults;
633 return static_cast<T*
>(StaticConstructObject_Internal(Params));
675KARMA_API UObject* StaticFindObjectFastInternal(
const UClass* ObjectClass,
const UObject* ObjectPackage,
const std::string& ObjectName,
bool bExactClass =
false, EObjectFlags ExcludeFlags = RF_NoFlags, EInternalObjectFlags ExclusiveInternalFlags = EInternalObjectFlags::None);
682KARMA_API UPackage* CreatePackage(
const std::string& PackageName);
695KARMA_API
void GetObjectsOfClass(
const UClass* ClassToLookFor,
KarmaVector<UObject *>& Results,
bool bIncludeDerivedClasses =
true, EObjectFlags ExcludeFlags = RF_ClassDefaultObject, EInternalObjectFlags ExclusionInternalFlags = EInternalObjectFlags::None);
706KARMA_API
void ForEachObjectOfClass(
const UClass* ClassToLookFor, std::function<
void(UObject*)> Operation,
bool bIncludeDerivedClasses =
true, EObjectFlags ExcludeFlags = RF_ClassDefaultObject, EInternalObjectFlags ExclusionInternalFlags = EInternalObjectFlags::None);
711typedef void (*FUObjectAllocatorCallback)(
void* InObject,
const std::string& InName,
size_t InSize,
size_t InAlignment,
class UClass* InClass);
719KARMA_API
extern void RegisterUObjectsStatisticsCallback(FUObjectAllocatorCallback dumpCallback);
728KARMA_API
void CacheObject(
class UObject* Object);
731extern void StaticUObjectInit();
732extern UPackage* GetTransientPackage();
753 FObjectInitializer(
UObject* InObj,
UObject* InObjectArchetype,
bool bInCopyTransientsFromClassDefaults,
bool bInShouldInitializeProps,
struct FObjectInstancingGraph* InInstanceGraph =
nullptr);
775 void PostConstructInit();
785 static void InitProperties(
UObject* Object,
UClass* DefaultsClass,
UObject* DefaultData,
bool bCopyTransientsFromClassDefaults);
795 bool m_bCopyTransientsFromClassDefaults;
798 bool m_bShouldInitializePropsFromArchetype;
801 bool m_bSubobjectClassInitializationAllowed;
804 UObject* m_LastConstructedObject;
void InternalConstructor(const FObjectInitializer &X)
Helper template to call the default constructor for a class.
Definition Object.h:33
Karma's std::map wrapper.
Definition KarmaTypes.h:63
Karma's std::vector wrapper.
Definition KarmaTypes.h:128
Definition UObjectGlobals.h:738
FORCEINLINE UObject * GetObj() const
Definition UObjectGlobals.h:760
Definition UObjectGlobals.h:301
FORCEINLINE FUObjectItem * GetObject() const
Definition UObjectGlobals.h:372
FORCEINLINE void operator++()
Definition UObjectGlobals.h:341
TIterator(EEndTagType, const TIterator &InIter)
Definition UObjectGlobals.h:332
const FUObjectArray & GetIteratedArray() const
Definition UObjectGlobals.h:399
TIterator(const FUObjectArray &InArray, bool bOnlyGCedObjects=false)
Definition UObjectGlobals.h:314
FORCEINLINE bool Advance()
Definition UObjectGlobals.h:381
Definition UObjectGlobals.h:295
const std::vector< FUObjectItem * > & GetObjectsList() const
Definition UObjectGlobals.h:420
Definition UObjectGlobals.h:424
KarmaVector< UObject * > * FindClassObjects(const UClass *Key)
Definition UObjectGlobals.cpp:594
KarmaVector< UObject * > * FindOrAddClass(const UClass *Key)
Definition UObjectGlobals.cpp:607
Low level implementation of UObject, should not be used directly in game code Taken from UE's UObject...
Definition UObjectBase.h:34
The base class of all the game code relevant objects.
Definition Object.h:106
@ None
Definition KarmaTypes.h:33
Type
Definition UObjectGlobals.h:530
@ NullAllowed
Definition UObjectGlobals.h:532
@ NullChecked
Definition UObjectGlobals.h:534
Definition UObjectGlobals.h:476
bool m_bAssumeTemplateIsArchetype
Definition UObjectGlobals.h:496
EObjectFlags m_SetFlags
Definition UObjectGlobals.h:487
EInternalObjectFlags m_InternalSetFlags
Definition UObjectGlobals.h:490
std::string m_Name
Definition UObjectGlobals.h:484
bool m_bCopyTransientsFromClassDefaults
Definition UObjectGlobals.h:493
UObject * m_Template
Definition UObjectGlobals.h:502
UObject * m_Outer
Definition UObjectGlobals.h:481
const UClass * m_Class
Definition UObjectGlobals.h:478
Definition UObjectGlobals.h:248