guillaume 2026.6.1
A C++ UI framework designed for modern desktop and extended reality (XR) applications.
Loading...
Searching...
No Matches
guillaume::entities::EntityBuilderBase< EntityType > Class Template Referenceabstract

Base of every widget Builder: turns a configuration into a widget that is attached to a parent and owned by an entity registry. More...

#include <headers/guillaume/entities/builder_base.hpp>

Inheritance diagram for guillaume::entities::EntityBuilderBase< EntityType >:
Collaboration diagram for guillaume::entities::EntityBuilderBase< EntityType >:

Public Member Functions

 EntityBuilderBase (ecs::ComponentRegistry &componentRegistry, ecs::EntityRegistry &entityRegistry)
 Construct a builder bound to two registries.
 ~EntityBuilderBase (void) override=default
 Default destructor.
std::shared_ptr< EntityType > registerEntity (std::shared_ptr< ecs::Entity > parent)
 Build the widget, attach it to its parent, hand it to the entity registry, then reset the builder to its defaults.
Public Member Functions inherited from guillaume::ecs::EntityBuilder
 EntityBuilder (ecs::ComponentRegistry &componentRegistry, ecs::EntityRegistry &entityRegistry)
 Create a builder working on a pair of registries, normally those of one scene.
virtual ~EntityBuilder (void)=default
 Virtual destructor.
virtual void reset (void)=0
 Forget the configuration accumulated for the entity being built, so the builder is ready for the next one.

Protected Member Functions

virtual std::shared_ptr< EntityType > buildEntity (void)=0
 Create the widget from the current configuration.
Protected Member Functions inherited from guillaume::ecs::EntityBuilder
ComponentRegistry & getComponentRegistry (void)
 Get the registry in which the builder creates components.
EntityRegistry & getEntityRegistry (void)
 Get the registry in which the builder registers the entities it creates.

Detailed Description

template<typename EntityType>
class guillaume::entities::EntityBuilderBase< EntityType >

Base of every widget Builder: turns a configuration into a widget that is attached to a parent and owned by an entity registry.

A concrete builder (Button::Builder, Checkbox::Builder, ...) stores the configuration in its fields, exposes with...() setters and make...() shortcuts, and implements two hooks: buildEntity(), which creates the widget from the fields, and reset(), which restores the default configuration. registerEntity() does the rest.

auto surface = builder.withElevation(theme::ElevationLevel::Level2)
.registerEntity(nullptr);
EntityRegistry & getEntityRegistry(void)
Get the registry in which the builder registers the entities it creates.
ComponentRegistry & getComponentRegistry(void)
Get the registry in which the builder creates components.
Configures and registers Surface widgets.
Definition surface.hpp:403
@ Level2
Second raised level.
Definition tokens.hpp:133

One builder can create several widgets in a row: it is back to its defaults after each registerEntity(), so nothing leaks from one widget to the next.

Template Parameters
EntityTypeThe widget class the builder creates.
See also
ecs::EntityBuilder, ecs::EntityRegistry

Definition at line 58 of file builder_base.hpp.

Constructor & Destructor Documentation

◆ EntityBuilderBase()

template<typename EntityType>
guillaume::entities::EntityBuilderBase< EntityType >::EntityBuilderBase ( ecs::ComponentRegistry & componentRegistry,
ecs::EntityRegistry & entityRegistry )

Construct a builder bound to two registries.

Parameters
componentRegistryThe registry that stores the components of the widgets built.
entityRegistryThe registry that owns the widgets built: a scene's registry for a top-level widget, or a parent widget for its own children.

Member Function Documentation

◆ buildEntity()

template<typename EntityType>
virtual std::shared_ptr< EntityType > guillaume::entities::EntityBuilderBase< EntityType >::buildEntity ( void )
protectedpure virtual

Create the widget from the current configuration.

Implemented by each concrete builder, usually as a call to the widget's static create(). It must not attach the parent nor register the widget: registerEntity() does both.

Returns
The new widget, not yet attached nor registered.

Implemented in guillaume::entities::AppBar::Builder, guillaume::entities::Badge::Builder, guillaume::entities::Button::Builder, guillaume::entities::Card::Builder, guillaume::entities::Checkbox::Builder, guillaume::entities::Chip::Builder, guillaume::entities::Dialog::Builder, guillaume::entities::Divider::Builder, guillaume::entities::ExtendedFloatingActionButton::Builder, guillaume::entities::FloatingActionButton::Builder, guillaume::entities::FloatingActionButtonMenu::Builder, guillaume::entities::Icon::Builder, guillaume::entities::IconButton::Builder, guillaume::entities::Image::Builder, guillaume::entities::List::Builder, guillaume::entities::LoadingIndicator::Builder, guillaume::entities::Menu::Builder, guillaume::entities::Mesh::Builder, guillaume::entities::NavigationBar::Builder, guillaume::entities::NavigationDrawer::Builder, guillaume::entities::ProgressIndicator::Builder, guillaume::entities::RadioButton::Builder, guillaume::entities::RadioGroup::Builder, guillaume::entities::Search::Builder, guillaume::entities::SegmentedButton::Builder, guillaume::entities::Snackbar::Builder, guillaume::entities::Surface::Builder, guillaume::entities::Switch::Builder, guillaume::entities::Text::Builder, guillaume::entities::TextField::Builder, guillaume::entities::Tooltip::Builder, and guillaume::entities::View::Builder.

◆ registerEntity()

template<typename EntityType>
std::shared_ptr< EntityType > guillaume::entities::EntityBuilderBase< EntityType >::registerEntity ( std::shared_ptr< ecs::Entity > parent)

Build the widget, attach it to its parent, hand it to the entity registry, then reset the builder to its defaults.

The make...() methods of the concrete builders end with this call.

Parameters
parentThe entity the widget becomes a child of, or nullptr for a widget without parent.
Returns
The registered widget, or nullptr when buildEntity() returned nullptr (nothing is registered then, but the builder is still reset).

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