The base class for an application.
More...
#include <app.hpp>
Inherited by SampleApp, SampleApp, SampleApp, SampleApp, SampleApp, SampleApp, SampleApp, SampleApp, SampleApp, SampleApp, SampleApp, SampleApp, SampleApp, TestApp, and TestApp.
|
| App () |
| Initializes a new app instance.
|
|
| App (const App &)=delete |
|
| App (App &&) noexcept=delete |
|
auto | operator= (const App &)=delete |
|
auto | operator= (App &&) noexcept=delete |
|
virtual | ~App () noexcept |
|
virtual StringView | name () const noexcept=0 |
| Returns the name of the app.
|
|
virtual AppVersion | version () const noexcept=0 |
| Returns the version of the app.
|
|
Platform | platform () const noexcept |
| Returns the platform, the app is running on.
|
|
const IBackend * | operator[] (std::type_index type) const |
| Returns the registered backend instance for a type index.
|
|
const IBackend * | getBackend (std::type_index type) const |
| Returns the registered backend instance for a type index.
|
|
Enumerable< const IBackend & > | getBackends (const BackendType type) const |
| Returns all registered backend instances of a backend type.
|
|
template<typename TBackend >
requires meta::implements<TBackend, IBackend> |
void | onBackendStart (const std::function< bool(TBackend *)> &callback) |
| Sets a callback that is called, if a backend is started.
|
|
template<typename TBackend >
requires meta::implements<TBackend, IBackend> |
void | onBackendStop (const std::function< void(TBackend *)> &callback) |
| Sets a callback that is called, if a backend is stopped.
|
|
template<typename TBackend >
requires meta::implements<TBackend, IBackend> |
const TBackend * | findBackend () const |
| Returns the registered backend instance for a type index.
|
|
template<typename TBackend >
requires meta::implements<TBackend, IBackend> |
void | startBackend () |
| Attempts to start a backend of type TBackend and stops the active backend of the same BackendType, if any.
|
|
template<typename TBackend >
requires meta::implements<TBackend, IBackend> |
void | stopBackend () |
| Stops a backend, if it is currently running.
|
|
virtual void | use (UniquePtr< IBackend > &&backend) |
| Adds a backend to the app.
|
|
void | run () |
| Starts the application.
|
|
void | resize (int width, int height) |
| Called, if the application window resizes.
|
|
|
template<typename TApp , typename ... TArgs> |
static AppBuilder | build (TArgs &&... _args) |
| Creates a new application builder.
|
|
The base class for an application.
- See also
- AppBuilder, AppVersion
◆ App() [1/3]
Initializes a new app instance.
◆ App() [2/3]
LiteFX::App::App |
( |
const App & | | ) |
|
|
delete |
◆ App() [3/3]
LiteFX::App::App |
( |
App && | | ) |
|
|
deletenoexcept |
◆ ~App()
◆ activeBackend()
Returns the active backend of the provided backend type .
- Parameters
-
type | The type of the backend. |
- Returns
- The active backend of the provided backend type, or
std::nullptr
, if no backend is active.
◆ activeBackendType()
std::type_index App::activeBackendType |
( |
BackendType | type | ) |
const |
|
protected |
Returns the type index of the active backend of the provided backend type .
- Parameters
-
type | The type of the backend. |
- Returns
- Type index of the active backend of the provided backend type, or the type index of
std::nullptr_t
, if no backend is active.
◆ build()
template<typename TApp , typename ... TArgs>
AppBuilder LiteFX::App::build |
( |
TArgs &&... | _args | ) |
|
|
inlinestaticnodiscard |
Creates a new application builder.
◆ findBackend() [1/2]
template<typename TBackend >
requires meta::implements<TBackend,
IBackend>
TBackend * LiteFX::App::findBackend |
( |
| ) |
|
|
inlineprotected |
Returns the registered backend instance for a type index.
- Template Parameters
-
TBackend | The type, the type index is derived from. |
- Returns
- The registered backend instance for a type index, or
nullptr
, if the app has no backend of the provided type.
◆ findBackend() [2/2]
template<typename TBackend >
requires meta::implements<TBackend,
IBackend>
const TBackend * LiteFX::App::findBackend |
( |
| ) |
const |
|
inline |
Returns the registered backend instance for a type index.
- Template Parameters
-
TBackend | The type, the type index is derived from. |
- Returns
- The registered backend instance for a type index, or
nullptr
, if the app has no backend of the provided type.
◆ getBackend() [1/2]
IBackend * App::getBackend |
( |
std::type_index | type | ) |
|
|
protected |
Returns the registered backend instance for a type index.
- Parameters
-
type | The type index of the requested backend. |
- Returns
- The registered backend instance for a type index, or
nullptr
, if the app has no backend of the provided type.
◆ getBackend() [2/2]
const IBackend * App::getBackend |
( |
std::type_index | type | ) |
const |
Returns the registered backend instance for a type index.
- Parameters
-
type | The type index of the requested backend. |
- Returns
- The registered backend instance for a type index, or
nullptr
, if the app has no backend of the provided type.
◆ getBackends()
Returns all registered backend instances of a backend type.
- Parameters
-
type | The backend type of the requested backends. |
- Returns
- All registered instances of type .
◆ name()
Returns the name of the app.
- Returns
- The name of the app.
Implemented in SampleApp, SampleApp, SampleApp, SampleApp, SampleApp, SampleApp, SampleApp, SampleApp, SampleApp, SampleApp, SampleApp, SampleApp, SampleApp, TestApp, and TestApp.
◆ onBackendStart()
template<typename TBackend >
requires meta::implements<TBackend,
IBackend>
void LiteFX::App::onBackendStart |
( |
const std::function< bool(TBackend *)> & | callback | ) |
|
|
inline |
Sets a callback that is called, if a backend is started.
A backend can have multiple start callbacks, that are executed if a backend is started. Typically such a callback is used to initialize a device and surface for an application. An application might use multiple callbacks, if it creates multiple devices, for example to create a plugin architecture.
Different to the backendStarted event, this event can be strongly typed at compile time, thus different callbacks can be provided per backend type without requiring to differentiate them at run-time.
- Template Parameters
-
TBackend | The type of the backend. |
- Parameters
-
callback | The function to call during backend startup. |
- See also
- onBackendStop, backendStarted
◆ onBackendStop()
template<typename TBackend >
requires meta::implements<TBackend,
IBackend>
void LiteFX::App::onBackendStop |
( |
const std::function< void(TBackend *)> & | callback | ) |
|
|
inline |
Sets a callback that is called, if a backend is stopped.
Different to the backendStopped event, this event can be strongly typed at compile time, thus different callbacks can be provided per backend type without requiring to differentiate them at run-time.
- Template Parameters
-
TBackend | The type of the backend. |
- Parameters
-
callback | The function to call during backend shutdown. |
- See also
- onBackendStart, backendStopped
◆ operator=() [1/2]
auto LiteFX::App::operator= |
( |
App && | | ) |
|
|
deletenoexcept |
◆ operator=() [2/2]
auto LiteFX::App::operator= |
( |
const App & | | ) |
|
|
delete |
◆ operator[]()
const IBackend * App::operator[] |
( |
std::type_index | type | ) |
const |
Returns the registered backend instance for a type index.
- Parameters
-
type | The type index of the requested backend. |
- Returns
- The registered backend instance for a type index, or
nullptr
, if the app has no backend of the provided type.
◆ platform()
Returns the platform, the app is running on.
- Returns
- The platform, the app is running on.
◆ resize()
void App::resize |
( |
int | width, |
|
|
int | height ) |
Called, if the application window resizes.
- Parameters
-
width | The new width of the application window. |
height | The new height of the application window. |
◆ run()
◆ startBackend() [1/2]
template<typename TBackend >
requires meta::implements<TBackend,
IBackend>
void LiteFX::App::startBackend |
( |
| ) |
|
|
inline |
Attempts to start a backend of type TBackend and stops the active backend of the same BackendType, if any.
- Template Parameters
-
TBackend | The type of the backend to start. |
- Exceptions
-
◆ startBackend() [2/2]
void App::startBackend |
( |
std::type_index | type | ) |
const |
|
protected |
Starts a backend.
Starting a backend will first stop the active backend of the same BackendType. It will then call all start callbacks for the backend. If the backend has been started successfully, it calls IBackend::activate before returning.
- Parameters
-
type | The type index of the backend to start. |
- See also
- Backend, onBackendStart
◆ stopActiveBackends()
Stops the active backend of type .
- Parameters
-
type | The backend type for which the active backend should be stopped. |
- See also
- stopBackend
◆ stopBackend() [1/2]
template<typename TBackend >
requires meta::implements<TBackend,
IBackend>
void LiteFX::App::stopBackend |
( |
| ) |
|
|
inline |
Stops a backend, if it is currently running.
- Template Parameters
-
TBackend | The type of the backend to stop. |
- Exceptions
-
◆ stopBackend() [2/2]
void App::stopBackend |
( |
std::type_index | type | ) |
const |
|
protected |
Stops a backend.
This method calls all stop callbacks for the backend, before returing. If the backend is not running, calling this method has no effect.
- Parameters
-
type | The type index of the backend to start. |
- See also
- Backend, onBackendStop
◆ use()
Adds a backend to the app.
- Parameters
-
backend | The backend to add. |
- Exceptions
-
◆ version()
Returns the version of the app.
- Returns
- The version of the app.
Implemented in SampleApp, SampleApp, SampleApp, SampleApp, SampleApp, SampleApp, SampleApp, SampleApp, SampleApp, SampleApp, SampleApp, SampleApp, SampleApp, TestApp, and TestApp.
◆ backendStarted
Invoked, if a backend has been started.
◆ backendStopped
Invoked, if a backend has been stopped.
◆ initializing
Invoked during initialization.
◆ resized
Invoked, if the app window or context gets resized.
◆ shutdown
Invoked, if the application has is shutting down.
◆ startup
Invoked, if the application has been started.