75 REX_SETTING(std::string, name,
"",
"App name, set by the constructor", kStartupOnly, kNoSave);
76 REX_SETTING(std::filesystem::path, root,
"",
77 "Folder the app keeps its files in, the folder of the executable when empty",
79 REX_SETTING(std::filesystem::path, log_root,
"{app.root}/logs",
"Log folder", kStartupOnly);
80 REX_SETTING(std::string, single_instance,
"",
81 "Lock name only one running copy may hold, empty for none", kStartupOnly);
86 explicit App(std::string_view name);
90 App& operator=(
const App&) =
delete;
92 std::string_view GetName()
const;
99 std::span<const std::string>
GetArgs()
const;
189 virtual void OnModules(std::vector<std::string>& modules);
255 std::unique_ptr<State> state_;
296#define REX_CONSOLE_APP(AppClass) \
297 static int ReXConsoleEntry(const ::rex::CLIArgList& args) { \
299 if (rex_app.Init(args)) { \
302 return rex_app.Shutdown(); \
304 REX_DETAIL_ENTRY_POINTS(ReXConsoleEntry)
322#define REX_CONSOLE_APP_MAIN(AppClass, Function) \
323 static int ReXConsoleEntry(const ::rex::CLIArgList& args) { \
325 return Function(rex_app, args); \
327 REX_DETAIL_ENTRY_POINTS(ReXConsoleEntry)
338REX_APP_API int ReportEntryFailure(
const char* what)
noexcept;
346template <
typename Fn>
347int RunGuarded(Fn&& fn)
noexcept {
349 return std::forward<Fn>(fn)();
350 }
catch (
const std::exception& error) {
351 return ReportEntryFailure(error.what());
353 return ReportEntryFailure(
"unknown exception");
357#if REX_PLATFORM_WIN32
369#if REX_PLATFORM_WIN32
379#define REX_DETAIL_ENTRY_POINTS(fn) \
380 int WINAPI wWinMain(HINSTANCE, HINSTANCE, PWSTR, int) { \
381 return ::rex::app::detail::RunGuarded( \
382 [] { return fn(::rex::app::detail::GetWindowsCommandLine()); }); \
384 int main(int argc, char** argv) { \
385 return ::rex::app::detail::RunGuarded( \
386 [&] { return fn(::rex::CLIArgList::Parse(argc, argv)); }); \
389#define REX_DETAIL_ENTRY_POINTS(fn) \
390 int main(int argc, char** argv) { \
391 return ::rex::app::detail::RunGuarded( \
392 [&] { return fn(::rex::CLIArgList::Parse(argc, argv)); }); \
REX_APP_API void RequestRestart(std::vector< std::string > args={})
REX_APP_API bool IsShutdownRequested()
AppPhase
Definition app.h:59
@ kStart
Definition app.h:60
@ kRunning
Definition app.h:62
@ kTitleStop
Definition app.h:65
@ kTitleLaunch
Definition app.h:63
@ kShutdown
Definition app.h:66
@ kProviders
Definition app.h:61
REX_APP_API void RequestShutdown(i32 exit_code)
SettingOwner(std::string_view scope)
App(std::string_view name)
bool IsHeadlessRequested() const
virtual Result< void > OnConfigure(SettingsRegistry &settings)
virtual Result< void > OnAction(const CLIActionHit &hit)
std::span< const std::string > GetArgs() const
virtual void OnRegisterModules(std::vector< IModule * > &modules)
virtual void ReportError(std::string_view message)
virtual void OnModules(std::vector< std::string > &modules)
rex::ui::IUISystem * FindUI()
virtual void OnShutdown()
virtual std::span< const CLIAction > GetActions() const
IInterfaceFactory & GetControlFactory()
void SetPhase(AppPhase phase)
Result< void > Init(const CLIArgList &args)
Result< void > Fail(std::string_view step, Error error)
virtual Result< void > OnInit()
virtual platform::CrashReporterOptions GetCrashOptions()
rex::hid::IInputSystem & GetInput()
virtual AppSysRequirements GetRequirements() const
Definition audio_system.h:64
Definition graphics_system.h:54
Definition ui_system.h:154
Interfaces, factory and module declaration.
std::expected< T, Error > Result
Definition result.h:98
Process control, console, environment and crash reports.
Typed settings and the owners that declare them.
The registry of every registered setting.
Integer types, byte order wrappers and size literals.