31#include "guillaume/ecs/entity.hpp"
84 mutable std::vector<std::shared_ptr<Entity>> _bfsCache;
90 mutable std::size_t _cachedVersion { 0 };
105 std::vector<Entity::Identifier> &orphans);
113 void clearOwned(std::vector<Entity::Identifier> &orphans);
121 virtual std::vector<std::shared_ptr<Entity>> &
129 virtual const std::vector<std::shared_ptr<Entity>> &
156 void addEntity(std::shared_ptr<Entity> entity);
196 const std::vector<std::shared_ptr<Entity>> &
getEntities(
void)
const
219 std::vector<std::shared_ptr<Entity>>
234 template<InheritFromEntity EntityType>
241 if (entity->getIdentifier() == identifier) {
242 return std::dynamic_pointer_cast<EntityType>(entity);
259 template<InheritFromEntity EntityType> std::shared_ptr<const EntityType>
266 if (entity->getIdentifier() == identifier) {
267 return std::dynamic_pointer_cast<const EntityType>(entity);
284 std::vector<Entity::Identifier>
300 std::vector<Entity::Identifier>
virtual ~EntityRegistry(void)=default
Virtual destructor.
virtual std::vector< std::shared_ptr< Entity > > & accessDirectEntities(void)=0
Give access to the list of entities this registry owns directly. Implemented by the class that provid...
std::vector< Entity::Identifier > getEntityWithSignature(Entity::Signature systemSignature) const
List the entities that have every component type of a signature, from the root down.
bool removeEntity(Entity::Identifier identifier)
Remove an entity, with its children and all their components.
virtual const std::vector< std::shared_ptr< Entity > > & accessDirectEntities(void) const =0
Give read access to the list of entities this registry owns directly.
std::vector< std::shared_ptr< Entity > > getEntitiesBreadthFirst(void)
List every entity of this registry and of the registries nested in it, level by level.
EntityRegistry(void)=default
Create a registry.
void addEntity(std::shared_ptr< Entity > entity)
Make this registry own an entity, so that it stays alive and systems visit it.
std::shared_ptr< EntityType > getEntity(Entity::Identifier identifier)
Find an entity owned directly by this registry, by identifier.
const std::vector< std::shared_ptr< Entity > > & getEntities(void) const
Get the entities this registry owns directly.
std::shared_ptr< const EntityType > getEntity(Entity::Identifier identifier) const
Find an entity owned directly by this registry, by identifier (const overload).
void clearEntities(void)
Remove every entity owned by this registry, with everything they own and all their components.
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...
static constexpr Identifier InvalidIdentifier
"No entity": never the identifier of a real entity
The entity-component-system core, independent of any widget.