guillaume 2026.6.1
A C++ UI framework designed for modern desktop and extended reality (XR) applications.
Loading...
Searching...
No Matches
guillaume::ecs::ParentEntityFiller< ComponentTypes > Class Template Reference

The base class of a widget with children: an EntityFiller that is also a ParentEntity. More...

#include <headers/guillaume/ecs/parent_entity_filler.hpp>

Inheritance diagram for guillaume::ecs::ParentEntityFiller< ComponentTypes >:
Collaboration diagram for guillaume::ecs::ParentEntityFiller< ComponentTypes >:

Public Member Functions

 ParentEntityFiller (ComponentRegistry &componentRegistry)
 Create the entity, its listed components and its components::Hierarchy. It owns no child yet.
virtual ~ParentEntityFiller (void)=default
 Destroy the entity object and release the children it owns; components stay in the registry (see EntityRegistry::removeEntity).
Public Member Functions inherited from guillaume::ecs::Entity
 Entity (void)
 Create an entity with a fresh identifier, an empty signature, no parent and no component.
virtual ~Entity (void)=default
 Destroy the entity object.
Entity::Identifier getIdentifier (void) const noexcept
 Get the identifier of the entity.
Entity::Signature getSignature (void) const noexcept
 Get the set of component types the entity declares.
void setSignature (const Signature &signature)
 Replace the signature of the entity.
std::int32_t getLayer (void) const noexcept
 Get the depth of the entity in the tree.
Entity & setParent (std::shared_ptr< Entity > parent)
 Attach the entity under another one, or detach it.
std::vector< Identifier > releaseComponents (void)
 Drop the entity's place in the tree and all its components.
std::shared_ptr< Entity > getParent (void) const noexcept
 Get the parent entity.
Public Member Functions inherited from guillaume::ecs::EntityRegistry
 EntityRegistry (void)=default
 Create a registry.
virtual ~EntityRegistry (void)=default
 Virtual destructor.
void addEntity (std::shared_ptr< Entity > entity)
 Make this registry own an entity, so that it stays alive and systems visit it.
bool removeEntity (Entity::Identifier identifier)
 Remove an entity, with its children and all their components.
void clearEntities (void)
 Remove every entity owned by this registry, with everything they own and all their components.
const std::vector< std::shared_ptr< Entity > > & getEntities (void) const
 Get the 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.
std::vector< std::shared_ptr< Entity > > getEntitiesBreadthFirst (void) const
 List every entity of this registry and of the registries nested in it, level by level (const overload).
template<InheritFromEntity EntityType>
std::shared_ptr< EntityType > getEntity (Entity::Identifier identifier)
 Find an entity owned directly by this registry, by identifier.
template<InheritFromEntity EntityType>
std::shared_ptr< const EntityType > getEntity (Entity::Identifier identifier) const
 Find an entity owned directly by this registry, by identifier (const overload).
std::vector< Entity::Identifier > getEntityWithSignature (Entity::Signature systemSignature) const
 List the entities that have every component type of a signature, from the root down.
std::vector< Entity::Identifier > getEntityWithSignature (Entity::Signature systemSignature, const EntityTreeTraveler &traveler) const
 List the entities that have every component type of a signature, in the order chosen by a traveler.

Protected Member Functions

ComponentRegistry & getComponentRegistry (void)
 Get the registry that stores this entity's components.
const ComponentRegistry & getComponentRegistry (void) const
 Get the registry that stores this entity's components, read-only.
Protected Member Functions inherited from guillaume::ecs::ParentEntity
std::vector< std::shared_ptr< Entity > > & accessDirectEntities (void) override
 Give access to the list of entities this entity owns directly.
const std::vector< std::shared_ptr< Entity > > & accessDirectEntities (void) const override
 Give read access to the list of entities this entity owns directly.
Protected Member Functions inherited from guillaume::ecs::Entity
void attachHierarchy (ComponentRegistry &componentRegistry)
 Give the entity a components::Hierarchy in a registry and add that component to its signature.
template<InheritFromComponent... ComponentTypes>
void setSignature (void)
 Replace the signature by the one made of the given component types.

Additional Inherited Members

Public Types inherited from guillaume::ecs::Entity
using Identifier = std::size_t
 The key under which an entity's components are stored. Systems and components refer to entities by this value.
using Signature = std::bitset<128>
 A set of component types, one bit per type (bit position given by ComponentTypeId, MaxComponentTypes bits).
Static Public Member Functions inherited from guillaume::ecs::Entity
template<InheritFromComponent... ComponentTypes>
static Signature getSignatureFromTypes (void)
 Build the signature that has exactly the bits of the given component types.
Static Public Attributes inherited from guillaume::ecs::Entity
static constexpr Identifier InvalidIdentifier
 "No entity": never the identifier of a real entity

Detailed Description

template<InheritFromComponent... ComponentTypes>
class guillaume::ecs::ParentEntityFiller< ComponentTypes >

The base class of a widget with children: an EntityFiller that is also a ParentEntity.

Like EntityFiller, the constructor sets the signature, creates one default component of each listed type and attaches a components::Hierarchy. In addition the entity owns child entities (EntityRegistry::addEntity) and the systems reach them through it.

class Row:
public ecs::ParentEntityFiller<components::Transform,
components::Bound, components::Layout>,
public std::enable_shared_from_this<Row>
{
public:
void add(std::shared_ptr<ecs::Entity> child)
{
child->setParent(shared_from_this());
addEntity(child);
}
};
void addEntity(std::shared_ptr< Entity > entity)
Make this registry own an entity, so that it stays alive and systems visit it.
The base class of a widget with children: an EntityFiller that is also a ParentEntity.
ParentEntityFiller(ComponentRegistry &componentRegistry)
Create the entity, its listed components and its components::Hierarchy. It owns no child yet.
Template Parameters
ComponentTypesThe component types the entity starts with.
See also
EntityFiller
ParentEntity

Definition at line 61 of file parent_entity_filler.hpp.

Constructor & Destructor Documentation

◆ ParentEntityFiller()

template<InheritFromComponent... ComponentTypes>
guillaume::ecs::ParentEntityFiller< ComponentTypes >::ParentEntityFiller ( ComponentRegistry & componentRegistry)

Create the entity, its listed components and its components::Hierarchy. It owns no child yet.

Parameters
componentRegistryThe registry in which the components are created, normally the scene's. It must outlive the entity.
Exceptions
ComponentTypeLimitExceededExceptionWhen more than MaxComponentTypes component types are in use.

Member Function Documentation

◆ getComponentRegistry() [1/2]

template<InheritFromComponent... ComponentTypes>
ComponentRegistry & guillaume::ecs::ParentEntityFiller< ComponentTypes >::getComponentRegistry ( void )
protected

Get the registry that stores this entity's components.

Returns
Reference to the registry given to the constructor.

◆ getComponentRegistry() [2/2]

template<InheritFromComponent... ComponentTypes>
const ComponentRegistry & guillaume::ecs::ParentEntityFiller< ComponentTypes >::getComponentRegistry ( void ) const
protected

Get the registry that stores this entity's components, read-only.

Returns
Const reference to the registry given to the constructor.

The documentation for this class was generated from the following file: