Karma Engine
Loading...
Searching...
No Matches
UObjectIterator.h
1#pragma once
2
3#include "krpch.h"
4#include "UObjectGlobals.h"
5
6namespace Karma
7{
8
13 {
14 public:
19 FRawObjectIterator(bool bOnlyGCedObjects = false) :
20 FUObjectArray::TIterator(GUObjectStore, bOnlyGCedObjects)
21 {
22 }
27 FORCEINLINE FUObjectItem* operator*() const
28 {
29 // casting UObjectBase to UObject for clients
30 return GetObject();
31 }
32
37 FORCEINLINE FUObjectItem* operator->() const
38 {
39 return GetObject();
40 }
41};
42
43 /*
44 inline EInternalObjectFlags GetObjectIteratorDefaultInternalExclusionFlags(EInternalObjectFlags InternalExclusionFlags)
45 {
46 //InternalExclusionFlags = UObjectBaseUtility::FixGarbageOrPendingKillInternalObjectFlags(InternalExclusionFlags);
47
48 InternalExclusionFlags = EInternalObjectFlags(int32_t(InternalExclusionFlags) | (int32_t(EInternalObjectFlags::Unreachable) | int32_t(EInternalObjectFlags::PendingConstruction)));
49
50 if (!IsInAsyncLoadingThread())
51 {
52 // We don't want to return any objects that are currently being background loaded unless we're using the object iterator during async loading.
53 InternalExclusionFlags |= EInternalObjectFlags::AsyncLoading;
54 }
55
56 return InternalExclusionFlags;
57 }*/
58
68 /*template<class T> class TObjectIterator
69 {
70 public:
71 enum EEndTagType
72 {
73 EndTag
74 };
75
76
77 explicit TObjectIterator(EObjectFlags AdditionalExclusionFlags = RF_ClassDefaultObject, bool bIncludeDerivedClasses = true, EInternalObjectFlags InInternalExclusionFlags = EInternalObjectFlags::None)
78 : m_Index(-1)
79 {
80 GetObjectsOfClass(T::StaticClass(), m_ObjectArray, bIncludeDerivedClasses, AdditionalExclusionFlags, GetObjectIteratorDefaultInternalExclusionFlags(InInternalExclusionFlags));
81 Advance();
82 }
83
84
85 TObjectIterator(EEndTagType, TObjectIterator& Begin)
86 : m_Index(Begin.m_ObjectArray.Num())
87 {
88 }
89
90
91 FORCEINLINE void operator++()
92 {
93 Advance();
94 }
95
96
97 FORCEINLINE explicit operator bool() const
98 {
99 return m_ObjectArray.IsValidIndex(m_Index);
100 }
101
102
103 FORCEINLINE bool operator !() const
104 {
105 return !(bool)*this;
106 }
107
108
109 FUNCTION_NON_NULL_RETURN_START
110 FORCEINLINE T* operator* () const
111 FUNCTION_NON_NULL_RETURN_END
112 {
113 return (T*)GetObject();
114 }
115
116 FUNCTION_NON_NULL_RETURN_START
117 FORCEINLINE T* operator-> () const
118 FUNCTION_NON_NULL_RETURN_END
119 {
120 return (T*)GetObject();
121 }
122
123 FORCEINLINE bool operator==(const TObjectIterator& Rhs) const { return m_Index == Rhs.Index; }
124 FORCEINLINE bool operator!=(const TObjectIterator& Rhs) const { return m_Index != Rhs.Index; }
125
126 protected:
127
128 FORCEINLINE UObject* GetObject() const
129 {
130 return m_ObjectArray.GetElements()[m_Index];
131 }
132
133
134 FORCEINLINE bool Advance()
135 {
136 //@todo UE check this for LHS on Index on consoles
137 while(++m_Index < m_ObjectArray.Num())
138 {
139 if (GetObject())
140 {
141 return true;
142 }
143 }
144 return false;
145 }
146
147 protected:
148
149 KarmaVector<UObject*> m_ObjectArray;
150
151 int32_t m_Index;
152 };
153*/
154}
Definition UObjectIterator.h:13
FRawObjectIterator(bool bOnlyGCedObjects=false)
Definition UObjectIterator.h:19
FORCEINLINE FUObjectItem * operator*() const
Definition UObjectIterator.h:27
FORCEINLINE FUObjectItem * operator->() const
Definition UObjectIterator.h:37
Definition UObjectGlobals.h:301
FORCEINLINE FUObjectItem * GetObject() const
Definition UObjectGlobals.h:372
TIterator(const FUObjectArray &InArray, bool bOnlyGCedObjects=false)
Definition UObjectGlobals.h:314
Definition UObjectGlobals.h:295
Definition UObjectGlobals.h:248