Helios Engine
A modular ECS based data-oriented C++23 game engine framework
Loading...
Searching...
No Matches
helios::app Namespace Reference

Namespaces

namespace  anonymous_namespace{application.cpp}

Classes

class  App
 Application class. More...
struct  AppExit
 Message that requests the application to exit. More...
class  DynamicPlugin
 Wrapper for dynamically loaded plugins. More...
struct  DynamicPluginConfig
 Configuration for dynamic plugin loading. More...
struct  Extract
 Extract schedule (runs after the last frame schedule). More...
struct  ExtractStage
 Stage for per-frame extraction into sub-apps. More...
struct  First
 First schedule in a frame. More...
struct  FixedRunnerConfig
 Configuration for fixed-timestep runners. More...
struct  Last
 Last schedule in a frame. More...
struct  MainStartup
 Main-thread startup schedule (window creation, etc.). More...
class  Plugin
 Base class for all plugins. More...
struct  PluginTypeExport
 C-compatible plugin identity exported by dynamic libraries. More...
struct  PostShutdown
 Post-shutdown schedule. More...
struct  PostStartup
 Post-startup schedule. More...
struct  PostUpdate
 Post-update schedule. More...
struct  PreShutdown
 Pre-shutdown schedule. More...
struct  PreStartup
 Pre-startup schedule. More...
struct  PreUpdate
 Pre-update schedule. More...
class  Scheduler
 Orchestrates the main sub-app schedule loop and sub-app updates. More...
struct  Shutdown
 Shutdown schedule. More...
struct  ShutdownStage
 Stage for one-time shutdown execution. More...
struct  Startup
 Startup schedule. More...
struct  StartupStage
 Stage for one-time startup execution. More...
class  SubApp
 A sub-application with its own ECS world and scheduler. More...
struct  Update
 Update schedule. More...
struct  UpdateStage
 Stage for per-frame game logic. More...

Concepts

concept  AsyncSubAppTrait
 Concept for sub-apps that run updates on a background loop.
concept  OverlappingUpdatesSubAppTrait
 Concept for sub-apps that allow skipping extraction while updating.
concept  PluginTrait
 Concept to ensure a type is a valid Plugin.
concept  PluginWithNameTrait
 Concept for plugins that provide a name.
concept  SubAppTrait
 Trait to identify valid sub-app types.
concept  SubAppWithMaxOverlappingUpdatesTrait
 Concept for sub-apps with a maximum extraction-skip budget.
concept  SubAppWithNameTrait
 Concept for sub-apps that provide custom names.

Typedefs

using CreatePluginFn = Plugin* (*)()
 Function signature for plugin creation.
using PluginTypeExportFn = const PluginTypeExport* (*)()
 Function signature for the plugin type export symbol.
template<typename T>
using DynamicPluginResult = std::expected<T, DynamicPluginError>
using PluginTypeIndex = utils::TypeIndex
 Type index for plugins.
using PluginTypeId = utils::TypeId
 Type id for plugins.
using SubAppTypeIndex = utils::TypeIndex
 Type index for sub-apps.
using SubAppTypeId = utils::TypeId
 Type id for sub-apps.

Enumerations

enum class  ExitCode : uint8_t { kSuccess = 0 , kFailure = 1 }
 Application exit codes. More...
enum class  DynamicPluginError : uint8_t {
  kLibraryLoadFailed , kCreateSymbolNotFound , kIdSymbolNotFound , kNameSymbolNotFound ,
  kCreateFailed , kReloadFailed
}
 Error codes for dynamic plugin operations. More...

Functions

constexpr std::string_view DynamicPluginErrorToString (DynamicPluginError error) noexcept
 Gets a human-readable description for a DynamicPluginError.
template<PluginTrait T>
constexpr std::string_view PluginNameOf () noexcept
 Gets name for a plugin type.
template<PluginTrait T>
constexpr std::string_view PluginNameOf (const T &) noexcept
 Gets name for a plugin type.
ExitCode RunDefault (App &app)
 Runs the application until an AppExit message is received.
ExitCode RunFixed (App &app, const FixedRunnerConfig &config={})
 Runs the application with a fixed timestep.
ExitCode RunOnce (App &app)
 Runs a single application frame.
void RunDefaultSubApp (SubApp &sub_app, async::Executor &executor)
 Runs the sub-app update loop until SubApp::ShouldExit is true.
void RunFixedSubApp (SubApp &sub_app, async::Executor &executor, const FixedRunnerConfig &config={})
 Runs the sub-app with a fixed timestep.
void RunOnceSubApp (SubApp &sub_app, async::Executor &executor)
 Runs a single sub-app update stage.
