33#include <utility/logging/loggable.hpp>
34#include <utility/logging/default_logger.hpp>
36#include <utility/demangle.hpp>
38#include "guillaume/ecs/component.hpp"
39#include "guillaume/ecs/component_storage.hpp"
40#include "guillaume/ecs/entity.hpp"
53 template<InheritFromComponent ComponentType>
60 std::string _componentTypeName {
61 utility::demangle<ComponentType>()
64 mutable std::string _message;
80 const char *
what(
void)
const noexcept override;
134 public utility::logging::Loggable<ComponentRegistry,
135 utility::logging::DefaultLogger>
138 std::map<std::type_index, std::unique_ptr<IComponentStorage>>
147 template<InheritFromComponent ComponentType>
157 template<InheritFromComponent ComponentType>
169 template<InheritFromComponent ComponentType>
224 template<InheritFromComponent ComponentType>
233 template<InheritFromComponent ComponentType>
274 template<InheritFromComponent ComponentType>
286 template<InheritFromComponent ComponentType>
const ComponentType &
295 template<
typename Type>
297 std::is_base_of_v<ComponentRegistry, Type>;
302#include "guillaume/ecs/component_registry.tpp"
void registerComponentsForEntity(const Entity::Identifier &entityIdentifier)
Give an entity one default-constructed component of each listed type.
void removeEntity(const Entity::Identifier &entityIdentifier)
Delete every component of an entity, of every type.
void resetChangedFlags(void)
Mark every component of every entity as unchanged.
ComponentType & getComponent(const Entity::Identifier &entityIdentifier)
Get a component of an entity, to read or modify it.
const ComponentType & getComponent(const Entity::Identifier &entityIdentifier) const
Get a component of an entity, read-only.
void removeComponent(const Entity::Identifier &entityIdentifier)
Delete one component of an entity. Does nothing when the entity does not have it.
ComponentType & addComponent(const Entity::Identifier &entityIdentifier, Args &&...args)
Construct a component for an entity, replacing the one it already has, if any.
~ComponentRegistry(void)=default
Destroy the registry and every component it stores.
ComponentRegistry(void)=default
Create a registry that holds no component.
bool hasComponent(const Entity::Identifier &entityIdentifier) const
Tell whether an entity has a component of a given type.
bool hasChanged(const Entity::Identifier &entityIdentifier) const
Tell whether at least one component of an entity was modified since the flags were last reset.
void registerNewComponentType(void)
Create the (empty) storage of a component type ahead of its first use.
Holds every component of one type, indexed by entity identifier.
const char * what(void) const noexcept override
Get the exception message.
EntityComponentNotFoundException(const Entity::Identifier &entityIdentifier)
Build the exception and its message.
std::size_t Identifier
The key under which an entity's components are stored. Systems and components refer to entities by th...
Constrains a template parameter to a type derived from ComponentRegistry (or ComponentRegistry itself...
Constrains a template parameter to a type derived from Component (or Component itself).
The entity-component-system core, independent of any widget.