Skip to main content

Application Class

Class providing the entry point for a helios application. More...

Declaration

class helios::app::Application { ... }

Derived Classes

classGLFWApplication

An Application implementation for glfw-based environments. More...

Public Constructors Index

Application (std::unique_ptr< helios::rendering::RenderingDevice > renderingDevice, std::unique_ptr< helios::input::InputManager > inputManager, std::unique_ptr< helios::event::EventManager > eventManager)

Creates a new application instance. More...

Public Destructor Index

~Application ()=default

Public Member Functions Index

voidaddController (std::unique_ptr< helios::app::controller::Controller > controller) noexcept

Registers a new controller with this application. More...

helios::window::Window &createWindow (std::unique_ptr< helios::rendering::RenderTarget > renderTarget, const helios::window::WindowConfig &cfg)=0

Creates the container for the native window and performs all necessary steps to properly initialize it. More...

voidinit ()

Initializes the application. More...

voidsetCurrent (helios::window::Window &win)=0

Sets the application's active window. More...

boolhasWindow (const helios::window::Window &win) const noexcept

Returns true if the specified window is owned by this application, otherwise false. More...

helios::window::Window *current () const noexcept=0

Returns the currently focused window, or nullptr if none exists or no window is being treated as current. More...

helios::input::InputManager &inputManager () const

Returns the input manager owned by this application. More...

helios::rendering::RenderingDevice &renderingDevice () const

Returns the rendering device owned by this application. More...

helios::event::EventManager &eventManager () const

Returns the event manager owned by this application. More...

Protected Member Attributes Index

boolinitialized_ = false

Flag indicating whether the application has been initialized. More...

std::unique_ptr< helios::rendering::RenderingDevice >renderingDevice_

The rendering device owned by this application. More...

std::unique_ptr< input::InputManager >inputManager_

The input manager owned by this application. More...

std::unique_ptr< event::EventManager >eventManager_

The event manager owned by this application. More...

std::list< std::unique_ptr< helios::window::Window > >windowList_

A list containing all windows managed by this application. More...

std::vector< std::unique_ptr< helios::app::controller::Controller > >controllers_

Collection of controllers registered with this application. More...

Protected Static Attributes Index

static const helios::util::log::Logger &logger_ = helios::util::log::LogManager::loggerForScope(HELIOS_LOG_SCOPE)

Shared logger instance for all Application objects. More...

Description

Class providing the entry point for a helios application.

`Application` serves as the central hub for the helios framework, offering convenient access and management for key subsystems such as the EventManager, the InputManager and the RenderingDevice.

It also allows for the registration of `helios.app.controller.Controller`s, which can provide specialized logic and management for the various subsystems and related events.

Definition at line 40 of file Application.ixx.

Public Constructors

Application()

helios::app::Application::Application (std::unique_ptr< helios::rendering::RenderingDevice > renderingDevice, std::unique_ptr< helios::input::InputManager > inputManager, std::unique_ptr< helios::event::EventManager > eventManager)
inline explicit

Creates a new application instance.

The application will take ownership of the specified constructor arguments.

Parameters
renderingDevice

Unique rendering device owned by the application.

inputManager

Unique input manager instance.

eventManager

Unique event manager instance.

Definition at line 98 of file Application.ixx.

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
102 ):
104 inputManager_(std::move(inputManager)),
105 eventManager_(std::move(eventManager))
106 {
107 assert(renderingDevice_ && "Unexpected nullptr for RenderingDevice");
108 assert(inputManager_ && "Unexpected nullptr for InputManager");
109 assert(eventManager_ && "Unexpected nullptr for EventManager");
110 }

References eventManager, eventManager_, inputManager, inputManager_, renderingDevice and renderingDevice_.

Referenced by helios::ext::glfw::app::GLFWApplication::GLFWApplication.

Public Destructor

~Application()

virtual helios::app::Application::~Application ()
virtual default
Todo

free resource allocations from renderingDevice, window and InputManager

Definition at line 84 of file Application.ixx.

Public Member Functions

addController()

void helios::app::Application::addController (std::unique_ptr< helios::app::controller::Controller > controller)
inline noexcept

Registers a new controller with this application.

Makes sure that the controller subscribes to the event manager's dispatcher of this application. The application receives ownership of the specified controller.

Parameters
controller

Unique pointer to the controller to add.

Definition at line 121 of file Application.ixx.

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())
125 );
126 if (controller->init()) {
127 controller->subscribeTo(eventManager_->dispatcher());
128 }
129 }
130 controllers_.push_back(std::move(controller));
131 }

References controllers_, eventManager_, initialized_ and logger_.

createWindow()

virtual helios::window::Window & helios::app::Application::createWindow (std::unique_ptr< helios::rendering::RenderTarget > renderTarget, const helios::window::WindowConfig & cfg)
nodiscard

Creates the container for the native window and performs all necessary steps to properly initialize it.

Parameters
renderTarget

Render target that wraps the framebuffer used by the window.

cfg

Window configuration defining properties such as title, dimensions, and hints.

Returns

Reference to the created window instance.

Exceptions
std::invalid_argument

If the configuration was invalid.

Definition at line 145 of file Application.ixx.

current()

virtual helios::window::Window * helios::app::Application::current ()
nodiscard noexcept