void RegisterBuiltinSchedules (ecs::Scheduler &scheduler)
 Registers default application schedules on an ECS scheduler.
void RegisterBuiltinSubAppSchedules (ecs::Scheduler &scheduler)
 Registers built-in schedules for a sub-app ECS scheduler.
template<SubAppTrait T>
constexpr std::string_view SubAppNameOf (const T &sub_app={}) noexcept
 Returns the name of the sub-app.
template<SubAppTrait T>
consteval bool IsSubAppAllowsOverlappingUpdates (const T &={}) noexcept
 Returns whether the sub-app allows extraction skips while updating.
template<OverlappingUpdatesSubAppTrait T>
consteval size_t SubAppMaxOverlappingUpdates (const T &={}) noexcept
 Returns the maximum consecutive extraction skips for the sub-app.
template<SubAppTrait T>
consteval bool IsSubAppAsync (const T &={}) noexcept
 Returns whether the sub-app runs updates on a background loop.

Variables

constexpr std::string_view kDefaultCreateSymbol = "helios_create_plugin"
 Default symbol name for the plugin creation function.
constexpr std::string_view kDefaultPluginIdSymbol
 Default symbol name for the plugin ID function.
constexpr StartupStage kStartupStage {}
 Builtin stage for startup.
constexpr UpdateStage kUpdateStage {}
 Builtin stage for per-frame updates.
constexpr ExtractStage kExtractStage {}
 Builtin stage for extraction.
constexpr ShutdownStage kShutdownStage {}
 Builtin stage for shutdown.
constexpr MainStartup kMainStartup {}
 Builtin main-thread startup schedule.
constexpr PreStartup kPreStartup {}
 Builtin pre-startup schedule.
constexpr Startup kStartup {}
 Builtin startup schedule.
constexpr PostStartup kPostStartup {}
 Builtin post-startup schedule.
constexpr First kFirst {}
 Builtin first schedule.
constexpr PreUpdate kPreUpdate {}
 Builtin pre-update schedule.
constexpr Update kUpdate {}
 Builtin update schedule.
constexpr PostUpdate kPostUpdate {}
 Builtin post-update schedule.
constexpr Last kLast {}
 Builtin last schedule.
constexpr Extract kExtract {}
 Builtin extract schedule.
constexpr PreShutdown kPreShutdown {}
 Builtin pre-shutdown schedule.
constexpr Shutdown kShutdown {}
 Builtin shutdown schedule.
constexpr PostShutdown kPostShutdown {}
 Builtin post-shutdown schedule.

Typedef Documentation

◆ CreatePluginFn

Function signature for plugin creation.

Dynamic plugins must export a function with this signature. The function should create and return a new Plugin instance.

Definition at line 27 of file dynamic_plugin.hpp.

◆ DynamicPluginResult

template<typename T>
using helios::app::DynamicPluginResult = std::expected<T, DynamicPluginError>

Definition at line 101 of file dynamic_plugin.hpp.

◆ PluginTypeExportFn

Function signature for the plugin type export symbol.

Dynamic plugins must export this with C linkage. The returned pointer must remain valid for the lifetime of the library image.

Definition at line 81 of file dynamic_plugin.hpp.

◆ PluginTypeId

Type id for plugins.

Definition at line 68 of file plugin.hpp.

◆ PluginTypeIndex

Type index for plugins.

Definition at line 65 of file plugin.hpp.

◆ SubAppTypeId

Type id for sub-apps.

Definition at line 42 of file sub_app.hpp.

◆ SubAppTypeIndex

Type index for sub-apps.

Definition at line 39 of file sub_app.hpp.

Enumeration Type Documentation

◆ DynamicPluginError

enum class helios::app::DynamicPluginError : uint8_t
strong

Error codes for dynamic plugin operations.

Enumerator
kLibraryLoadFailed 

Failed to load the dynamic library.

kCreateSymbolNotFound 

Plugin creation function not found.

kIdSymbolNotFound 

Plugin ID function not found.

kNameSymbolNotFound 

Plugin name function not found.

kCreateFailed 

Plugin creation function returned nullptr.

kReloadFailed 

Failed to reload plugin.

Definition at line 91 of file dynamic_plugin.hpp.

◆ ExitCode

enum class helios::app::ExitCode : uint8_t
strong

Application exit codes.

Enumerator
kSuccess 

Successful execution.

kFailure 

General failure.

Definition at line 47 of file application.hpp.

Function Documentation

◆ DynamicPluginErrorToString()

std::string_view helios::app::DynamicPluginErrorToString ( DynamicPluginError error)
nodiscardconstexprnoexcept

