25#include <unordered_map>
28#include "guillaume/ecs/component.hpp"
29#include "guillaume/ecs/entity.hpp"
101 using Storage = std::unordered_map<Entity::Identifier, ComponentType>;
128 template<
typename... Args> ComponentType &
145 const ComponentType *
181#include "guillaume/ecs/component_storage.tpp"
void resetChangedFlags(void) override
Mark every component of this storage as unchanged.
void remove(const Entity::Identifier &entityIdentifier) override
Delete the component stored for an entity. Does nothing when the entity has none.
bool has(const Entity::Identifier &entityIdentifier) const override
Tell whether a component is stored for an entity.
ComponentType & emplace(const Entity::Identifier &entityIdentifier, Args &&...args)
Construct a component for an entity, replacing the one it already has, if any.
bool hasChanged(const Entity::Identifier &entityIdentifier) const override
Tell whether the component stored for an entity is marked as changed.
const ComponentType * find(const Entity::Identifier &entityIdentifier) const
Look up the component of an entity, read-only.
ComponentType * find(const Entity::Identifier &entityIdentifier)
Look up the component of an entity.
~ComponentStorage(void) override=default
Destroy the storage and every component it holds.
ComponentStorage(void)=default
Create an empty storage.
std::unordered_map< Entity::Identifier, ComponentType > Storage
The container: one component per entity identifier.
std::size_t Identifier
The key under which an entity's components are stored. Systems and components refer to entities by th...
What ComponentRegistry can do with a component storage without knowing which component type it holds.
virtual bool has(const Entity::Identifier &entityIdentifier) const =0
Tell whether a component is stored for an entity.
virtual void resetChangedFlags(void)=0
Mark every component of this storage as unchanged.
virtual bool hasChanged(const Entity::Identifier &entityIdentifier) const =0
Tell whether the component stored for an entity is marked as changed.
virtual void remove(const Entity::Identifier &entityIdentifier)=0
Delete the component stored for an entity. Does nothing when the entity has none.
virtual ~IComponentStorage(void)=default
Virtual destructor.
The entity-component-system core, independent of any widget.