31#include <utility/logging/loggable.hpp>
32#include <utility/logging/default_logger.hpp>
33#include <utility/demangle.hpp>
35#include "guillaume/ecs/component.hpp"
36#include "guillaume/ecs/component_registry.hpp"
37#include "guillaume/ecs/component_type_id.hpp"
38#include "guillaume/ecs/entity.hpp"
39#include "guillaume/ecs/entity_registry.hpp"
40#include "guillaume/ecs/system_phase.hpp"
41#include "guillaume/ecs/entity_tree_traveler.hpp"
117 protected utility::logging::Loggable<System,
118 utility::logging::DefaultLogger>
191 template<InheritFromComponent ComponentType>
bool
205 template<InheritFromComponent ComponentType> ComponentType &
218 template<InheritFromComponent ComponentType>
const ComponentType &
236 template<InheritFromComponent ComponentType>
350 template<
typename Type>
356#include "guillaume/ecs/system.tpp"
Stores every component of a scene, per component type and per entity identifier, and knows which ones...
Owns entities and gives the systems the list of entities to visit.
Decides in which order the entities of a scene are visited.
std::bitset< 128 > Signature
A set of component types, one bit per type (bit position given by ComponentTypeId,...
std::size_t Identifier
The key under which an entity's components are stored. Systems and components refer to entities by th...
Phase getPhase(void) const noexcept
Get the phase of the frame in which the system runs.
const ComponentType & getComponent(const ecs::Entity::Identifier &entityIdentifier) const
Get a component of an entity from the bound registry, read-only.
virtual void cleanup(void)
Called once per pass, after the last update().
ecs::EntityRegistry & getEntityRegistry(void)
Get the entity registry of the scene being processed.
void unbindComponentRegistry(void)
Drop the binding made by bindComponentRegistry().
ecs::ComponentRegistry & getComponentRegistry(void)
Get the component registry of the scene being processed.
void setSignature(void)
Replace the signature by the one made of the given component types.
bool hasComponent(const ecs::Entity::Identifier &entityIdentifier) const
Tell whether an entity has a component, in the bound registry.
virtual void prepare(void)
Called once per pass, before the first update().
ComponentType & getComponent(const ecs::Entity::Identifier &entityIdentifier)
Get a component of an entity from the bound registry, to read or modify it.
bool requireComponent(const ecs::Entity::Identifier &entityIdentifier)
Tell whether an entity has a component, and log a warning naming the entity and the component when it...
virtual ~System(void)=default
Virtual destructor.
System(Phase phase)
Create a system that runs in a given phase, with an empty signature.
void routine(ecs::ComponentRegistry &componentRegistry, ecs::EntityRegistry &entityRegistry, const ecs::EntityTreeTraveler &traveler)
Run the system once over a scene: prepare(), update() on each matching entity, cleanup().
void bindComponentRegistry(ecs::ComponentRegistry &componentRegistry)
Bind a component registry so update() can be called directly, without routine().
Entity::Signature getSignature(void) const noexcept
Get the component types an entity must declare to be visited by this system.
virtual void update(const ecs::Entity::Identifier &entityIdentifier)=0
Apply the system's rule to one entity. Implemented by each system.
Constrains a template parameter to a type derived from Component (or Component itself).
Constrains a template parameter to a type derived from System.
The entity-component-system core, independent of any widget.
Phase
The four steps of a frame. Every system belongs to one of them.