Gets a human-readable description for a DynamicPluginError.

Parameters
errorThe error code
Returns
String description of the error

Definition at line 108 of file dynamic_plugin.hpp.

◆ IsSubAppAllowsOverlappingUpdates()

template<SubAppTrait T>
bool helios::app::IsSubAppAllowsOverlappingUpdates ( const T & = {})
nodiscardconstevalnoexcept

Returns whether the sub-app allows extraction skips while updating.

Template Parameters
TThe type of the sub-app
Returns
Whether overlapping extraction skips are enabled

Definition at line 100 of file sub_app.hpp.

◆ IsSubAppAsync()

template<SubAppTrait T>
bool helios::app::IsSubAppAsync ( const T & = {})
nodiscardconstevalnoexcept

Returns whether the sub-app runs updates on a background loop.

Template Parameters
TThe type of the sub-app
Returns
True when kAsync is set on the label type

Definition at line 127 of file sub_app.hpp.

◆ PluginNameOf() [1/2]

template<PluginTrait T>
std::string_view helios::app::PluginNameOf ( )
nodiscardconstexprnoexcept

Gets name for a plugin type.

Template Parameters
TPlugin type
Returns
Name of the plugin

Definition at line 95 of file plugin.hpp.

◆ PluginNameOf() [2/2]

template<PluginTrait T>
std::string_view helios::app::PluginNameOf ( const T & )
nodiscardconstexprnoexcept

Gets name for a plugin type.

Template Parameters
TPlugin type
Parameters
pluginPlugin instance
Returns
Name of the plugin

Definition at line 110 of file plugin.hpp.

◆ RegisterBuiltinSchedules()

void helios::app::RegisterBuiltinSchedules ( ecs::Scheduler & scheduler)
inline

Registers default application schedules on an ECS scheduler.

Creates empty schedules for all built-in types and assigns default executor kinds, stage membership, and ordering.

Parameters
schedulerECS scheduler to populate

Definition at line 154 of file schedules.hpp.

◆ RegisterBuiltinSubAppSchedules()

void helios::app::RegisterBuiltinSubAppSchedules ( ecs::Scheduler & scheduler)
inline

Registers built-in schedules for a sub-app ECS scheduler.

Same as RegisterBuiltinSchedules except extract stage and schedules are omitted; extraction is driven by the main app via SubApp::Extract.

Parameters
schedulerECS scheduler to populate

Definition at line 223 of file schedules.hpp.

◆ RunDefault()

ExitCode helios::app::RunDefault ( App & app)
inline

Runs the application until an AppExit message is received.

Parameters
appApplication to update
Returns
Exit code from the first AppExit message

Definition at line 66 of file runners.hpp.

◆ RunDefaultSubApp()

void helios::app::RunDefaultSubApp ( SubApp & sub_app,
async::Executor & executor )
inline

Runs the sub-app update loop until SubApp::ShouldExit is true.

Intended for async sub-apps via SubApp::SetRunner.

Parameters
sub_appSub-app to update
executorAsync executor used to build and run schedules

Definition at line 115 of file runners.hpp.

◆ RunFixed()

ExitCode helios::app::RunFixed ( App & app,
const FixedRunnerConfig & config = {} )
inline

Runs the application with a fixed timestep.

Uses sleep_until against an advancing absolute target time point so that scheduler wake-up overshoot on one frame is automatically absorbed by a shorter sleep on the next, preventing drift accumulation.

Parameters
appApplication to update
configFixed-runner configuration
Returns
Exit code from the first AppExit message

Definition at line 83 of file runners.hpp.

◆ RunFixedSubApp()

void helios::app::RunFixedSubApp ( SubApp & sub_app,
async::Executor & executor,
const FixedRunnerConfig & config = {} )
inline

Runs the sub-app with a fixed timestep.

Intended for async sub-apps via SubApp::SetRunner. Uses sleep_until against an advancing absolute target time point so that scheduler wake-up overshoot on one frame is automatically absorbed by a shorter sleep on the next, preventing drift accumulation.

Parameters
sub_appSub-app to update
executorAsync executor used to build and run schedules
configFixed-runner configuration

Definition at line 131 of file runners.hpp.

◆ RunOnce()

ExitCode helios::app::RunOnce ( App & app)
inline

Runs a single application frame.

Parameters
appApplication to update
Returns
Exit code from an AppExit message, or ExitCode::kSuccess

Definition at line 104 of file runners.hpp.

◆ RunOnceSubApp()

void helios::app::RunOnceSubApp ( SubApp & sub_app,
async::Executor & executor )
inline

