guillaume 2026.6.1
A C++ UI framework designed for modern desktop and extended reality (XR) applications.
Loading...
Searching...
No Matches
guillaume::ecs::EntityTreeTraveler Class Referenceabstract

Decides in which order the entities of a scene are visited. More...

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

Inheritance diagram for guillaume::ecs::EntityTreeTraveler:

Public Member Functions

virtual ~EntityTreeTraveler (void)=default
 Virtual destructor.
virtual std::vector< std::shared_ptr< Entity > > travel (EntityRegistry &entityRegistry) const =0
 List every entity below a registry, in this traveler's order.
virtual std::vector< std::shared_ptr< const Entity > > travel (const EntityRegistry &entityRegistry) const =0
 List every entity below a registry, in this traveler's order, read-only.

Detailed Description

Decides in which order the entities of a scene are visited.

A traveler turns the ownership tree of an EntityRegistry (the scene, the entities it owns, the entities those own, ...) into a flat list. System::routine walks that list and calls System::update on each entity that matches the system. The order matters because a system often needs the result it computed for a parent or for the children:

  • LevelOrderTraveler: parents before children. Used by the Layout and Render phases (a parent places its children, then they place theirs).
  • ReverseLevelOrderTraveler: children before parents. Used by the Event and Measure phases (a parent is sized from the sizes of its children).

"Parent" and "child" here follow ownership (who called EntityRegistry::addEntity), not Entity::setParent. An entity created through a widget Builder is owned by the scene even when it has a parent: it is ordered among the entities of the scene, by creation order.

Each phase is tied to its traveler in system_phase.hpp. A traveler has no state and can be shared.

See also
SystemPhase
EntityRegistry::getEntitiesBreadthFirst

Definition at line 61 of file entity_tree_traveler.hpp.

Member Function Documentation

◆ travel() [1/2]

virtual std::vector< std::shared_ptr< const Entity > > guillaume::ecs::EntityTreeTraveler::travel ( const EntityRegistry & entityRegistry) const
pure virtual

List every entity below a registry, in this traveler's order, read-only.

Parameters
entityRegistryThe registry to start from, usually the scene. Entities owned by nested registries are included.
Returns
The entities, in visiting order; empty when the registry owns nothing.

Implemented in guillaume::ecs::LevelOrderTraveler, and guillaume::ecs::ReverseLevelOrderTraveler.

◆ travel() [2/2]

virtual std::vector< std::shared_ptr< Entity > > guillaume::ecs::EntityTreeTraveler::travel ( EntityRegistry & entityRegistry) const
pure virtual

List every entity below a registry, in this traveler's order.

Parameters
entityRegistryThe registry to start from, usually the scene. Entities owned by nested registries are included.
Returns
The entities, in visiting order; empty when the registry owns nothing.

Implemented in guillaume::ecs::LevelOrderTraveler, and guillaume::ecs::ReverseLevelOrderTraveler.

Here is the caller graph for this function:

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