8template<>
inline Cogs::StringView getNameImpl(std::string *) {
return "string"; }
11template<>
inline Cogs::StringView getNameImpl(int16_t *) {
return "int16_t"; }
12template<>
inline Cogs::StringView getNameImpl(int32_t *) {
return "int32_t"; }
13template<>
inline Cogs::StringView getNameImpl(int64_t *) {
return "int64_t"; }
15template<>
inline Cogs::StringView getNameImpl(uint8_t *) {
return "uint8_t"; }
16template<>
inline Cogs::StringView getNameImpl(uint16_t *) {
return "uint16_t"; }
17template<>
inline Cogs::StringView getNameImpl(uint32_t *) {
return "uint32_t"; }
18template<>
inline Cogs::StringView getNameImpl(uint64_t *) {
return "uint64_t"; }
20#if defined(__EMSCRIPTEN__) or defined(__APPLE__)
28template<>
inline Cogs::StringView getNameImpl(std::vector<std::string> *) {
return "vector<string>"; }
30template<>
inline Cogs::StringView getNameImpl(std::vector<int8_t> *) {
return "vector<int8_t>"; }
31template<>
inline Cogs::StringView getNameImpl(std::vector<int16_t> *) {
return "vector<int16_t>"; }
32template<>
inline Cogs::StringView getNameImpl(std::vector<int32_t> *) {
return "vector<int32_t>"; }
33template<>
inline Cogs::StringView getNameImpl(std::vector<int64_t> *) {
return "vector<int64_t>"; }
35template<>
inline Cogs::StringView getNameImpl(std::vector<uint8_t> *) {
return "vector<uint8_t>"; }
36template<>
inline Cogs::StringView getNameImpl(std::vector<uint16_t> *) {
return "vector<uint16_t>"; }
37template<>
inline Cogs::StringView getNameImpl(std::vector<uint32_t> *) {
return "vector<uint32_t>"; }
38template<>
inline Cogs::StringView getNameImpl(std::vector<uint64_t> *) {
return "vector<uint64_t>"; }
40template<>
inline Cogs::StringView getNameImpl(std::vector<float> *) {
return "vector<float>"; }
41template<>
inline Cogs::StringView getNameImpl(std::vector<double> *) {
return "vector<double>"; }
49 namespace Construction
52 void * createInstanceImpl(std::false_type)
58 void * createInstanceImpl(std::true_type)
64 void * createInstance()
66 return createInstanceImpl<T>(std::is_constructible<T>());
70 void destroyInstance(
void * t)
72 delete reinterpret_cast<T *
>(t);
76 void * constructInstanceImpl(
void * memory, std::true_type)
78 return new (memory) T();
82 void * constructInstanceImpl(
void *, std::false_type)
88 void * constructInstance(
void * memory)
90 return constructInstanceImpl<T>(memory, std::is_constructible<T>());
94 void destructInstance(
void * 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);
Manages all Type instances currently created in the system.
static Type & createAbstractType()
Create a new abstract Type from the provided template type.
static T * createInstance(const StringView &name)
Create an instance of the type with the given name.
static const Type & getType()
Get the Type of the given template argument.
static std::unique_ptr< class TypeStore > typeStore
Stores registered types.
static Type & createType(bool isAbstract=false)
Create a new Type from the provided template type.
Represents a discrete type definition, describing a native type class.
TypeId typeId
Unique type id for this type.
Provides a weakly referenced view over the contents of a string.
uint16_t TypeId
Built in type used to uniquely identify a single type instance.
void(*)(void *) DestroyInstance
Object destroy function type. Comparable to regular delete.
void *(*)(void *) ConstructInstance
Object construction function type. Comparable to placement new.
void *(*)() CreateInstance
Object creation function type. Comparable to regular new.
void(*)(void *) DestructInstance
Object destruction function type. Comparable to calling the destructor.
Contains all Cogs related functionality.
Represents an unique name.