Returns the currently focused window, or nullptr if none exists or no window is being treated as current.

Returns

Pointer to the current window, or nullptr if none is active.

Definition at line 208 of file Application.ixx.

eventManager()

helios::event::EventManager & helios::app::Application::eventManager ()
inline nodiscard

Returns the event manager owned by this application.

Returns

Reference to the event manager instance.

Definition at line 234 of file Application.ixx.

235 return *eventManager_;
236 }

Reference eventManager_.

Referenced by Application and helios::ext::glfw::app::GLFWApplication::GLFWApplication.

hasWindow()

bool helios::app::Application::hasWindow (const helios::window::Window & win)
inline nodiscard noexcept

Returns true if the specified window is owned by this application, otherwise false.

Parameters
win

The window to look up in this application's window list.

Returns

True if the window is owned by this application, otherwise false.

Definition at line 192 of file Application.ixx.

192 [[nodiscard]] bool hasWindow(const helios::window::Window& win) const noexcept {
193 auto it = std::find_if(
194 windowList_.begin(),
195 windowList_.end(),
196 [&win](const auto& window){return *window == win;});
197
198 return it != windowList_.end();
199 }

Reference windowList_.

Referenced by helios::ext::glfw::app::GLFWApplication::setCurrent.

init()

virtual void helios::app::Application::init ()
inline virtual

Initializes the application.

Performs any bootstrapping necessary for this application and provides an idiomatic entry point for APIs using this application. This method ensures that all controllers are initialized and subscribe to this application's event manager dispatcher.

Exceptions
std::runtime_error

If the application was already initialized.

Definition at line 156 of file Application.ixx.

156 virtual void init() {
157 logger_.info("Initializing application.");
158
159 if (initialized_) {
160 std::string msg = "Application was already initialized.";
161 logger_.error(msg);
162 throw std::runtime_error(msg);
163 }
164 for (auto& ctrl: controllers_) {
165 if (ctrl->init()) {
166 ctrl->subscribeTo(eventManager_->dispatcher());
167 }
168 }
169
170 initialized_ = true;
171 }

References controllers_, eventManager_, initialized_ and logger_.

inputManager()

helios::input::InputManager & helios::app::Application::inputManager ()
inline nodiscard

Returns the input manager owned by this application.

Returns

Reference to the input manager instance.

Definition at line 216 of file Application.ixx.

216 [[nodiscard]] helios::input::InputManager& inputManager() const {
217 return *inputManager_;
218 };

References inputManager and inputManager_.

Referenced by Application, helios::ext::glfw::app::GLFWApplication::GLFWApplication and inputManager.

renderingDevice()

helios::rendering::RenderingDevice & helios::app::Application::renderingDevice ()
inline nodiscard

Returns the rendering device owned by this application.

Returns

Reference to the rendering device instance.

Definition at line 225 of file Application.ixx.

226 return *renderingDevice_;
227 };

Reference renderingDevice_.

Referenced by Application and helios::ext::glfw::app::GLFWApplication::GLFWApplication.

setCurrent()

virtual void helios::app::Application::setCurrent (helios::window::Window & win)

Sets the application's active window.

Advises the input manager to poll this window's events.

Parameters
win

Reference to the window that becomes the current active window.

Definition at line 181 of file Application.ixx.

Protected Member Attributes

controllers_

std::vector<std::unique_ptr<helios::app::controller::Controller> > helios::app::Application::controllers_
protected

Collection of controllers registered with this application.

Definition at line 76 of file Application.ixx.

76 std::vector<std::unique_ptr<helios::app::controller::Controller>> controllers_;

Referenced by addController and init.

eventManager_

std::unique_ptr<event::EventManager> helios::app::Application::eventManager_
protected

The event manager owned by this application.

Definition at line 66 of file Application.ixx.

66 std::unique_ptr<event::EventManager> eventManager_;

Referenced by addController, Application, eventManager and init.

initialized_

bool helios::app::Application::initialized_ = false
protected

Flag indicating whether the application has been initialized.

Definition at line 51 of file Application.ixx.

51 bool initialized_ = false;

Referenced by addController and init.

inputManager_

std::unique_ptr<input::InputManager> helios::app::Application::inputManager_
protected

The input manager owned by this application.

Definition at line 61 of file Application.ixx.

61 std::unique_ptr<input::InputManager> inputManager_;

Referenced by Application, inputManager and helios::ext::glfw::app::GLFWApplication::setCurrent.

renderingDevice_

std::unique_ptr<helios::rendering::RenderingDevice> helios::app::Application::renderingDevice_
protected

The rendering device owned by this application.

Definition at line 56 of file Application.ixx.

56 std::unique_ptr<helios::rendering::RenderingDevice> renderingDevice_;

Referenced by Application, helios::ext::glfw::app::GLFWApplication::createWindow and renderingDevice.

windowList_

std::list<std::unique_ptr<helios::window::Window> > helios::app::Application::windowList_
protected

A list containing all windows managed by this application.

Definition at line 71 of file Application.ixx.

71 std::list<std::unique_ptr<helios::window::Window>> windowList_;

Referenced by helios::ext::glfw::app::GLFWApplication::createWindow and hasWindow.

Protected Static Attributes

logger_


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


Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.