25 #define INVALID_OBJECT (UObject*)-1
44 template<
typename Enum>
47 return(((__underlying_type(Enum))Flags) & (__underlying_type(Enum))Contains) != 0;
71 CLASS_MatchedSerializers = 0x00000020u,
377 m_CurrentObject(nullptr)
379 if (bOnlyGCedObjects)
395 m_Array(InIter.m_Array)
397 m_Index = m_Array.Num();
431 return !!m_CurrentObject;
466 return m_CurrentObject;
481 m_CurrentObject =
nullptr;
482 while(++m_Index < m_Array.GetObjectsList().size())
484 NextObject = m_Array.GetObjectsList()[m_Index];
487 m_CurrentObject = NextObject;
525 void AddUObject(
UObject* Object);
598 extern KARMA_API FUObjectArray GUObjectStore;
610 extern KARMA_API KarmaClassObjectMap m_ClassToObjectVectorMap;
703template <
class T,
class U>
708 T*
Result =
static_cast<T*
>(Src);
719 KR_CORE_ASSERT(
false,
"Attempting to cast nullptr");
734KARMA_API UObject* StaticConstructObject_Internal(
const FStaticConstructObjectParameters& Params);
752KARMA_API UObject* StaticAllocateObject(
const UClass* Class, UObject* InOuter,
const std::string& name, EObjectFlags SetFlags = EObjectFlags::RF_NoFlags, EInternalObjectFlags InternalSetFlags = EInternalObjectFlags::None);
770FUNCTION_NON_NULL_RETURN_START
772FUNCTION_NON_NULL_RETURN_END
776 KR_CORE_ASSERT(
false,
"NewObject with empty name can't be used to create default subobjects");
791 return static_cast<T*
>(StaticConstructObject_Internal(Params));
833KARMA_API UObject* StaticFindObjectFastInternal(
const UClass* ObjectClass,
const UObject* ObjectPackage,
const std::string& ObjectName,
bool bExactClass =
false, EObjectFlags ExcludeFlags = RF_NoFlags, EInternalObjectFlags ExclusiveInternalFlags = EInternalObjectFlags::None);
856 return (T*)StaticFindObjectFastInternal(T::StaticClass(), Outer, Name, ExactClass);
865KARMA_API UPackage* CreatePackage(
const std::string& PackageName);
879KARMA_API void GetObjectsOfClass(
const UClass* ClassToLookFor,
KarmaVector<UObject *>& Results,
bool bIncludeDerivedClasses =
true, EObjectFlags ExcludeFlags = RF_ClassDefaultObject, EInternalObjectFlags ExclusionInternalFlags = EInternalObjectFlags::None);
890KARMA_API void ForEachObjectOfClass(
const UClass* ClassToLookFor, std::function<
void(UObject*)> Operation,
bool bIncludeDerivedClasses =
true, EObjectFlags ExcludeFlags = RF_ClassDefaultObject, EInternalObjectFlags ExclusionInternalFlags = EInternalObjectFlags::None);
895typedef void (*FUObjectAllocatorCallback)(
void* InObject,
const std::string& InName,
size_t InSize,
size_t InAlignment,
class UClass* InClass);
903KARMA_API extern void RegisterUObjectsStatisticsCallback(FUObjectAllocatorCallback dumpCallback);
911KARMA_API void CacheObject(
class UObject* Object);
914extern void StaticUObjectInit();
915extern UPackage* GetTransientPackage();
944 FObjectInitializer(UObject* InObj, UObject* InObjectArchetype,
bool bInCopyTransientsFromClassDefaults,
bool bInShouldInitializeProps,
struct FObjectInstancingGraph* InInstanceGraph =
nullptr);
974 void PostConstructInit();
988 static void InitProperties(
UObject* Object,
UClass* DefaultsClass,
UObject* DefaultData,
bool bCopyTransientsFromClassDefaults);
998 bool m_bCopyTransientsFromClassDefaults;
1001 bool m_bShouldInitializePropsFromArchetype;
1004 bool m_bSubobjectClassInitializationAllowed;
1007 UObject* m_LastConstructedObject;
#define KARMA_API
Defining Karma's API macro for storage class information.
Definition Core.h:41
#define FORCEINLINE
Typical inlining macro for clarity.
Definition Core.h:157
@ None
Events of the unknown category.
Definition Event.h:37
#define KR_CORE_ERROR(...)
A macro for logging error in Core part.
Definition Log.h:73
void InternalConstructor(const FObjectInitializer &X)
Helper template to call the default constructor for a class.
Definition Object.h:33
FORCEINLINE bool IsValid(const UObject *Test)
Test validity of object.
Definition Object.h:239
FUNCTION_NON_NULL_RETURN_START T * NewObject(UObject *Outer, const UClass *Class, std::string name="No_Name", EObjectFlags Flags=RF_NoFlags, UObject *Template=nullptr, bool bCopyTransientsFromClassDefaults=false) FUNCTION_NON_NULL_RETURN_END
Definition UObjectGlobals.h:771
FORCEINLINE T * CastChecked(const U &Src, ECastCheckedType::Type CheckType=ECastCheckedType::NullChecked)
Definition UObjectGlobals.h:704
constexpr bool EnumHasAnyFlags(Enum Flags, Enum Contains)
Sees if a specified flag(s) exists in the linear combination of flags.
Definition UObjectGlobals.h:45
EObjectFlags
Flags describing an object instance.
Definition UObjectGlobals.h:183
@ RF_BeingRegenerated
Flagged on UObjects that are used to create UClasses (e.g. Blueprints) while they are regenerating th...
Definition UObjectGlobals.h:213
@ RF_ClassDefaultObject
This object is its class's default object.
Definition UObjectGlobals.h:194
@ RF_MarkAsNative
Object (UField) will be marked as native on construction (DO NOT USE THIS FLAG in HasAnyFlags() etc)
Definition UObjectGlobals.h:192
@ RF_NeedLoad
During load, indicates object needs loading.
Definition UObjectGlobals.h:204
@ RF_TextExportTransient
Do not export object to text form (e.g. copy/paste). Generally used for sub-objects that can be regen...
Definition UObjectGlobals.h:216
@ RF_Public
Object is visible outside its package.
Definition UObjectGlobals.h:190
@ RF_StrongRefOnFrame
References to this object from persistent function frame are handled as strong ones.
Definition UObjectGlobals.h:220
@ RF_AllocatedInSharedPage
Allocated from a ref-counted page shared with other UObjects.
Definition UObjectGlobals.h:233
@ RF_DefaultSubObject
Flagged on subobjects that are defaults.
Definition UObjectGlobals.h:214
@ RF_NeedInitialization
This object has not completed its initialization process. Cleared when ~FObjectInitializer completes.
Definition UObjectGlobals.h:203
@ RF_KeepForCooker
Keep this object during garbage collection because it's still being used by the cooker.
Definition UObjectGlobals.h:205
@ RF_BeginDestroyed
BeginDestroy has been called on the object.
Definition UObjectGlobals.h:209
@ RF_Transient
Don't save object.
Definition UObjectGlobals.h:196
@ RF_WillBeLoaded
This object was constructed during load and will be loaded shortly.
Definition UObjectGlobals.h:223
@ RF_TagGarbageTemp
This is a temp user flag for various utilities that need to use the garbage collector....
Definition UObjectGlobals.h:200
@ RF_WasLoaded
Flagged on UObjects that were loaded.
Definition UObjectGlobals.h:215
@ RF_ArchetypeObject
This object is a template for another object - treat like a class default object.
Definition UObjectGlobals.h:195
@ RF_InheritableComponentTemplate
Archetype of the object can be in its super class.
Definition UObjectGlobals.h:218
@ RF_MarkAsRootSet
Object will be marked as root set on construction and not be garbage collected, even if unreferenced ...
Definition UObjectGlobals.h:199
@ RF_PendingKill
Objects that are pending destruction (invalid for gameplay but valid objects). This flag is mirrored ...
Definition UObjectGlobals.h:231
@ RF_NonPIEDuplicateTransient
Object should not be included for duplication unless it's being duplicated for a PIE session.
Definition UObjectGlobals.h:221
@ RF_Standalone
Keep object around for editing even if unreferenced.
Definition UObjectGlobals.h:191
@ RF_Garbage
Garbage from logical point of view and should not be referenced. This flag is mirrored in EInternalOb...
Definition UObjectGlobals.h:232
@ RF_NewerVersionExists
Object has been consigned to oblivion due to its owner package being reloaded, and a newer version cu...
Definition UObjectGlobals.h:208
@ RF_HasExternalPackage
This object has an external package assigned and should look it up when getting the outermost package...
Definition UObjectGlobals.h:224
@ RF_FinishDestroyed
FinishDestroy has been called on the object.
Definition UObjectGlobals.h:210
@ RF_LoadCompleted
Object has been completely serialized by linkerload at least once. DO NOT USE THIS FLAG,...
Definition UObjectGlobals.h:217
@ RF_NeedPostLoad
Object needs to be postloaded.
Definition UObjectGlobals.h:206
@ RF_DuplicateTransient
Object should not be included in any type of duplication (copy/paste, binary duplication,...
Definition UObjectGlobals.h:219
@ RF_Transactional
Object is transactional.
Definition UObjectGlobals.h:193
@ RF_NoFlags
No flags, used to avoid a cast.
Definition UObjectGlobals.h:186
@ RF_NeedPostLoadSubobjects
During load, indicates that the object still needs to instance subobjects and fixup serialized compon...
Definition UObjectGlobals.h:207
@ RF_Dynamic
Field Only. Dynamic field - doesn't get constructed during static initialization, can be constructed ...
Definition UObjectGlobals.h:222
EClassFlags
Flags describing a class.
Definition UObjectGlobals.h:57
@ CLASS_Optional
Definition UObjectGlobals.h:69
@ CLASS_GlobalUserConfig
Definition UObjectGlobals.h:123
@ CLASS_Transient
Definition UObjectGlobals.h:67
@ CLASS_HideDropDown
Definition UObjectGlobals.h:121
@ CLASS_Deprecated
Definition UObjectGlobals.h:119
@ CLASS_RequiredAPI
Definition UObjectGlobals.h:107
@ CLASS_DefaultToInstanced
Definition UObjectGlobals.h:110
@ CLASS_TokenStreamAssembled
Definition UObjectGlobals.h:113
@ CLASS_EditInlineNew
Definition UObjectGlobals.h:87
@ CLASS_Interface
Definition UObjectGlobals.h:91
@ CLASS_NeedsDeferredDependencyLoading
Definition UObjectGlobals.h:98
@ CLASS_Native
Definition UObjectGlobals.h:75
@ CLASS_Const
Definition UObjectGlobals.h:95
@ CLASS_None
Definition UObjectGlobals.h:59
@ CLASS_PerObjectConfig
Definition UObjectGlobals.h:81
@ CLASS_Config
Definition UObjectGlobals.h:65
@ CLASS_NewerVersionExists
Definition UObjectGlobals.h:131
@ CLASS_Abstract
Definition UObjectGlobals.h:61
@ CLASS_ReplicationDataIsSetUp
Definition UObjectGlobals.h:84
@ CLASS_Intrinsic
Definition UObjectGlobals.h:125
@ CLASS_ConfigDoNotCheckDefaults
Definition UObjectGlobals.h:129
@ CLASS_HasInstancedReference
Definition UObjectGlobals.h:115
@ CLASS_Hidden
Definition UObjectGlobals.h:117
@ CLASS_CompiledFromBlueprint
Definition UObjectGlobals.h:101
@ CLASS_CollapseCategories
Definition UObjectGlobals.h:89
@ CLASS_NotPlaceable
Definition UObjectGlobals.h:79
@ CLASS_DefaultConfig
Definition UObjectGlobals.h:63
@ CLASS_ProjectUserConfig
Definition UObjectGlobals.h:73
@ CLASS_Constructed
Definition UObjectGlobals.h:127
@ CLASS_MinimalAPI
Definition UObjectGlobals.h:104
EInternalObjectFlags
Objects flags for internal use (GC, low level UObject code)
Definition UObjectGlobals.h:243
@ Async
Object exists only on a different thread than the game thread.
Definition UObjectGlobals.h:252
@ ClusterRoot
Root of a cluster.
Definition UObjectGlobals.h:250
@ Unreachable
Object is not reachable on the object graph.
Definition UObjectGlobals.h:254
@ PendingKill
Objects that are pending destruction (invalid for gameplay but valid objects). This flag is mirrored ...
Definition UObjectGlobals.h:255
@ ReachableInCluster
External reference to object in cluster exists.
Definition UObjectGlobals.h:249
@ PendingConstruction
Object didn't have its class constructor called yet (only the UObjectBase one to initialize its most ...
Definition UObjectGlobals.h:257
@ LoaderImport
Object is ready to be imported by another package during loading.
Definition UObjectGlobals.h:246
@ Garbage
Garbage from logical point of view and should not be referenced. This flag is mirrored in EObjectFlag...
Definition UObjectGlobals.h:247
@ Native
Native (UClass only).
Definition UObjectGlobals.h:251
@ RootSet
Object will not be garbage collected, even if unreferenced.
Definition UObjectGlobals.h:256
@ AsyncLoading
Object is being asynchronously loaded.
Definition UObjectGlobals.h:253
@ AllFlags
Flags mirrored in EObjectFlags.
Definition UObjectGlobals.h:263
@ PersistentGarbage
Same as above but referenced through a persistent reference so it can't be GC'd.
Definition UObjectGlobals.h:248
KARMA_API T * FindObject(UObject *Outer, const std::string &Name, bool ExactClass=false)
Find an optional object.
Definition UObjectGlobals.h:854
KARMA_API UObject * StaticFindObject(UClass *Class, UObject *InOuter, const std::string &Name, bool ExactClass=false)
EPackageFlags
Package flags, passed into UPackage::SetPackageFlags and related functions.
Definition UObjectGlobals.h:141
@ PKG_CompiledIn
This package is from "compiled in" classes.
Definition UObjectGlobals.h:146
@ PKG_ContainsNoAsset
Package doesn't contain any asset object (although asset tags can be present)
Definition UObjectGlobals.h:152
@ PKG_IsSaving
Temporarily set on a package while it is being saved.
Definition UObjectGlobals.h:157
@ PKG_Cooked
Package is cooked.
Definition UObjectGlobals.h:151
@ PKG_CookGenerated
This package was generated by the cooker and does not exist in the WorkspaceDomain.
Definition UObjectGlobals.h:169
@ PKG_ContainsMap
Set if the package contains a ULevel/ UWorld object.
Definition UObjectGlobals.h:159
@ PKG_ServerSideOnly
Only needed on the server side.
Definition UObjectGlobals.h:145
@ PKG_None
No flags.
Definition UObjectGlobals.h:142
@ PKG_ContainsScript
Package is allowed to contain UClass objects.
Definition UObjectGlobals.h:163
@ PKG_FilterEditorOnly
Package has editor-only data filtered out.
Definition UObjectGlobals.h:173
@ PKG_Compiling
package is currently being compiled
Definition UObjectGlobals.h:158
@ PKG_UnversionedProperties
Uses unversioned property serialization instead of versioned tagged property serialization.
Definition UObjectGlobals.h:155
@ PKG_PlayInEditor
Set if the package was created for the purpose of PIE.
Definition UObjectGlobals.h:162
@ PKG_ForDiffing
This package was loaded just for the purposes of diffing.
Definition UObjectGlobals.h:147
@ PKG_EditorOnly
This is editor-only package (for example: editor module script package)
Definition UObjectGlobals.h:148
@ PKG_NewlyCreated
Newly created package, not saved yet. In editor only.
Definition UObjectGlobals.h:143
@ PKG_UncookedOnly
Loaded only in uncooked builds (i.e. runtime in editor)
Definition UObjectGlobals.h:150
@ PKG_ClientOptional
Purely optional for clients.
Definition UObjectGlobals.h:144
@ PKG_Developer
Developer module.
Definition UObjectGlobals.h:149
@ PKG_ContainsMapData
Contains map data (UObjects only referenced by a single ULevel) but is stored in a different package.
Definition UObjectGlobals.h:156
@ PKG_ReloadingForCooker
This package is reloading in the cooker, try to avoid getting data we will never need....
Definition UObjectGlobals.h:172
@ PKG_DisallowExport
Editor should not export asset in this package.
Definition UObjectGlobals.h:164
@ PKG_DynamicImports
This package should resolve dynamic imports from its export at runtime.
Definition UObjectGlobals.h:170
@ PKG_RequiresLocalizationGather
Set if the package contains any data to be gathered by localization.
Definition UObjectGlobals.h:160
@ PKG_NotExternallyReferenceable
Objects in this package cannot be referenced in a different plugin or mount point (i....
Definition UObjectGlobals.h:153
@ PKG_RuntimeGenerated
This package contains elements that are runtime generated, and may not follow standard loading order ...
Definition UObjectGlobals.h:171
signed int int32
32-bit signed integer
Definition UObjectGlobals.h:33
Actor is the base class for an object that can be placed or spawned in a level.
Definition Actor.h:34
Internal class to finalize UObject creation (initialize properties) after the real C++ constructor is...
Definition UObjectGlobals.h:921
FObjectInitializer()
Default Constructor, used when you are using the C++ "new" syntax. UObject::UObject will set the obje...
FORCEINLINE UObject * GetObj() const
Definition UObjectGlobals.h:954
FORCEINLINE FUObjectItem * GetObject() const
Definition UObjectGlobals.h:464
FORCEINLINE void operator++()
Definition UObjectGlobals.h:405
TIterator(EEndTagType, const TIterator &InIter)
Definition UObjectGlobals.h:394
bool operator==(const TIterator &Rhs) const
Definition UObjectGlobals.h:415
FORCEINLINE int32 GetIndex() const
Definition UObjectGlobals.h:451
bool operator!=(const TIterator &Rhs) const
Definition UObjectGlobals.h:422
const FUObjectArray & GetIteratedArray() const
Definition UObjectGlobals.h:499
TIterator(const FUObjectArray &InArray, bool bOnlyGCedObjects=false)
Definition UObjectGlobals.h:374
FORCEINLINE bool Advance()
Definition UObjectGlobals.h:477
A class for managing the collection of UObjects (all or some?)
Definition UObjectGlobals.h:350
const std::vector< FUObjectItem * > & GetObjectsList() const
Definition UObjectGlobals.h:532
KarmaVector< UObject * > * FindClassObjects(const UClass *Key)
Definition UObjectGlobals.cpp:613
KarmaVector< UObject * > * FindOrAddClass(const UClass *Key)
Definition UObjectGlobals.cpp:626
~KarmaClassObjectMap()
Definition UObjectGlobals.cpp:649
KarmaClassObjectMap()
Definition UObjectGlobals.h:557
An object class.
Definition Class.h:158
Low level implementation of UObject, should not be used directly in game code.
Definition UObjectBase.h:36
The base class of all the game code relevant objects.
Definition Object.h:106
A generic outer for UObjects, for instance UWorld.
Definition Package.h:23
KarmaMap()
Definition KarmaTypes.h:89
Karma's std::vector wrapper.
Definition KarmaTypes.h:152
KarmaVector()
Definition KarmaTypes.h:159
Definition UObjectGlobals.h:684
Type
Definition UObjectGlobals.h:686
@ NullAllowed
Definition UObjectGlobals.h:688
@ NullChecked
Definition UObjectGlobals.h:690
This struct is used for passing parameter values to the StaticConstructObject_Internal() method....
Definition UObjectGlobals.h:617
bool m_bAssumeTemplateIsArchetype
Definition UObjectGlobals.h:652
EObjectFlags m_SetFlags
Definition UObjectGlobals.h:638
EInternalObjectFlags m_InternalSetFlags
Definition UObjectGlobals.h:646
std::string m_Name
Definition UObjectGlobals.h:631
bool m_bCopyTransientsFromClassDefaults
Definition UObjectGlobals.h:649
UObject * m_Template
Definition UObjectGlobals.h:658
UObject * m_Outer
Definition UObjectGlobals.h:625
const UClass * m_Class
Definition UObjectGlobals.h:619
Single item in UObjectStore.
Definition UObjectGlobals.h:270
FORCEINLINE void SetFlags(EInternalObjectFlags FlagsToSet)
Set the internal flags.
Definition UObjectGlobals.h:307
FUObjectItem()
Null (basically default) constructor.
Definition UObjectGlobals.h:289
FORCEINLINE bool HasAnyFlags(EInternalObjectFlags InFlags) const
Query for m_InternalFlags.
Definition UObjectGlobals.h:334
FORCEINLINE EInternalObjectFlags GetFlags() const
Getter for internal flags.
Definition UObjectGlobals.h:320
class UObjectBase * m_Object
Definition UObjectGlobals.h:274
int32_t m_InternalFlags
Definition UObjectGlobals.h:282