guillaume 2026.6.1
A C++ UI framework designed for modern desktop and extended reality (XR) applications.
Loading...
Searching...
No Matches
application.hpp
1/*
2 Copyright (c) 2026 ETIB Corporation
3
4 Permission is hereby granted, free of charge, to any person obtaining a copy of
5 this software and associated documentation files (the "Software"), to deal in
6 the Software without restriction, including without limitation the rights to
7 use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
8 of the Software, and to permit persons to whom the Software is furnished to do
9 so, subject to the following conditions:
10
11 The above copyright notice and this permission notice shall be included in all
12 copies or substantial portions of the Software.
13
14 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 SOFTWARE.
21 */
22
23#pragma once
24
25#include <map>
26#include <memory>
27#include <stdexcept>
28#include <string>
29#include <tuple>
30#include <typeinfo>
31#include <utility>
32
33#include <utility/logging/loggable.hpp>
34#include <utility/logging/default_logger.hpp>
35
36#include <utility/event/quit_event.hpp>
37
38#include <utility/ressource_provider.hpp>
39
40#include <utility/system_io/default_system_io.hpp>
41
42#include <utility/demangle.hpp>
43
44#include <utility/graphic/view.hpp>
45
46#include <utility/engine.hpp>
47
48#include "guillaume/ecs/system_phase.hpp"
49#include "guillaume/ecs/system_registry.hpp"
50
51#include "guillaume/metadata.hpp"
52#include "guillaume/scene_manager.hpp"
53
54#include "guillaume/event/event_bus.hpp"
55#include "guillaume/event/event_subscriber.hpp"
56
57#include "guillaume/systems/core_systems.hpp"
58
59namespace guillaume
60{
131 template<InheritFromScene DefaultSceneType, InheritFromScene... SceneTypes>
132 requires AllDistinct<DefaultSceneType, SceneTypes...>
134 protected utility::logging::Loggable<
135 Application<DefaultSceneType, SceneTypes...>,
136 utility::logging::DefaultLogger>
137 {
138 public:
154 std::shared_ptr<utility::RessourceProvider> ressourceProvider,
155 std::unique_ptr<utility::Engine> engine);
156
161 virtual ~Application(void);
162
175 void routine(void);
176
185 bool shouldQuit(void);
186
192 int run(void);
193
194 protected:
199 std::shared_ptr<utility::RessourceProvider> getRessourceProvider(void)
200 {
201 return _ressourceProvider;
202 }
203
204 private:
212 template<typename PhaseType> void runPhase(PhaseType &phaseDefinition);
213
220 static std::unique_ptr<utility::Engine>
221 requireEngine(std::unique_ptr<utility::Engine> engine);
222
223 std::unique_ptr<utility::Engine>
224 _engine;
225 std::unique_ptr<SceneManager<DefaultSceneType, SceneTypes...>>
226 _sceneManager;
228 _eventBus;
230 _quitEventSubscriber;
233 _systemRegistry;
234 ecs::SystemPhaseList _systemPhases;
237 std::shared_ptr<utility::RessourceProvider>
238 _ressourceProvider;
239 };
240
241} // namespace guillaume
242
243// Include the implementation of the Application template class
244#include "guillaume/application.tpp"
Application(std::shared_ptr< utility::RessourceProvider > ressourceProvider, std::unique_ptr< utility::Engine > engine)
Build the application and enter the default scene.
int run(void)
Run frames until a quit event is received.
virtual ~Application(void)
Destroy the application with its scenes, systems and engine.
std::shared_ptr< utility::RessourceProvider > getRessourceProvider(void)
Get the resource provider given to the constructor.
void routine(void)
Run one frame.
bool shouldQuit(void)
Tell whether a quit event was received since the last call.
Owns the scenes of an application, knows which one is active, and performs the switches between them.
Owns the systems of an application, grouped by phase and kept in registration order.
Hands each engine event to the listeners subscribed to its type.
Definition event_bus.hpp:67
A queue of the events of one type published on an EventBus, waiting to be read.
Constrains a parameter pack to types that are all different.
Definition scene.hpp:325
Constrains a template parameter to a type derived from Scene.
Definition scene.hpp:296
std::tuple< EventPhase, MeasurePhase, LayoutPhase, RenderPhase > SystemPhaseList
Every phase, in the order a frame runs them: Event, Measure, Layout, Render.
A C++20 UI framework for desktop and XR, built as an entity-component-system.