Application.ixx File
Entry point and central manager for helios applications. More...
Included Headers
#include <memory>
#include <vector>
#include <list>
#include <stdexcept>
#include <format>
#include <algorithm>
#include <cassert>
#include <helios.util.log.LogManager>
#include <helios.window.WindowConfig>
#include <helios.window.Window>
#include <helios.event.EventManager>
#include <helios.input.InputManager>
#include <helios.rendering.RenderTarget>
#include <helios.util.log.Logger>
#include <helios.rendering.RenderingDevice>
#include <helios.app.controller.Controller>
Namespaces Index
| namespace | helios |
| namespace | app |
|
Application infrastructure and lifecycle management. More... | |
Classes Index
| class | Application |
|
Class providing the entry point for a helios application. More... | |
Macro Definitions Index
| #define | HELIOS_LOG_SCOPE "helios::app::Application" |
Description
Entry point and central manager for helios applications.
Macro Definitions
HELIOS_LOG_SCOPE
|
Definition at line 27 of file Application.ixx.
27#define HELIOS_LOG_SCOPE "helios::app::Application"
File Listing
The file content with the documentation metadata removed is:
27#define HELIOS_LOG_SCOPE "helios::app::Application"
28export namespace helios::app {
38 * which can provide specialized logic and management for the various subsystems and related events.
40 class Application {
46 inline static const helios::util::log::Logger& logger_ = helios::util::log::LogManager::loggerForScope(HELIOS_LOG_SCOPE);
51 bool initialized_ = false;
56 std::unique_ptr<helios::rendering::RenderingDevice> renderingDevice_;
61 std::unique_ptr<input::InputManager> inputManager_;
66 std::unique_ptr<event::EventManager> eventManager_;
71 std::list<std::unique_ptr<helios::window::Window>> windowList_;
76 std::vector<std::unique_ptr<helios::app::controller::Controller>> controllers_;
84 virtual ~Application() = default;
98 explicit Application(
99 std::unique_ptr<helios::rendering::RenderingDevice> renderingDevice,
100 std::unique_ptr<helios::input::InputManager> inputManager,
101 std::unique_ptr<helios::event::EventManager> eventManager
103 renderingDevice_(std::move(renderingDevice)),
104 inputManager_(std::move(inputManager)),
105 eventManager_(std::move(eventManager))
107 assert(renderingDevice_ && "Unexpected nullptr for RenderingDevice");
108 assert(inputManager_ && "Unexpected nullptr for InputManager");
109 assert(eventManager_ && "Unexpected nullptr for EventManager");
121 void addController(std::unique_ptr<helios::app::controller::Controller> controller) noexcept {
122 if (initialized_) {
123 logger_.info(
124 std::format("Controller {0} added to an already initialized Application, explicitly initializing.", controller->toString())
126 if (controller->init()) {
127 controller->subscribeTo(eventManager_->dispatcher());
130 controllers_.push_back(std::move(controller));
145 [[nodiscard]] virtual helios::window::Window& createWindow(std::unique_ptr<helios::rendering::RenderTarget> renderTarget, const helios::window::WindowConfig& cfg) = 0;
157 logger_.info("Initializing application.");
159 if (initialized_) {
161 logger_.error(msg);
164 for (auto& ctrl: controllers_) {
166 ctrl->subscribeTo(eventManager_->dispatcher());
170 initialized_ = true;
181 virtual void setCurrent(helios::window::Window& win) = 0;
192 [[nodiscard]] bool hasWindow(const helios::window::Window& win) const noexcept {
194 windowList_.begin(),
195 windowList_.end(),
196 [&win](const auto& window){return *window == win;});
198 return it != windowList_.end();
208 [[nodiscard]] virtual helios::window::Window* current() const noexcept = 0;
216 [[nodiscard]] helios::input::InputManager& inputManager() const {
217 return *inputManager_;
225 [[nodiscard]] helios::rendering::RenderingDevice& renderingDevice() const {
226 return *renderingDevice_;
234 [[nodiscard]] helios::event::EventManager& eventManager() const {
235 return *eventManager_;
Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.