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

The base class of a widget without children: an Entity that creates its components when it is constructed. More...

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

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

Public Member Functions

 EntityFiller (ComponentRegistry &componentRegistry)
 Create the entity, its listed components and its components::Hierarchy.
virtual ~EntityFiller (void)=default
 Destroy the entity object; its 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.

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::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::EntityFiller< ComponentTypes >

The base class of a widget without children: an Entity that creates its components when it is constructed.

The constructor does three things for the new entity:

  1. sets its signature to the listed component types, so the systems that need them visit it;
  2. creates one default component of each listed type in the registry;
  3. gives it a components::Hierarchy (added to the signature too), so Entity::setParent keeps the tree readable from components.
class Label:
public ecs::EntityFiller<components::Transform, components::Bound,
components::Text>
{
public:
Label(ecs::ComponentRegistry &registry)
: ecs::EntityFiller<components::Transform, components::Bound,
components::Text>(registry)
{
}
};
auto label = std::make_shared<Label>(scene.getComponentRegistry());
scene.getEntityRegistry().addEntity(label);
Stores every component of a scene, per component type and per entity identifier, and knows which ones...
The base class of a widget without children: an Entity that creates its components when it is constru...
EntityFiller(ComponentRegistry &componentRegistry)
Create the entity, its listed components and its components::Hierarchy.
State. Every class here is plain data attached to an entity.
The entity-component-system core, independent of any widget.
Definition component.hpp:28

Things to watch out for:

Template Parameters
ComponentTypesThe component types the entity starts with.
See also
Entity
ParentEntityFiller
ComponentRegistry

Definition at line 71 of file entity_filler.hpp.

Constructor & Destructor Documentation

◆ EntityFiller()

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

Create the entity, its listed components and its components::Hierarchy.

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::EntityFiller< 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::EntityFiller< 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: