20#if defined(__EMSCRIPTEN__) or defined(__APPLE__)
49 namespace Construction
66 return createInstanceImpl<T>(std::is_constructible<T>());
72 delete reinterpret_cast<T *
>(t);
78 return new (memory)
T();
90 return constructInstanceImpl<T>(memory, std::is_constructible<T>());
97 reinterpret_cast<T *
>(t)->~
T();
110 static void initializeBaseTypes();
125 return createType(getName<T>(),
127 &Construction::createInstance<T>,
128 &Construction::destroyInstance<T>,
129 &Construction::constructInstance<T>,
130 &Construction::destructInstance<T>,
131 isAbstract || std::is_enum<T>::value);
142 return createType(getName<T>(),
154 static const Type & getType(
const TypeId typeId);
159 static const Type & getType(
const Name & name);
170 static auto typeId = getType(getName<T>()).
typeId;
172 auto & type = getType(typeId);
187 static void constructInstance(
const Type & type,
void * data,
const size_t dataSize);
197 static void destructInstance(
const Type & type,
void * data);
208 auto & type = getType(name);
210 auto object =
reinterpret_cast<T *
>(createInstance(type));
220 static void * createInstance(
const Type & type);
230 static const Type * getTypes(
size_t & count);
239 bool isAbstract =
false);
#define COGSFOUNDATION_API
Definition: FoundationBase.h:31
Cogs::StringView getNameImpl(bool *)
Definition: TypeDatabase.h:7
Manages all Type instances currently created in the system.
Definition: TypeDatabase.h:105
static Type & createAbstractType()
Create a new abstract Type from the provided template type.
Definition: TypeDatabase.h:140
static T * createInstance(const StringView &name)
Create an instance of the type with the given name.
Definition: TypeDatabase.h:206
static const Type & getType()
Get the Type of the given template argument.
Definition: TypeDatabase.h:168
static std::unique_ptr< class TypeStore > typeStore
Stores registered types.
Definition: TypeDatabase.h:243
static Type & createType(bool isAbstract=false)
Create a new Type from the provided template type.
Definition: TypeDatabase.h:123
Represents a discrete type definition, describing a native type class.
Definition: Type.h:89
TypeId typeId
Unique type id for this type.
Definition: Type.h:353
Provides a weakly referenced view over the contents of a string.
Definition: StringView.h:24
void * createInstanceImpl(std::false_type)
Definition: TypeDatabase.h:52
void destructInstance(void *t)
Definition: TypeDatabase.h:94
void * createInstance()
Definition: TypeDatabase.h:64
void * constructInstance(void *memory)
Definition: TypeDatabase.h:88
void destroyInstance(void *t)
Definition: TypeDatabase.h:70
void * constructInstanceImpl(void *memory, std::true_type)
Definition: TypeDatabase.h:76
uint16_t TypeId
Built in type used to uniquely identify a single type instance.
Definition: Name.h:48
void(*)(void *) DestroyInstance
Object destroy function type. Comparable to regular delete.
Definition: Name.h:42
void *(*)(void *) ConstructInstance
Object construction function type. Comparable to placement new.
Definition: Name.h:39
void *(*)() CreateInstance
Object creation function type. Comparable to regular new.
Definition: Name.h:36
void(*)(void *) DestructInstance
Object destruction function type. Comparable to calling the destructor.
Definition: Name.h:45
Main Cogs namespace.
Definition: MortonCode.h:5
Represents an unique name.
Definition: Name.h:70