Cogs.Foundation
|
Manages all Type instances currently created in the system. More...
#include <TypeDatabase.h>
Public Member Functions | |
~TypeDatabase () | |
Static Public Member Functions | |
static void | initializeBaseTypes () |
Initialize the set of types describing built in C++ types like int, float etc. | |
static void | clear () |
Clear the database, removing all existing types. Invalidates all existing Reflection::TypeId instances. | |
template<typename T > | |
static Type & | createType (bool isAbstract=false) |
Create a new Type from the provided template type. | |
template<typename T > | |
static Type & | createAbstractType () |
Create a new abstract Type from the provided template type. | |
static const Type & | getType (const TypeId typeId) |
Get the Type with the given type id. | |
static const Type & | getType (const Name &name) |
Get the Type with the given unique name. | |
template<typename T > | |
static const Type & | getType () |
Get the Type of the given template argument. | |
static void | constructInstance (const Type &type, void *data, const size_t dataSize) |
Construct an instance of the given type into the given data. | |
static void | destructInstance (const Type &type, void *data) |
Destruct an instance of the given type located in data. | |
template<typename T > | |
static T * | createInstance (const StringView &name) |
Create an instance of the type with the given name. | |
static void * | createInstance (const Type &type) |
Create an instance of the given type. | |
static const Type * | getTypes (size_t &count) |
Get a pointer to the array of types currently in the type database. | |
static Type & | createType (const StringView &name, size_t size, CreateInstance createInstance, DestroyInstance destroyInstance, ConstructInstance constructInstance, DestructInstance destructInstance, bool isAbstract=false) |
Create a new type from the native type with the given name. | |
Static Private Attributes | |
static std::unique_ptr< class TypeStore > | typeStore = std::make_unique<TypeStore>() |
Stores registered types. | |
Manages all Type instances currently created in the system.
Cogs::Reflection::TypeDatabase::~TypeDatabase | ( | ) |
|
static |
Clear the database, removing all existing types. Invalidates all existing Reflection::TypeId instances.
|
static |
Construct an instance of the given type into the given data.
The instance will be constructed using placement new into the provided storage.
type | A reference to a non-abstract type. |
data | Pointer to data where an instance of type can be constructed. |
dataSize | Size of the pointed-to memory area. Used to ensure there is enough space to construct the instance. |
References Cogs::Reflection::Type::constructInstance, Cogs::Reflection::Type::getSize(), and Cogs::Reflection::Type::isValid().
Referenced by Cogs::ComponentModel::ComponentPoolBase::allocateComponent().
|
inlinestatic |
|
static |
Create an instance of the given type.
References Cogs::Reflection::Type::createInstance.
|
inlinestatic |
Create a new Type from the provided template type.
isAbstract | A boolean indicating if the type should be abstract. Abstract types can not be instantiated. |
T | The type of class/struct to create a new type from. Must provide specialization of the getName function. |
References Cogs::T.
|
static |
Create a new type from the native type with the given name.
References debug_assert, and Cogs::StringView::empty().
|
static |
Destruct an instance of the given type located in data.
No memory will be freed by this operation, just invoking the destructor.
type | A reference to the type used to construct the element. |
data | Pointer to the location in memory of the instance to destruct. |
References Cogs::Reflection::Type::destructInstance.
Referenced by Cogs::ComponentModel::ComponentPoolBase::deallocateComponent().
Get the Type of the given template argument.
T | Template type to find the corresponding Type for. Must provide specialization of the getName function. |
References Cogs::Reflection::Type::typeId.
Referenced by Cogs::ComponentModel::ComponentPoolBase::allocateComponent(), Cogs::ComponentModel::ComponentPoolBase::ComponentPoolBase(), Cogs::ComponentModel::ComponentPoolBase::deallocateComponent(), Cogs::Reflection::Type::getBase(), Cogs::ComponentModel::Entity::getComponent(), Cogs::ComponentModel::Entity::getComponentHandle(), Cogs::ComponentModel::Entity::getComponents(), Cogs::ComponentModel::Component::getComponentTypeId(), Cogs::Reflection::Type::getFieldId(), and Cogs::ComponentModel::Component::getType().
|
static |
Get the Type with the given unique name.
References Cogs::Reflection::Name::getId().
|
static |
Get the Type with the given type id.
References debug_assert, and Cogs::Reflection::NoType.
|
static |
Get a pointer to the array of types currently in the type database.
count | Returns the count of available types. Can be used to iterate over the type array. |
References Cogs::Reflection::Type::size.
|
static |
Initialize the set of types describing built in C++ types like int, float etc.
|
staticprivate |
Stores registered types.