Runs a single sub-app update stage.

Intended for SubApp::SetRunner or blocking per-frame updates.

Parameters
sub_appSub-app to update
executorAsync executor used to build and run schedules

Definition at line 152 of file runners.hpp.

◆ SubAppMaxOverlappingUpdates()

template<OverlappingUpdatesSubAppTrait T>
size_t helios::app::SubAppMaxOverlappingUpdates ( const T & = {})
nodiscardconstevalnoexcept

Returns the maximum consecutive extraction skips for the sub-app.

0 means unlimited skips while an update is in flight.

Template Parameters
TThe type of the sub-app
Returns
Maximum extraction skip budget

Definition at line 112 of file sub_app.hpp.

◆ SubAppNameOf()

template<SubAppTrait T>
std::string_view helios::app::SubAppNameOf ( const T & sub_app = {})
nodiscardconstexprnoexcept

Returns the name of the sub-app.

Template Parameters
TThe type of the sub-app
Parameters
sub_appThe sub-app to get the name of
Returns
The name of the sub-app

Definition at line 85 of file sub_app.hpp.

Variable Documentation

◆ kDefaultCreateSymbol

std::string_view helios::app::kDefaultCreateSymbol = "helios_create_plugin"
inlineconstexpr

Default symbol name for the plugin creation function.

Definition at line 84 of file dynamic_plugin.hpp.

◆ kDefaultPluginIdSymbol

std::string_view helios::app::kDefaultPluginIdSymbol
inlineconstexpr
Initial value:
=
"helios_plugin_type_id"

Default symbol name for the plugin ID function.

Definition at line 87 of file dynamic_plugin.hpp.

◆ kExtract

Extract helios::app::kExtract {}
inlineconstexpr

Builtin extract schedule.

Definition at line 122 of file schedules.hpp.

◆ kExtractStage

ExtractStage helios::app::kExtractStage {}
inlineconstexpr

Builtin stage for extraction.

Definition at line 34 of file schedules.hpp.

◆ kFirst

First helios::app::kFirst {}
inlineconstexpr

Builtin first schedule.

Definition at line 82 of file schedules.hpp.

◆ kLast

Last helios::app::kLast {}
inlineconstexpr

Builtin last schedule.

Definition at line 114 of file schedules.hpp.

◆ kMainStartup

MainStartup helios::app::kMainStartup {}
inlineconstexpr

Builtin main-thread startup schedule.

Definition at line 50 of file schedules.hpp.

◆ kPostShutdown

PostShutdown helios::app::kPostShutdown {}
inlineconstexpr

Builtin post-shutdown schedule.

Definition at line 146 of file schedules.hpp.

◆ kPostStartup

PostStartup helios::app::kPostStartup {}
inlineconstexpr

Builtin post-startup schedule.

Definition at line 74 of file schedules.hpp.

◆ kPostUpdate

PostUpdate helios::app::kPostUpdate {}
inlineconstexpr

Builtin post-update schedule.

Definition at line 106 of file schedules.hpp.

◆ kPreShutdown

PreShutdown helios::app::kPreShutdown {}
inlineconstexpr

Builtin pre-shutdown schedule.

Definition at line 130 of file schedules.hpp.

◆ kPreStartup

PreStartup helios::app::kPreStartup {}
inlineconstexpr

Builtin pre-startup schedule.

Definition at line 58 of file schedules.hpp.

◆ kPreUpdate

PreUpdate helios::app::kPreUpdate {}
inlineconstexpr

Builtin pre-update schedule.

Definition at line 90 of file schedules.hpp.

◆ kShutdown

Shutdown helios::app::kShutdown {}
inlineconstexpr

Builtin shutdown schedule.

Definition at line 138 of file schedules.hpp.

◆ kShutdownStage

ShutdownStage helios::app::kShutdownStage {}
inlineconstexpr

Builtin stage for shutdown.

Definition at line 42 of file schedules.hpp.

◆ kStartup

Startup helios::app::kStartup {}
inlineconstexpr

Builtin startup schedule.

Definition at line 66 of file schedules.hpp.

◆ kStartupStage

StartupStage helios::app::kStartupStage {}
inlineconstexpr

Builtin stage for startup.

Definition at line 18 of file schedules.hpp.

◆ kUpdate

Update helios::app::kUpdate {}
inlineconstexpr

Builtin update schedule.

Definition at line 98 of file schedules.hpp.

◆ kUpdateStage

UpdateStage helios::app::kUpdateStage {}
inlineconstexpr

Builtin stage for per-frame updates.

Definition at line 26 of file schedules.hpp.