|
guillaume 2026.6.1
A C++ UI framework designed for modern desktop and extended reality (XR) applications.
|
Owns the scenes of an application, knows which one is active, and performs the switches between them. More...
#include <headers/guillaume/scene_manager.hpp>


Public Member Functions | |
| SceneManager (std::shared_ptr< utility::RessourceProvider > ressourceProvider, utility::Engine &engine) | |
| Create one instance of every scene type and make DefaultSceneType the active one. | |
| ~SceneManager (void) | |
| Destroy the manager and every scene. onExit() is not called on the active scene. | |
| Scene * | getActiveScene (void) |
| Get the active scene. | |
| bool | hasScenes (void) const noexcept |
| Tell whether the manager holds at least one scene. | |
| bool | hasActiveScene (void) const noexcept |
| Tell whether an active scene is selected. | |
| void | enterActiveScene (void) |
| Enter the active scene: call its onEnter(), then place its entities in front of the engine's current view (Scene::placeEntitiesInFrontOfView). | |
| void | processSceneTransition (void) |
| Carry out the switch requested by the active scene with Scene::goToScene, if any. | |
| template<InheritFromScene SceneType> | |
| void | switchToScene (void) |
| Switch to another scene immediately, without waiting for the end of the frame. | |
| ecs::EntityRegistry & | getActiveEntityRegistry (void) |
| Get the entity registry of the active scene. | |
| ecs::ComponentRegistry & | getActiveComponentRegistry (void) |
| Get the component registry of the active scene. | |
| std::vector< std::type_index > | getRegisteredSceneTypes (void) const |
| List the scene types this manager holds. | |
Protected Member Functions | |
| template<InheritFromScene SceneType> | |
| void | addScene (void) |
| Create the instance of one scene type and keep it. | |
Owns the scenes of an application, knows which one is active, and performs the switches between them.
Application creates one manager. The manager builds one instance of every scene type at construction and keeps them all until it is destroyed: switching scenes changes which one is active, it does not create or destroy scenes. Each frame, Application asks it for the registries of the active scene, runs the systems on them, then calls processSceneTransition() to honor a Scene::goToScene request.
Every switch goes through the same steps: onExit() on the active scene, then onEnter() on the new one, then Scene::placeEntitiesInFrontOfView with the engine's view.
The manager also owns the LocalStorage and the SessionStorage handed to every scene. The LocalStorage uses its default path, so constructing a manager opens (and creates if needed) the file given by LocalStorage::defaultStoragePath.
| DefaultSceneType | The scene activated when the application starts. |
| SceneTypes | The other scenes of the application. Every scene type must inherit from Scene and appear only once. |
Definition at line 81 of file scene_manager.hpp.
| guillaume::SceneManager< DefaultSceneType, SceneTypes >::SceneManager | ( | std::shared_ptr< utility::RessourceProvider > | ressourceProvider, |
| utility::Engine & | engine ) |
Create one instance of every scene type and make DefaultSceneType the active one.
No scene is entered yet: call enterActiveScene() once the manager is built.
| ressourceProvider | The resource provider handed to every scene. |
| engine | The engine asked for the current view each time a scene is entered. It must outlive the manager. |
| std::runtime_error | When the local storage cannot be opened at all (see LocalStorage). |
|
protected |
Create the instance of one scene type and keep it.
The scene receives the resource provider and the two storages. A scene of the same type already held is replaced.
| SceneType | The scene type to instantiate. It must be constructible from the arguments of the Scene constructor. |
| void guillaume::SceneManager< DefaultSceneType, SceneTypes >::enterActiveScene | ( | void | ) |
Enter the active scene: call its onEnter(), then place its entities in front of the engine's current view (Scene::placeEntitiesInFrontOfView).
onEnter() comes first because that is where the scene builds the entities to place. Application calls this once at start-up for the default scene; later entries happen through the switches.
| std::runtime_error | When the manager holds no scene. |
| ecs::ComponentRegistry & guillaume::SceneManager< DefaultSceneType, SceneTypes >::getActiveComponentRegistry | ( | void | ) |
Get the component registry of the active scene.
| std::runtime_error | When the manager holds no scene. |
| ecs::EntityRegistry & guillaume::SceneManager< DefaultSceneType, SceneTypes >::getActiveEntityRegistry | ( | void | ) |
Get the entity registry of the active scene.
| std::runtime_error | When the manager holds no scene. |
| Scene * guillaume::SceneManager< DefaultSceneType, SceneTypes >::getActiveScene | ( | void | ) |
Get the active scene.
| std::runtime_error | When the manager holds no scene. |
| std::vector< std::type_index > guillaume::SceneManager< DefaultSceneType, SceneTypes >::getRegisteredSceneTypes | ( | void | ) | const |
List the scene types this manager holds.
|
noexcept |
Tell whether an active scene is selected.
|
noexcept |
Tell whether the manager holds at least one scene.
| void guillaume::SceneManager< DefaultSceneType, SceneTypes >::processSceneTransition | ( | void | ) |
Carry out the switch requested by the active scene with Scene::goToScene, if any.
Does nothing when no switch is pending. Otherwise the request is cleared, onExit() is called on the active scene, the requested scene becomes active and is entered (enterActiveScene()). Application calls it once per frame, after the systems ran.
| std::runtime_error | When the requested scene type is not one of this manager's scenes. The request is dropped and the active scene stays active, without onExit() being called. |
| void guillaume::SceneManager< DefaultSceneType, SceneTypes >::switchToScene | ( | void | ) |
Switch to another scene immediately, without waiting for the end of the frame.
Same steps as a switch requested by the scene itself: onExit() on the active scene, then the new scene becomes active and is entered. Switching to the scene that is already active exits and re-enters it.
| SceneType | The scene type to switch to. |
| std::runtime_error | When SceneType is not one of this manager's scenes; the active scene is left as it was. |