cubos::core::ecs::Types class final

Registry of all data types used in an ECS world.

Public functions

void reset()
Resets the registry to its initial state.
void addResource(const reflection::Type& type)
Registers a resource type.
void addComponent(const reflection::Type& type)
Registers a component type.
void addRelation(const reflection::Type& type)
Registers a relation type.
void remove(const reflection::Type& type)
Unregisters a data type.
auto id(const reflection::Type& type) const -> DataTypeId
Gets the identifier of a data type.
template<typename T>
auto id() const -> DataTypeId
Gets the identifier of a data type.
auto id(const std::string& name) const -> DataTypeId
Gets the identifier of a data type.
auto type(DataTypeId id) const -> const reflection::Type&
Gets a data type from its identifier.
auto contains(const reflection::Type& type) const -> bool
Checks if a data type is registered.
auto contains(const std::string& name) const -> bool
Checks if a data type is registered.
auto isResource(DataTypeId id) const -> bool
Checks if the given data type is a resource.
auto isComponent(DataTypeId id) const -> bool
Checks if the given data type is a component.
auto isRelation(DataTypeId id) const -> bool
Checks if the given data type is a relation.
auto isSymmetricRelation(DataTypeId id) const -> bool
Checks if the given data type is a symmetric relation.
auto isTreeRelation(DataTypeId id) const -> bool
Checks if the given data type is a tree relation.
auto resources() const -> reflection::TypeRegistry
Gets a type registry with only the resource types.
auto components() const -> reflection::TypeRegistry
Gets a type registry with only the component types.
auto relations() const -> reflection::TypeRegistry
Gets a type registry with only the relation types.

Function documentation

void cubos::core::ecs::Types::reset()

Resets the registry to its initial state.

Previously returned identifiers become invalid, as they might be reused.

void cubos::core::ecs::Types::addResource(const reflection::Type& type)

Registers a resource type.

Parameters
type Resource type.

void cubos::core::ecs::Types::addComponent(const reflection::Type& type)

Registers a component type.

Parameters
type Component type.

void cubos::core::ecs::Types::addRelation(const reflection::Type& type)

Registers a relation type.

Parameters
type Relation type.

void cubos::core::ecs::Types::remove(const reflection::Type& type)

Unregisters a data type.

Parameters
type Data type.

DataTypeId cubos::core::ecs::Types::id(const reflection::Type& type) const

Gets the identifier of a data type.

Parameters
type Data type.
Returns Data type identifier.

Aborts if the data type is not registered.

template<typename T>
DataTypeId cubos::core::ecs::Types::id() const

Gets the identifier of a data type.

Template parameters
T Data type.
Returns Data type identifier.

Aborts if the data type is not registered.

DataTypeId cubos::core::ecs::Types::id(const std::string& name) const

Gets the identifier of a data type.

Parameters
name Data type name.
Returns Data type identifier.

Aborts if the data type is not registered.

const reflection::Type& cubos::core::ecs::Types::type(DataTypeId id) const

Gets a data type from its identifier.

Parameters
id Data type identifier.
Returns Data type.

bool cubos::core::ecs::Types::contains(const reflection::Type& type) const

Checks if a data type is registered.

Parameters
type Data type.
Returns Whether the data type is registered.

bool cubos::core::ecs::Types::contains(const std::string& name) const

Checks if a data type is registered.

Parameters
name Data type name.
Returns Whether the data type is registered.

bool cubos::core::ecs::Types::isResource(DataTypeId id) const

Checks if the given data type is a resource.

Parameters
id Data type identifier.
Returns Whether the identifier refers to a resource.

bool cubos::core::ecs::Types::isComponent(DataTypeId id) const

Checks if the given data type is a component.

Parameters
id Data type identifier.
Returns Whether the identifier refers to a component.

bool cubos::core::ecs::Types::isRelation(DataTypeId id) const

Checks if the given data type is a relation.

Parameters
id Data type identifier.
Returns Whether the identifier refers to a relation.

bool cubos::core::ecs::Types::isSymmetricRelation(DataTypeId id) const

Checks if the given data type is a symmetric relation.

Parameters
id Data type identifier.
Returns Whether the identifier refers to a symmetric relation.

bool cubos::core::ecs::Types::isTreeRelation(DataTypeId id) const

Checks if the given data type is a tree relation.

Parameters
id Data type identifier.
Returns Whether the identifier refers to a tree relation.

reflection::TypeRegistry cubos::core::ecs::Types::resources() const

Gets a type registry with only the resource types.

Returns Resource type registry.

reflection::TypeRegistry cubos::core::ecs::Types::components() const

Gets a type registry with only the component types.

Returns Component type registry.

reflection::TypeRegistry cubos::core::ecs::Types::relations() const

Gets a type registry with only the relation types.

Returns Relation type registry.