KarmaEngine
Game Engine for practical learning and research purposes
Loading...
Searching...
No Matches
UObjectIterator.h
Go to the documentation of this file.
1
10
11#pragma once
12
13#include "krpch.h"
14#include "UObjectGlobals.h"
15
16namespace Karma
17{
22 {
23 public:
30 FRawObjectIterator(bool bOnlyGCedObjects = false) :
31 FUObjectArray::TIterator(GUObjectStore, bOnlyGCedObjects)
32 {
33 }
34
42 {
43 // casting UObjectBase to UObject for clients
44 return GetObject();
45 }
46
54 {
55 return GetObject();
56 }
57};
58
59 /*
60 inline EInternalObjectFlags GetObjectIteratorDefaultInternalExclusionFlags(EInternalObjectFlags InternalExclusionFlags)
61 {
62 //InternalExclusionFlags = UObjectBaseUtility::FixGarbageOrPendingKillInternalObjectFlags(InternalExclusionFlags);
63
64 InternalExclusionFlags = EInternalObjectFlags(int32_t(InternalExclusionFlags) | (int32_t(EInternalObjectFlags::Unreachable) | int32_t(EInternalObjectFlags::PendingConstruction)));
65
66 if (!IsInAsyncLoadingThread())
67 {
68 // We don't want to return any objects that are currently being background loaded unless we're using the object iterator during async loading.
69 InternalExclusionFlags |= EInternalObjectFlags::AsyncLoading;
70 }
71
72 return InternalExclusionFlags;
73 }*/
74
84 /*template<class T> class TObjectIterator
85 {
86 public:
87 enum EEndTagType
88 {
89 EndTag
90 };
91
92
93 explicit TObjectIterator(EObjectFlags AdditionalExclusionFlags = RF_ClassDefaultObject, bool bIncludeDerivedClasses = true, EInternalObjectFlags InInternalExclusionFlags = EInternalObjectFlags::None)
94 : m_Index(-1)
95 {
96 GetObjectsOfClass(T::StaticClass(), m_ObjectArray, bIncludeDerivedClasses, AdditionalExclusionFlags, GetObjectIteratorDefaultInternalExclusionFlags(InInternalExclusionFlags));
97 Advance();
98 }
99
100
101 TObjectIterator(EEndTagType, TObjectIterator& Begin)
102 : m_Index(Begin.m_ObjectArray.Num())
103 {
104 }
105
106
107 FORCEINLINE void operator++()
108 {
109 Advance();
110 }
111
112
113 FORCEINLINE explicit operator bool() const
114 {
115 return m_ObjectArray.IsValidIndex(m_Index);
116 }
117
118
119 FORCEINLINE bool operator !() const
120 {
121 return !(bool)*this;
122 }
123
124
125 FUNCTION_NON_NULL_RETURN_START
126 FORCEINLINE T* operator* () const
127 FUNCTION_NON_NULL_RETURN_END
128 {
129 return (T*)GetObject();
130 }
131
132 FUNCTION_NON_NULL_RETURN_START
133 FORCEINLINE T* operator-> () const
134 FUNCTION_NON_NULL_RETURN_END
135 {
136 return (T*)GetObject();
137 }
138
139 FORCEINLINE bool operator==(const TObjectIterator& Rhs) const { return m_Index == Rhs.Index; }
140 FORCEINLINE bool operator!=(const TObjectIterator& Rhs) const { return m_Index != Rhs.Index; }
141
142 protected:
143
144 FORCEINLINE UObject* GetObject() const
145 {
146 return m_ObjectArray.GetElements()[m_Index];
147 }
148
149
150 FORCEINLINE bool Advance()
151 {
152 //@todo UE check this for LHS on Index on consoles
153 while(++m_Index < m_ObjectArray.Num())
154 {
155 if (GetObject())
156 {
157 return true;
158 }
159 }
160 return false;
161 }
162
163 protected:
164
165 KarmaVector<UObject*> m_ObjectArray;
166
167 int32_t m_Index;
168 };
169*/
170}
#define FORCEINLINE
Typical inlining macro for clarity.
Definition Core.h:157
This file contains some commonly used game code macros.
FRawObjectIterator(bool bOnlyGCedObjects=false)
Definition UObjectIterator.h:30
FORCEINLINE FUObjectItem * operator*() const
Definition UObjectIterator.h:41
FORCEINLINE FUObjectItem * operator->() const
Definition UObjectIterator.h:53
Low level iterator.
Definition UObjectGlobals.h:356
FORCEINLINE FUObjectItem * GetObject() const
Definition UObjectGlobals.h:464
TIterator(const FUObjectArray &InArray, bool bOnlyGCedObjects=false)
Definition UObjectGlobals.h:374
A class for managing the collection of UObjects (all or some?)
Definition UObjectGlobals.h:350
Single item in UObjectStore.
Definition UObjectGlobals.h:270