ReXGlue SDK
Loading...
Searching...
No Matches
rex::app::App Class Reference

#include <rex/app/app.h>

Inheritance diagram for rex::app::App:
[legend]

Public Member Functions

 REX_SETTING (std::string, name, "", "App name, set by the constructor", kStartupOnly, kNoSave)
 REX_SETTING (std::filesystem::path, root, "", "Folder the app keeps its files in, the folder of the executable when empty", kStartupOnly)
 REX_SETTING (std::filesystem::path, log_root, "{app.root}/logs", "Log folder", kStartupOnly)
 REX_SETTING (std::string, single_instance, "", "Lock name only one running copy may hold, empty for none", kStartupOnly)
 App (std::string_view name)
 App (const App &)=delete
App & operator= (const App &)=delete
std::string_view GetName () const
AppPhase GetPhase () const
std::span< const std::string > GetArgs () const
rex::hid::IInputSystem & GetInput ()
rex::gpu::IGraphicsSystem & GetGraphics ()
rex::apu::IAudioSystem & GetAudio ()
rex::ui::IUISystem & GetUI ()
void RequestShutdown ()
void RequestRestart ()
Result< void > Init (const CLIArgList &args)
bool RunFrame ()
void Run ()
int Shutdown ()
Public Member Functions inherited from rex::SettingOwner
 SettingOwner (std::string_view scope)
virtual ~SettingOwner ()
const std::string & GetScope () const
std::span< SettingBase *const > GetOwnedSettings () const

Protected Member Functions

virtual AppSysRequirements GetRequirements () const
virtual Result< void > OnConfigure (SettingsRegistry &settings)
virtual std::span< const CLIAction > GetActions () const
virtual Result< void > OnAction (const CLIActionHit &hit)
virtual void OnModules (std::vector< std::string > &modules)
virtual void OnRegisterModules (std::vector< IModule * > &modules)
virtual Result< void > OnInit ()
virtual void OnRun ()
virtual void OnShutdown ()
virtual void ReportError (std::string_view message)
virtual platform::CrashReporterOptions GetCrashOptions ()
rex::ui::IUISystem * FindUI ()
bool IsHeadlessRequested () const
Result< void > Fail (std::string_view step, Error error)
virtual void OnStop ()
virtual void OnRelease ()
IInterfaceFactory & GetControlFactory ()
void SetPhase (AppPhase phase)
Protected Member Functions inherited from rex::NonCopyable
 NonCopyable (const NonCopyable &)=delete
NonCopyable & operator= (const NonCopyable &)=delete

Detailed Description

A program derives from it, overrides the hooks it needs and hands the class to REX_TITLE_APP or REX_CONSOLE_APP. It owns the app.* path settings.

Constructor & Destructor Documentation

◆ App()

rex::app::App::App ( std::string_view name)
explicit
Parameters
nameThe app name, which names the config file and the log file.

Member Function Documentation

◆ Fail()

Result< void > rex::app::App::Fail ( std::string_view step,
Error error )
nodiscardprotected

Marks a failed lifecycle step so Shutdown returns 1, and reports it.

Parameters
stepName of the step, used in the report.
Returns
The error, for the step to return.

◆ FindUI()

rex::ui::IUISystem * rex::app::App::FindUI ( )
protected

Returns the UI system, or null while the systems are not connected and after a failed start released them.

◆ GetActions()

virtual std::span< const CLIAction > rex::app::App::GetActions ( ) const
protectedvirtual

Returns the command line actions this program accepts, such as –version. The default has none.

◆ GetArgs()

std::span< const std::string > rex::app::App::GetArgs ( ) const

Returns the positional command line arguments the framework did not consume.

◆ GetControlFactory()

IInterfaceFactory & rex::app::App::GetControlFactory ( )
protected

Returns the internal interfaces of the systems, for TitleRuntime::Launch.

◆ GetCrashOptions()

virtual platform::CrashReporterOptions rex::app::App::GetCrashOptions ( )
protectedvirtual

The base class names the app after the executable and shows no dialog.

Reimplemented in rex::app::TitleApp.

◆ GetInput()

rex::hid::IInputSystem & rex::app::App::GetInput ( )

Returns the input system. Its settings register in Init and it starts with the modules.

◆ GetRequirements()

virtual AppSysRequirements rex::app::App::GetRequirements ( ) const
protectedvirtual

Returns the systems this program needs. The app uses it to choose driver plugins and to fail startup when a required system has no driver. The default requires nothing.

