Karma Engine
Loading...
Searching...
No Matches
Class.h
1#pragma once
2
3#include "krpch.h"
4
5#include "Object.h"
6
7namespace Karma
8{
9 /*-----------------------------------------------------------------------------
10 UField.
11 -----------------------------------------------------------------------------*/
12
13 //
14 // Base class of reflection data objects.
15 //
16 class KARMA_API UField : public UObject
17 {
18 DECLARE_KARMA_CLASS(UField, UObject)
19
20
21 UField* m_Next;
22
28 UClass* GetOwnerClass() const;
29
31 //UStruct* GetOwnerStruct() const;
32
38 const std::string& GetAuthoredName() const;
39 };
40
41 /*-----------------------------------------------------------------------------
42 UStruct.
43 -----------------------------------------------------------------------------*/
44
48 class KARMA_API UStruct : public UField
49 {
50 DECLARE_KARMA_CLASS(UStruct, UField)
51
52 public:
53
55 bool IsChildOf(const UStruct* SomeBase) const;
56
59 {
60 return m_SuperStruct;
61 }
62
64 FORCEINLINE size_t GetPropertiesSize() const
65 {
66 return m_PropertiesSize;
67 }
68
73 virtual void SetSuperStruct(UStruct* NewSuperStruct);
74
75 private:
77 UStruct* m_SuperStruct;
78
79 public:
89
91 // Public?
93 };
94
98 class KARMA_API UClass : public UStruct
99 {
100 DECLARE_KARMA_CLASS(UClass, UStruct)
101
102 public:
104 UClass();
105 UClass(const std::string& name);
106
112 UClass(const std::string& name, size_t size, size_t alignment, ClassConstructorType inClassConstructor);
113
115 //UClass* m_ClassWithin;
116
117 // Only for hot reload purposes
118 // typedef UObject* (*ClassVTableHelperCtorCallerType) (FVTableHelper& Helper);
119
120 ClassConstructorType m_ClassConstructor;
121
123 EClassFlags m_ClassFlags;
124
125 public:
126 // UObject interface.
127 virtual const std::string& GetDesc() override;
128
137 FORCEINLINE bool HasAnyClassFlags(EClassFlags FlagsToCheck) const
138 {
139 return EnumHasAnyFlags(m_ClassFlags, FlagsToCheck) != 0;
140 }
141
142 public:
146 virtual void SetupObjectInitializer(FObjectInitializer& ObjectInitializer) const {}
147
153 UObject* GetDefaultObject(bool bCreateIfNeeded = true) const
154 {
155 if (/*m_ClassDefaultObject == nullptr &&*/ bCreateIfNeeded)
156 {
157 // some UE macro
158 const_cast<UClass*>(this)->CreateDefaultObject();
159 }
160
161 return nullptr;//m_ClassDefaultObject;
162 }
163
168 template<class T>
170 {
171 UObject* Ret = GetDefaultObject();
172 KR_CORE_ASSERT(Ret->IsA(T::StaticClass()), "Class {0} is not subclass of UObject");
173 return (T*)Ret;
174 }
175
178 {
179 return (UClass*)GetSuperStruct();
180 }
181
183 FORCEINLINE size_t GetMinAlignment() const
184 {
185 return m_MinAlignment;
186 }
187
188 // UStruct interface.
189 virtual void SetSuperStruct(UStruct* NewSuperStruct) override;
190
198 virtual void InitPropertiesFromCustomList(uint8_t* DataPtr, const uint8_t* DefaultDataPtr) {}
199
200 protected:
205 virtual UObject* CreateDefaultObject();
206
207 public:
209 //UObject* m_ClassDefaultObject;
210
211 private:
213 //bool m_bLayoutChanging;
214 };
215}
This file contains the class UObject along with helper functions.
Definition UObjectGlobals.h:738
Definition Class.h:99
UClass * GetSuperClass() const
Definition Class.h:177
T * GetDefaultObject() const
Definition Class.h:169
virtual void InitPropertiesFromCustomList(uint8_t *DataPtr, const uint8_t *DefaultDataPtr)
Definition Class.h:198
EClassFlags m_ClassFlags
Definition Class.h:123
FORCEINLINE size_t GetMinAlignment() const
Definition Class.h:183
UObject * GetDefaultObject(bool bCreateIfNeeded=true) const
Definition Class.h:153
FORCEINLINE bool HasAnyClassFlags(EClassFlags FlagsToCheck) const
Definition Class.h:137
virtual void SetupObjectInitializer(FObjectInitializer &ObjectInitializer) const
Definition Class.h:146
ClassConstructorType m_ClassConstructor
Definition Class.h:120
Definition Class.h:17
FORCEINLINE bool IsA(OtherClassType SomeBase) const
Definition UObjectBase.h:187
The base class of all the game code relevant objects.
Definition Object.h:106
Definition Class.h:49
FORCEINLINE size_t GetPropertiesSize() const
Definition Class.h:64
size_t m_MinAlignment
Definition Class.h:92
UStruct * GetSuperStruct() const
Definition Class.h:58
size_t m_PropertiesSize
Definition Class.h:88