The base class for an application.
More...
#include <app.hpp>
Inherited by SampleApp, SampleApp, SampleApp, SampleApp, SampleApp, SampleApp, SampleApp, and SampleApp.
|
| App () |
| Initializes a new app instance. More...
|
|
| App (const App &)=delete |
|
| App (App &&)=delete |
|
virtual | ~App () noexcept |
|
virtual String | name () const noexcept=0 |
| Returns the name of the app. More...
|
|
virtual AppVersion | version () const noexcept=0 |
| Returns the version of the app. More...
|
|
Platform | platform () const noexcept |
| Returns the platform, the app is running on. More...
|
|
virtual const IBackend * | operator[] (std::type_index type) const |
| Returns the registered backend instance for a type index. More...
|
|
virtual const IBackend * | getBackend (std::type_index type) const |
| Returns the registered backend instance for a type index. More...
|
|
virtual Array< const IBackend * > | getBackends (const BackendType type) const noexcept |
| Returns all registered backend instances of a backend type. More...
|
|
template<typename TBackend >
requires rtti::implements<TBackend, IBackend> |
void | onBackendStart (const std::function< bool(TBackend *)> &callback) |
| Sets a callback that is called, if a backend is started. More...
|
|
template<typename TBackend >
requires rtti::implements<TBackend, IBackend> |
void | onBackendStop (const std::function< void(TBackend *)> &callback) |
| Sets a callback that is called, if a backend is stopped. More...
|
|
template<typename TBackend >
requires rtti::implements<TBackend, IBackend> |
const TBackend * | findBackend () const |
| Returns the registered backend instance for a type index. More...
|
|
template<typename TBackend >
requires rtti::implements<TBackend, IBackend> |
void | startBackend () |
| Attempts to start a backend of type TBackend and stops the active backend of the same BackendType, if any. More...
|
|
template<typename TBackend >
requires rtti::implements<TBackend, IBackend> |
void | stopBackend () |
| Stops a backend, if it is currently running. More...
|
|
virtual void | use (UniquePtr< IBackend > &&backend) |
| Adds a backend to the app. More...
|
|
virtual void | run ()=0 |
| Starts the application. More...
|
|
virtual void | initialize ()=0 |
| Called to initialize the application state. More...
|
|
virtual void | resize (int &width, int &height) |
| Called, if the application window resizes. More...
|
|
|
template<typename TApp , typename ... TArgs> |
static AppBuilder | build (TArgs &&... _args) |
| Creates a new application builder. More...
|
|
|
virtual IBackend * | getBackend (std::type_index type) |
| Returns the registered backend instance for a type index. More...
|
|
template<typename TBackend >
requires rtti::implements<TBackend, IBackend> |
TBackend * | findBackend () |
| Returns the registered backend instance for a type index. More...
|
|
virtual void | startBackend (std::type_index type) const |
| Starts a backend. More...
|
|
virtual void | stopBackend (std::type_index type) const |
| Stops a backend. More...
|
|
virtual void | stopActiveBackends (const BackendType &type) const |
| Stops the active backend of type . More...
|
|
virtual IBackend * | activeBackend (const BackendType &type) const |
| Returns the active backend of the provided backend type . More...
|
|
virtual std::type_index | activeBackendType (const BackendType &type) const |
| Returns the type index of the active backend of the provided backend type . More...
|
|
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 && |
| ) |
|
|
delete |
◆ ~App()
◆ activeBackend()
IBackend * App::activeBackend |
( |
const BackendType & |
type | ) |
const |
|
protectedvirtual |
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 |
( |
const BackendType & |
type | ) |
const |
|
protectedvirtual |
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>
static AppBuilder LiteFX::App::build |
( |
TArgs &&... |
_args | ) |
|
|
inlinestatic |
Creates a new application builder.
◆ findBackend() [1/2]
template<typename TBackend >
requires rtti::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 rtti::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 | ) |
|
|
protectedvirtual |
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 |
|
virtual |
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()
Array< const IBackend * > App::getBackends |
( |
const BackendType |
type | ) |
const |
|
virtualnoexcept |
Returns all registered backend instances of a backend type.
- Parameters
-
type | The backend type of the requested backends. |
- Returns
- All registered instances of type .
◆ initialize()
virtual void LiteFX::App::initialize |
( |
| ) |
|
|
pure virtual |
◆ name()
virtual String LiteFX::App::name |
( |
| ) |
const |
|
pure virtualnoexcept |
◆ onBackendStart()
template<typename TBackend >
requires rtti::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.
- Template Parameters
-
TBackend | The type of the backend. |
- Parameters
-
callback | The function to call during backend startup. |
- See also
- onBackendStop
◆ onBackendStop()
template<typename TBackend >
requires rtti::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.
- Template Parameters
-
TBackend | The type of the backend. |
- Parameters
-
callback | The function to call during backend shutdown. |
- See also
- onBackendStart
◆ operator[]()
const IBackend * App::operator[] |
( |
std::type_index |
type | ) |
const |
|
virtual |
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()
Platform App::platform |
( |
| ) |
const |
|
noexcept |
Returns the platform, the app is running on.
- Returns
- The platform, the app is running on.
◆ resize()
void App::resize |
( |
int & |
width, |
|
|
int & |
height |
|
) |
| |
|
virtual |
◆ run()
virtual void LiteFX::App::run |
( |
| ) |
|
|
pure virtual |
◆ startBackend() [1/2]
template<typename TBackend >
requires rtti::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
-
InvalidArgumentException | Thrown, if no backend of type TBackend is registered. |
◆ startBackend() [2/2]
void App::startBackend |
( |
std::type_index |
type | ) |
const |
|
protectedvirtual |
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()
void App::stopActiveBackends |
( |
const BackendType & |
type | ) |
const |
|
protectedvirtual |
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 rtti::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
-
InvalidArgumentException | Thrown, if no backend of type TBackend is registered. |
◆ stopBackend() [2/2]
void App::stopBackend |
( |
std::type_index |
type | ) |
const |
|
protectedvirtual |
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
-
InvalidArgumentException | Thrown, if the backend is not initialized. |
◆ version()