Reimplemented in rex::app::TitleApp.

◆ Init()

Result< void > rex::app::App::Init ( const CLIArgList & args)
nodiscard

The start and modules phases. Ends with OnInit.

A shutdown or restart requested in OnConfigure or in OnAction ends startup once the log file is open, before the crash reporter and before any driver module loads. OnInit does not run, Init returns Ok and logs no error, and the caller goes on to Shutdown. A caller that runs Init itself tells the two outcomes apart with rex::app::IsShutdownRequested.

Returns
Ok after OnInit, or Ok with startup ended early because a shutdown or restart was requested, or an error, which the app logged and showed.

◆ IsHeadlessRequested()

bool rex::app::App::IsHeadlessRequested ( ) const
protected

Reports whether the program asked for no UI driver, in any layer or on the command line. The answer holds after the UI system is gone.

◆ OnAction()

virtual Result< void > rex::app::App::OnAction ( const CLIActionHit & hit)
nodiscardprotectedvirtual

Init, after the command line is read, once for each action given. A shutdown or restart requested here ends startup once the log file is open, before any driver module loads.

Parameters
hitThe action and the text given with it.
Returns
Ok, or an error that fails Init.

◆ OnConfigure()

virtual Result< void > rex::app::App::OnConfigure ( SettingsRegistry & settings)
nodiscardprotectedvirtual

Init, after the modules connect and before the config file, environment and command line apply. Set title layer values and register the program's own setting owners here. A shutdown or restart requested here ends startup before any driver module loads.

Returns
Ok, or an error that fails Init.

◆ OnInit()

virtual Result< void > rex::app::App::OnInit ( )
nodiscardprotectedvirtual

Init, last. The systems run and the window is open. Add fonts, styles and overlays here.

Returns
Ok, or an error that fails Init.

◆ OnModules()

virtual void rex::app::App::OnModules ( std::vector< std::string > & modules)
protectedvirtual

Init, before any module loads. Edits the module libraries rex::Init loads, in order. The default is rexfilesystem, rexhid, rexapu, rexui, rexgpu, rexxam, rexxbdm and rexkernel.

Parameters
modulesThe library names. The driver plugins load after them.

◆ OnRegisterModules()

virtual void rex::app::App::OnRegisterModules ( std::vector< IModule * > & modules)
protectedvirtual

Init, before modules connect. Register modules compiled into the program here.

Parameters
modulesWhere to add them. The app does not own them.

◆ OnRelease()

virtual void rex::app::App::OnRelease ( )
protectedvirtual

Releases what a derived app type created after Init. Runs after OnShutdown.

Reimplemented in rex::app::TitleApp.

◆ OnRun()

virtual void rex::app::App::OnRun ( )
protectedvirtual

The default calls RunFrame until a shutdown is requested.

Reimplemented in rex::app::TitleApp.

◆ OnShutdown()

virtual void rex::app::App::OnShutdown ( )
protectedvirtual

Shutdown, before drivers shut down. Logging and settings work.

◆ OnStop()

virtual void rex::app::App::OnStop ( )
protectedvirtual

Stops what a derived app type runs. Shutdown calls it first, before OnShutdown.

Reimplemented in rex::app::TitleApp.

◆ ReportError()

virtual void rex::app::App::ReportError ( std::string_view message)
protectedvirtual

Reports an error from a lifecycle step. The base class logs it.

Reimplemented in rex::app::TitleApp.

◆ RequestRestart()

void rex::app::App::RequestRestart ( )

Asks the app to shut down and start the process again with the same arguments, so kRestart settings take effect. Any thread.

◆ RequestShutdown()

void rex::app::App::RequestShutdown ( )

Asks the app to shut down, stopping a running title first. Any thread.

◆ Run()

void rex::app::App::Run ( )

The running phase. Calls OnRun.

◆ RunFrame()

bool rex::app::App::RunFrame ( )

Runs one frame of the running phase, delivering window events and the work posted to the UI thread.

Returns
False once a shutdown was requested or the UI loop ended.

◆ SetPhase()

void rex::app::App::SetPhase ( AppPhase phase)
protected

Moves the app to a phase between kRunning and kTitleStop, for an app that runs a title.

◆ Shutdown()

int rex::app::App::Shutdown ( )

The shutdown phase. Safe after a failed Init.

Returns
The exit code passed to rex::app::RequestShutdown if there was one, else 1 when a step failed, else 0.

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