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

Application class. More...

#include <app.hpp>

Public Types

using RunnerFn = std::function< AppExitCode(App &)>
 
using ExtractFn = std::function< void(const ecs::World &, ecs::World &)>
 

Public Member Functions

 App ()
 
 App (size_t worker_thread_count)
 Constructs an App with a specific number of worker threads.
 
 App (const App &)=delete
 
 App (App &&)=delete
 
 ~App ()
 Destructor that ensures all async work is completed before destruction.
 
Appoperator= (const App &)=delete
 
Appoperator= (App &&)=delete
 
void Clear ()
 Clears the application state, removing all data.
 
void Initialize ()
 Initializes the application and its subsystems.
 
void Update ()
 Updates the application and its subsystems.
 
AppExitCode Run ()
 Runs the application with the given arguments.
 
void WaitForOverlappingUpdates ()
 Waits for all overlapping sub-app updates to complete.
 
template<SubAppTrait T>
void WaitForOverlappingUpdates (T sub_app={})
 Waits for overlapping updates of a specific sub-app type to complete.
 
void WaitForOverlappingUpdates (const SubApp &sub_app)
 Waits for overlapping updates of a specific sub-app instance to complete.
 
void TickTime () noexcept
 Updates the Time resource for the current frame.
 
template<SubAppTrait T>
auto AddSubApp (this auto &&self, T sub_app={}) -> decltype(std::forward< decltype(self)>(self))
 Adds a new sub-application of type T.
 
template<SubAppTrait T>
auto AddSubApp (this auto &&self, SubApp sub_app, T sub_app_tag={}) -> decltype(std::forward< decltype(self)>(self))
 Adds an existing sub-application instance.
 
template<DefaultConstructibleModuleTrait T>
auto AddModule (this auto &&self) -> decltype(std::forward< decltype(self)>(self))
 Adds a default-constructed module to the main sub-app.
 
template<ModuleTrait T>
auto AddModule (this auto &&self, T module) -> decltype(std::forward< decltype(self)>(self))
 Adds a pre-constructed module instance to the main sub-app.
 
template<DefaultConstructibleModuleTrait... Modules>
requires (sizeof...(Modules) > 1 && utils::UniqueTypes<Modules...>)
auto AddModules (this auto &&self) -> decltype(std::forward< decltype(self)>(self))
 Adds multiple default-constructed modules to the main sub-app.
 
template<ModuleTrait... Modules>
requires (sizeof...(Modules) > 1 && utils::UniqueTypes<Modules...>)
auto AddModules (this auto &&self, Modules &&... modules) -> decltype(std::forward< decltype(self)>(self))
 Adds multiple pre-constructed module instances to the main sub-app.
 
auto AddDynamicModule (this auto &&self, DynamicModule module) -> decltype(std::forward< decltype(self)>(self))
 Adds a dynamic module to the main sub-app, taking ownership.
 
template<ecs::SystemTrait T, ScheduleTrait Schedule>
auto AddSystem (this auto &&self, Schedule schedule={}) -> decltype(std::forward< decltype(self)>(self))
 Adds a system to the specified schedule in the main sub-app.
 
template<ecs::SystemTrait... Systems, ScheduleTrait Schedule>
requires (sizeof...(Systems) > 1 && utils::UniqueTypes<Systems...>)
auto AddSystems (this auto &&self, Schedule schedule={}) -> decltype(std::forward< decltype(self)>(self))
 Adds multiple systems to the specified schedule in the main sub-app.
 
template<ecs::SystemTrait... Systems, ScheduleTrait Schedule>
requires (sizeof...(Systems) > 0 && utils::UniqueTypes<Systems...>)
auto AddSystemsBuilder (this auto &&self, Schedule schedule={}) -> SystemConfig< Schedule, Systems... >
 
template<ecs::SystemTrait T, ScheduleTrait Schedule>
auto AddSystemBuilder (this auto &&self, Schedule schedule={}) -> SystemConfig< Schedule, T >
 Adds a single system with fluent configuration builder.
 
template<SystemSetTrait Set, ScheduleTrait Schedule>
auto ConfigureSet (this auto &&self, Schedule schedule={}) -> SystemSetConfig< Schedule, Set >
 
template<ecs::ResourceTrait T>
auto InsertResource (this auto &&self, T &&resource) -> decltype(std::forward< decltype(self)>(self))
 Inserts a resource into the main sub-app.
 
template<ecs::ResourceTrait T, typename... Args>
requires std::constructible_from<T, Args...>
auto EmplaceResource (this auto &&self, Args &&... args) -> decltype(std::forward< decltype(self)>(self))
 Emplaces a resource into the main sub-app's world.
 
template<ecs::EventTrait T>
auto AddEvent (this auto &&self) -> decltype(std::forward< decltype(self)>(self))
 Registers an event type for use in the main sub-app.
 
template<ecs::EventTrait... Events>
requires (sizeof...(Events) > 1)
auto AddEvents (this auto &&self) -> decltype(std::forward< decltype(self)>(self))
 Registers multiple event types for use in the main sub-app.
 
auto SetRunner (this auto &&self, RunnerFn runner) noexcept -> decltype(std::forward< decltype(self)>(self))
 Sets runner function for the application.
 
template<SubAppTrait T>
auto SetSubAppExtraction (this auto &&self, ExtractFn extract_fn) -> decltype(std::forward< decltype(self)>(self))
 Sets extraction function for a sub-app.
 
template<SubAppTrait T>
bool ContainsSubApp () const noexcept
 Checks if a sub app of type T exists in main sub-app.
 
template<ModuleTrait T>
bool ContainsModule () const noexcept
 Checks if a module of type T exists in main sub-app.
 
bool ContainsDynamicModule (ModuleTypeId module_id) const noexcept
 Checks if a dynamic module with the given ID exists.
 
template<ecs::SystemTrait T>
bool ContainsSystem () const noexcept
 Checks if a system of type T exists in any schedule of main sub-app.
 
template<ecs::SystemTrait T, ScheduleTrait Schedule>
bool ContainsSystem (Schedule schedule={}) const noexcept
 Checks if a system of type T exists in the specified schedule of main sub-app.
 
bool IsInitialized () const noexcept
 Checks if the app has been initialized.
 
bool IsRunning () const noexcept
 Checks if the app is currently running.
 
template<ecs::ResourceTrait T>
bool HasResource () const noexcept
 Checks if a resource exists in main sub_app.
 
template<ecs::EventTrait T>
bool HasEvent () const noexcept
 Checks if a event is registered in main sub_app.
 
size_t ModuleCount () const noexcept
 Gets the number of modules in main sub-app.
 
size_t SystemCount () const noexcept
 Gets the total number of systems across all schedules in main sub-app.
 
template<ScheduleTrait Schedule>
size_t SystemCount (Schedule schedule={}) const noexcept
 Gets the number of systems in the specified schedule of main sub-app.
 
template<SubAppTrait T>
SubAppGetSubApp () noexcept
 Gets a sub-application by type.
 
template<SubAppTrait T>
const SubAppGetSubApp () const noexcept
 Gets a sub-application by type (const version).
 
SubAppGetMainSubApp () noexcept
 Gets the main sub-application.
 
const SubAppGetMainSubApp () const noexcept
 Gets the main sub-application (const version).
 
const ecs::WorldGetMainWorld () const noexcept
 Gets the main world.
 
async::ExecutorGetExecutor () noexcept
 Gets the async executor.
 
const async::ExecutorGetExecutor () const noexcept
 Gets the async executor (const version).
 

Detailed Description

Application class.

Manages the application lifecycle, including initialization, updating, and shutdown.

Note
Not thread-safe.
Examples
/home/runner/work/HeliosEngine/HeliosEngine/src/modules/example/include/helios/example/example.hpp.

Definition at line 97 of file app.hpp.

Member Typedef Documentation

◆ ExtractFn

◆ RunnerFn

Constructor & Destructor Documentation

◆ App() [1/4]

helios::app::App::App ( )
Examples
/home/runner/work/HeliosEngine/HeliosEngine/src/core/include/helios/core/app/app.hpp.

Definition at line 22 of file app.cpp.

22: runner_(DefaultRunnerWrapper) {}

◆ App() [2/4]

helios::app::App::App ( size_t  worker_thread_count)
explicit

Constructs an App with a specific number of worker threads.

Parameters
worker_thread_countNumber of worker threads for the executor

Definition at line 24 of file app.cpp.

24: executor_(worker_thread_count), runner_(DefaultRunnerWrapper) {}

◆ App() [3/4]

helios::app::App::App ( const App )
delete

◆ App() [4/4]

helios::app::App::App ( App &&  )
delete

◆ ~App()

helios::app::App::~App ( )

Destructor that ensures all async work is completed before destruction.

Waits for all overlapping updates and pending executor tasks to complete.

Examples
/home/runner/work/HeliosEngine/HeliosEngine/src/core/include/helios/core/app/app.hpp.

Definition at line 26 of file app.cpp.

26 {
27 // Ensure we're not running (should already be false if properly shut down)
28 is_running_.store(false, std::memory_order_release);
29
30 // Wait for any pending overlapping sub-app updates
32
33 // Wait for all pending executor tasks to complete
34 executor_.WaitForAll();
35}
void WaitForOverlappingUpdates()
Waits for all overlapping sub-app updates to complete.
Definition app.cpp:172
void WaitForAll()
Blocks until all submitted tasks complete.
Definition executor.hpp:298

Member Function Documentation

◆ AddDynamicModule()

auto helios::app::App::AddDynamicModule ( this auto &&  self,
DynamicModule  module 
) -> decltype(std::forward<decltype(self)>(self))
inline

Adds a dynamic module to the main sub-app, taking ownership.

Modules can add their own systems, resources, and sub-apps. The App takes ownership of the module via move semantics.

Warning
Triggers an assertion if app is initialized or running.
Parameters
moduleDynamic module to add (moved)
Returns
Reference to app for method chaining
Examples
/home/runner/work/HeliosEngine/HeliosEngine/src/core/include/helios/core/app/app.hpp.

Definition at line 722 of file app.hpp.

723 {
724 const std::string_view name = module.GetModuleName();
725 const ModuleTypeId id = module.GetModuleId();
726
727 HELIOS_ASSERT(!self.IsInitialized(), "Failed to add module '{}': Cannot add modules after app initialization!", name);
728 HELIOS_ASSERT(!self.IsRunning(), "Failed to add module '{}': Cannot add modules while app is running!", name);
729 HELIOS_ASSERT(module.Loaded(), "Failed to add module '{}': Module is not loaded!", name);
730
731 // Check both static and dynamic module maps for duplicates
732 if (self.module_index_map_.contains(id) || self.dynamic_module_index_map_.contains(id)) [[unlikely]] {
733 HELIOS_WARN("Module '{}' already exists in app!", name);
734 return std::forward<decltype(self)>(self);
735 }
736
737 self.dynamic_module_index_map_[id] = self.dynamic_modules_.size();
738 self.dynamic_modules_.push_back(std::move(module));
739 return std::forward<decltype(self)>(self);
740}
#define HELIOS_ASSERT(condition,...)
Assertion macro that aborts execution in debug builds.
Definition assert.hpp:140
#define HELIOS_WARN(...)
Definition logger.hpp:687
size_t ModuleTypeId
Definition module.hpp:88

◆ AddEvent()

template<ecs::EventTrait T>
auto helios::app::App::AddEvent ( this auto &&  self) -> decltype(std::forward<decltype(self)>(self))
inline

Registers an event type for use in the main sub-app.

Events must be registered before they can be written or read.

Warning
Triggers assertion if app is initialized or running.
Template Parameters
TEvent type
Returns
Reference to app for method chaining
Examples
/home/runner/work/HeliosEngine/HeliosEngine/src/core/include/helios/core/app/app.hpp.

Definition at line 794 of file app.hpp.

794 {
795 HELIOS_ASSERT(!self.IsInitialized(), "Failed to add event '{}': Cannot add events after app initialization!",
797
798 HELIOS_ASSERT(!self.IsRunning(), "Failed to add event '{}': Cannot add events while app is running!",
800
801 if (self.template HasEvent<T>()) [[unlikely]] {
802 HELIOS_WARN("Event '{}' is already exist in app!", ecs::EventNameOf<T>());
803 return std::forward<decltype(self)>(self);
804 }
805
806 self.GetMainSubApp().template AddEvent<T>();
807 return std::forward<decltype(self)>(self);
808}
BasicQuery< World, Allocator, Components... > Query
Type alias for query with mutable world access.
Definition query.hpp:2481

◆ AddEvents()

template<ecs::EventTrait... Events>
requires (sizeof...(Events) > 1)
auto helios::app::App::AddEvents ( this auto &&  self) -> decltype(std::forward<decltype(self)>(self))
inline

Registers multiple event types for use in the main sub-app.

Warning
Triggers assertion if app is initialized or running.
Template Parameters
EventsEvent types to register
Returns
Reference to app for method chaining
Examples
/home/runner/work/HeliosEngine/HeliosEngine/src/core/include/helios/core/app/app.hpp.

Definition at line 812 of file app.hpp.

812 {
813 HELIOS_ASSERT(!self.IsInitialized(), "Failed to add events: Cannot add events after app initialization!");
814 HELIOS_ASSERT(!self.IsRunning(), "Failed to add events: Cannot add events while app is running!");
815
816 self.GetMainSubApp().template AddEvents<Events...>();
817 return std::forward<decltype(self)>(self);
818}
auto AddEvents(this auto &&self) -> decltype(std::forward< decltype(self)>(self))
Registers multiple event types for use in the main sub-app.
Definition app.hpp:812

◆ AddModule() [1/2]

template<DefaultConstructibleModuleTrait T>
auto helios::app::App::AddModule ( this auto &&  self) -> decltype(std::forward<decltype(self)>(self))
inline

Adds a default-constructed module to the main sub-app.

Modules can add their own systems, resources, and sub-apps.

Warning
Triggers an assertion if app is initialized or running.
Template Parameters
TModule type (must be default constructible)
Returns
Reference to app for method chaining
Examples
/home/runner/work/HeliosEngine/HeliosEngine/src/core/include/helios/core/app/app.hpp, and /home/runner/work/HeliosEngine/HeliosEngine/src/modules/example/include/helios/example/example.hpp.

Definition at line 663 of file app.hpp.

663 {
664 HELIOS_ASSERT(!self.IsInitialized(), "Failed to add module '{}': Cannot add modules after app initialization!",
665 ModuleNameOf<T>());
666
667 HELIOS_ASSERT(!self.IsRunning(), "Failed to add module '{}': Cannot add modules while app is running!",
668 ModuleNameOf<T>());
669
670 // module->Build(self); // Will be called after all modules are added
671 constexpr ModuleTypeId id = ModuleTypeIdOf<T>();
672 if (self.module_index_map_.contains(id)) [[unlikely]] {
673 HELIOS_WARN("Module '{}' is already exist in app!", ModuleNameOf<T>());
674 return std::forward<decltype(self)>(self);
675 }
676
677 self.module_index_map_[id] = self.modules_.size();
678 auto module = std::make_unique<T>();
679 self.modules_.push_back(std::move(module));
680 return std::forward<decltype(self)>(self);
681}

◆ AddModule() [2/2]

template<ModuleTrait T>
auto helios::app::App::AddModule ( this auto &&  self,
module 
) -> decltype(std::forward<decltype(self)>(self))
inline

Adds a pre-constructed module instance to the main sub-app.

Allows adding modules with non-default constructors or pre-configured state.

Warning
Triggers an assertion if app is initialized or running.
Template Parameters
TModule type
Parameters
moduleModule instance to add (will be moved)
Returns
Reference to app for method chaining

Definition at line 684 of file app.hpp.

684 {
685 HELIOS_ASSERT(!self.IsInitialized(), "Failed to add module '{}': Cannot add modules after app initialization!",
686 ModuleNameOf<T>());
687
688 HELIOS_ASSERT(!self.IsRunning(), "Failed to add module '{}': Cannot add modules while app is running!",
689 ModuleNameOf<T>());
690
691 constexpr ModuleTypeId id = ModuleTypeIdOf<T>();
692 if (self.module_index_map_.contains(id)) [[unlikely]] {
693 HELIOS_WARN("Module '{}' is already exist in app!", ModuleNameOf<T>());
694 return std::forward<decltype(self)>(self);
695 }
696
697 self.module_index_map_[id] = self.modules_.size();
698 self.modules_.push_back(std::make_unique<T>(std::move(module)));
699 return std::forward<decltype(self)>(self);
700}

◆ AddModules() [1/2]

template<DefaultConstructibleModuleTrait... Modules>
requires (sizeof...(Modules) > 1 && utils::UniqueTypes<Modules...>)
auto helios::app::App::AddModules ( this auto &&  self) -> decltype(std::forward<decltype(self)>(self))
inline

Adds multiple default-constructed modules to the main sub-app.

Warning
Triggers an assertion if app is initialized or running.
Template Parameters
ModulesModule types (must be default constructible)
Returns
Reference to app for method chaining
Examples
/home/runner/work/HeliosEngine/HeliosEngine/src/core/include/helios/core/app/app.hpp.

Definition at line 704 of file app.hpp.

704 {
705 HELIOS_ASSERT(!self.IsInitialized(), "Failed to add modules: Cannot add modules after app initialization!");
706 HELIOS_ASSERT(!self.IsRunning(), "Failed to add modules: Cannot add modules while app is running!");
707
708 (self.template AddModule<Modules>(), ...);
709 return std::forward<decltype(self)>(self);
710}

◆ AddModules() [2/2]

template<ModuleTrait... Modules>
requires (sizeof...(Modules) > 1 && utils::UniqueTypes<Modules...>)
auto helios::app::App::AddModules ( this auto &&  self,
Modules &&...  modules 
) -> decltype(std::forward<decltype(self)>(self))
inline

Adds multiple pre-constructed module instances to the main sub-app.

Allows adding modules with non-default constructors or pre-configured state.

Warning
Triggers an assertion if app is initialized or running.
Template Parameters
ModulesModule types
Parameters
modulesModule instances to add (will be moved)
Returns
Reference to app for method chaining

Definition at line 714 of file app.hpp.

714 {
715 HELIOS_ASSERT(!self.IsInitialized(), "Failed to add modules: Cannot add modules after app initialization!");
716 HELIOS_ASSERT(!self.IsRunning(), "Failed to add modules: Cannot add modules while app is running!");
717
718 (self.AddModule(std::forward<Modules>(modules)), ...);
719 return std::forward<decltype(self)>(self);
720}

◆ AddSubApp() [1/2]

template<SubAppTrait T>
auto helios::app::App::AddSubApp ( this auto &&  self,
SubApp  sub_app,
sub_app_tag = {} 
) -> decltype(std::forward<decltype(self)>(self))
inline

Adds an existing sub-application instance.

Warning
Triggers an assertion if app is initialized or running.
Template Parameters
TSub-application type
Parameters
sub_appSub-application instance to add
sub_app_tagSub-app type tag
Returns
Reference to app for method chaining

Definition at line 634 of file app.hpp.

635 {
636 HELIOS_ASSERT(!self.IsInitialized(), "Failed to add sub app '{}': Cannot add sub apps after app initialization!",
637 SubAppNameOf<T>());
638
639 HELIOS_ASSERT(!self.IsRunning(), "Failed to add sub app '{}': Cannot add sub apps while app is running!",
640 SubAppNameOf<T>());
641
642 constexpr SubAppTypeId id = SubAppTypeIdOf<T>();
643 if (self.sub_app_index_map_.contains(id)) [[unlikely]] {
644 HELIOS_WARN("Sub app '{}' is already exist in app!", SubAppNameOf<T>());
645 return std::forward<decltype(self)>(self);
646 }
647
648 // Set overlapping updates flag based on trait before adding
649 constexpr bool allow_overlapping = SubAppAllowsOverlappingUpdates<T>();
650 sub_app.SetAllowOverlappingUpdates(allow_overlapping);
651
652 // Set max overlapping updates based on trait
653 constexpr size_t max_overlapping = SubAppMaxOverlappingUpdates<T>();
654 sub_app.SetMaxOverlappingUpdates(max_overlapping);
655
656 self.sub_app_index_map_[id] = self.sub_apps_.size();
657 self.sub_apps_.push_back(std::move(sub_app));
658
659 return std::forward<decltype(self)>(self);
660}
size_t SubAppTypeId
Type alias for sub-app type IDs.
Definition sub_app.hpp:128

◆ AddSubApp() [2/2]

template<SubAppTrait T>
auto helios::app::App::AddSubApp ( this auto &&  self,
sub_app = {} 
) -> decltype(std::forward<decltype(self)>(self))
inline

Adds a new sub-application of type T.

Warning
Triggers an assertion if app is initialized or running.
Template Parameters
TSub-application type
Parameters
sub_appSub-app type tag
Returns
Reference to app for method chaining
Examples
/home/runner/work/HeliosEngine/HeliosEngine/src/core/include/helios/core/app/app.hpp.

Definition at line 606 of file app.hpp.

606 {
607 HELIOS_ASSERT(!self.IsInitialized(), "Failed to add sub app '{}': Cannot add sub apps after app initialization!",
608 SubAppNameOf<T>());
609
610 HELIOS_ASSERT(!self.IsRunning(), "Failed to add sub app '{}': Cannot add sub apps while app is running!",
611 SubAppNameOf<T>());
612
613 constexpr SubAppTypeId id = SubAppTypeIdOf<T>();
614 if (self.sub_app_index_map_.contains(id)) [[unlikely]] {
615 HELIOS_WARN("Sub app '{}' is already exist in app!", SubAppNameOf<T>());
616 return std::forward<decltype(self)>(self);
617 }
618
619 self.sub_app_index_map_[id] = self.sub_apps_.size();
620 self.sub_apps_.emplace_back();
621
622 // Set overlapping updates flag based on trait
623 constexpr bool allow_overlapping = SubAppAllowsOverlappingUpdates<T>();
624 self.sub_apps_.back().SetAllowOverlappingUpdates(allow_overlapping);
625
626 // Set max overlapping updates based on trait
627 constexpr size_t max_overlapping = SubAppMaxOverlappingUpdates<T>();
628 self.sub_apps_.back().SetMaxOverlappingUpdates(max_overlapping);
629
630 return std::forward<decltype(self)>(self);
631}

◆ AddSystem()

template<ecs::SystemTrait T, ScheduleTrait Schedule>
auto helios::app::App::AddSystem ( this auto &&  self,
Schedule  schedule = {} 
) -> decltype(std::forward<decltype(self)>(self))
inline

Adds a system to the specified schedule in the main sub-app.

Warning
Triggers an assertion if app is initialized or running.
Template Parameters
TSystem type
ScheduleSchedule type
Parameters
scheduleSchedule to add system to
Returns
Reference to app for method chaining
Examples
/home/runner/work/HeliosEngine/HeliosEngine/src/core/include/helios/core/app/app.hpp.

Definition at line 743 of file app.hpp.

743 {
744 HELIOS_ASSERT(!self.IsInitialized(), "Failed to add system '{}': Cannot add systems after app initialization!",
746
747 HELIOS_ASSERT(!self.IsRunning(), "Failed to add system '{}': Cannot add systems while app is running!",
749
750 if (self.template ContainsSystem<T>(schedule)) [[unlikely]] {
751 HELIOS_WARN("System '{}' is already exist in app schedule '{}'!", ecs::SystemNameOf<T>(),
752 ScheduleNameOf<Schedule>());
753 return std::forward<decltype(self)>(self);
754 }
755
756 self.GetMainSubApp().template AddSystem<T>(schedule);
757 return std::forward<decltype(self)>(self);
758}

◆ AddSystemBuilder()

template<ecs::SystemTrait T, ScheduleTrait Schedule>
auto helios::app::App::AddSystemBuilder ( this auto &&  self,
Schedule  schedule = {} 
) -> SystemConfig<Schedule, T>
inline

Adds a single system with fluent configuration builder.

Returns a builder that allows chaining configuration methods.

Warning
Triggers an assertion if app is initialized or running.
Template Parameters
TSystem type to add
ScheduleSchedule type
Parameters
scheduleSchedule to add system to
Returns
SystemConfig builder for fluent configuration
Examples
/home/runner/work/HeliosEngine/HeliosEngine/src/core/include/helios/core/app/app.hpp.

Definition at line 919 of file app.hpp.

919 {
920 HELIOS_ASSERT(!self.IsInitialized(), "Failed to add system '{}': Cannot add system after app initialization!",
922 HELIOS_ASSERT(!self.IsRunning(), "Failed to add system '{}': Cannot add system while app is running!",
924
925 return self.GetMainSubApp().template AddSystemBuilder<T>(schedule);
926}

◆ AddSystems()

template<ecs::SystemTrait... Systems, ScheduleTrait Schedule>
requires (sizeof...(Systems) > 1 && utils::UniqueTypes<Systems...>)
auto helios::app::App::AddSystems ( this auto &&  self,
Schedule  schedule = {} 
) -> decltype(std::forward<decltype(self)>(self))
inline

Adds multiple systems to the specified schedule in the main sub-app.

Warning
Triggers an assertion if app is initialized or running.
Template Parameters
SystemsSystem types
ScheduleSchedule type
Parameters
scheduleSchedule to add systems to
Returns
Reference to app for method chaining
Examples
/home/runner/work/HeliosEngine/HeliosEngine/src/core/include/helios/core/app/app.hpp.

Definition at line 762 of file app.hpp.

762 {
763 HELIOS_ASSERT(!self.IsInitialized(), "Failed to add systems: Cannot add systems after app initialization!");
764 HELIOS_ASSERT(!self.IsRunning(), "Failed to add systems: Cannot add systems while app is running!");
765
766 self.GetMainSubApp().template AddSystems<Systems...>(schedule);
767 return std::forward<decltype(self)>(self);
768}
auto AddSystems(this auto &&self, Schedule schedule={}) -> decltype(std::forward< decltype(self)>(self))
Adds multiple systems to the specified schedule in the main sub-app.
Definition app.hpp:762

◆ AddSystemsBuilder()

template<ecs::SystemTrait... Systems, ScheduleTrait Schedule>
requires (sizeof...(Systems) > 0 && utils::UniqueTypes<Systems...>)
auto helios::app::App::AddSystemsBuilder ( this auto &&  self,
Schedule  schedule = {} 
) -> SystemConfig<Schedule, Systems...>
inline
Examples
/home/runner/work/HeliosEngine/HeliosEngine/src/core/include/helios/core/app/app.hpp.

Definition at line 911 of file app.hpp.

911 {
912 HELIOS_ASSERT(!self.IsInitialized(), "Failed to add systems: Cannot add systems after app initialization!");
913 HELIOS_ASSERT(!self.IsRunning(), "Failed to add systems: Cannot add systems while app is running!");
914
915 return self.GetMainSubApp().template AddSystemsBuilder<Systems...>(schedule);
916}
auto AddSystemsBuilder(this auto &&self, Schedule schedule={}) -> SystemConfig< Schedule, Systems... >
Definition app.hpp:911

◆ Clear()

void helios::app::App::Clear ( )

Clears the application state, removing all data.

Warning
Triggers assertion if app is running.
Examples
/home/runner/work/HeliosEngine/HeliosEngine/src/core/include/helios/core/app/app.hpp.

Definition at line 37 of file app.cpp.

37 {
38 HELIOS_ASSERT(!IsRunning(), "Failed to clear app: Cannot clear app while it is running!");
39
40 WaitForOverlappingUpdates(); // Ensure all async work is done
41 sub_app_overlapping_futures_.clear();
42 main_sub_app_.Clear();
43 sub_apps_.clear();
44 sub_app_index_map_.clear();
45
46 is_initialized_ = false;
47}
bool IsRunning() const noexcept
Checks if the app is currently running.
Definition app.hpp:453
void Clear()
Clears the sub-app, removing all data.
Definition sub_app.hpp:512

◆ ConfigureSet()

template<SystemSetTrait Set, ScheduleTrait Schedule>
auto helios::app::App::ConfigureSet ( this auto &&  self,
Schedule  schedule = {} 
) -> SystemSetConfig<Schedule, Set>
inline
Examples
/home/runner/work/HeliosEngine/HeliosEngine/src/core/include/helios/core/app/app.hpp.

Definition at line 929 of file app.hpp.

929 {
930 HELIOS_ASSERT(!self.IsInitialized(), "Failed to configure set '{}': Cannot configure set after app initialization!",
931 SystemSetNameOf<Set>());
932 HELIOS_ASSERT(!self.IsRunning(), "Failed to configure set '{}': Cannot configure set while app is running!",
933 SystemSetNameOf<Set>());
934
935 return self.GetMainSubApp().template ConfigureSet<Set>(schedule);
936}

◆ ContainsDynamicModule()

bool helios::app::App::ContainsDynamicModule ( ModuleTypeId  module_id) const
inlinenoexcept

Checks if a dynamic module with the given ID exists.

Parameters
module_idModule type ID
Returns
True if module exists, false otherwise
Examples
/home/runner/work/HeliosEngine/HeliosEngine/src/core/include/helios/core/app/app.hpp.

Definition at line 867 of file app.hpp.

867 {
868 return dynamic_module_index_map_.contains(module_id);
869}

◆ ContainsModule()

template<ModuleTrait T>
bool helios::app::App::ContainsModule ( ) const
inlinenoexcept

Checks if a module of type T exists in main sub-app.

Template Parameters
TModule type
Returns
True if module exists, false otherwise
Examples
/home/runner/work/HeliosEngine/HeliosEngine/src/core/include/helios/core/app/app.hpp.

Definition at line 862 of file app.hpp.

862 {
863 constexpr ModuleTypeId id = ModuleTypeIdOf<T>();
864 return module_index_map_.contains(id) || dynamic_module_index_map_.contains(id);
865}

◆ ContainsSubApp()

template<SubAppTrait T>
bool helios::app::App::ContainsSubApp ( ) const
inlinenoexcept

Checks if a sub app of type T exists in main sub-app.

Template Parameters
TSubApp type
Returns
True if sub app exists, false otherwise
Examples
/home/runner/work/HeliosEngine/HeliosEngine/src/core/include/helios/core/app/app.hpp.

Definition at line 856 of file app.hpp.

856 {
857 constexpr SubAppTypeId id = SubAppTypeIdOf<T>();
858 return sub_app_index_map_.contains(id);
859}

◆ ContainsSystem() [1/2]

template<ecs::SystemTrait T>
bool helios::app::App::ContainsSystem ( ) const
inlinenoexcept

Checks if a system of type T exists in any schedule of main sub-app.

Template Parameters
TSystem type
Returns
True if system exists, false otherwise
Examples
/home/runner/work/HeliosEngine/HeliosEngine/src/core/include/helios/core/app/app.hpp.

Definition at line 427 of file app.hpp.

427 {
428 return main_sub_app_.ContainsSystem<T>();
429 }
bool ContainsSystem() const noexcept
Checks if a system of type T is in any schedule.
Definition sub_app.hpp:380

◆ ContainsSystem() [2/2]

template<ecs::SystemTrait T, ScheduleTrait Schedule>
bool helios::app::App::ContainsSystem ( Schedule  schedule = {}) const
inlinenoexcept

Checks if a system of type T exists in the specified schedule of main sub-app.

Template Parameters
TSystem type
ScheduleSchedule type
Parameters
scheduleSchedule to check
Returns
True if system exists, false otherwise

Definition at line 439 of file app.hpp.

439 {}) const noexcept {
440 return main_sub_app_.ContainsSystem<T>(schedule);
441 }

◆ EmplaceResource()

template<ecs::ResourceTrait T, typename... Args>
requires std::constructible_from<T, Args...>
auto helios::app::App::EmplaceResource ( this auto &&  self,
Args &&...  args 
) -> decltype(std::forward<decltype(self)>(self))
inline

Emplaces a resource into the main sub-app's world.

Warning
Triggers assertion if app is initialized or running.
Template Parameters
TResource type
ArgsConstructor argument types
Parameters
argsArguments to forward to resource constructor
Returns
Reference to app for method chaining
Examples
/home/runner/work/HeliosEngine/HeliosEngine/src/core/include/helios/core/app/app.hpp.

Definition at line 781 of file app.hpp.

781 {
782 HELIOS_ASSERT(!self.IsInitialized(),
783 "Failed to emplace resource '{}': Cannot add resources after app initialization!",
785
786 HELIOS_ASSERT(!self.IsRunning(), "Failed to emplace resource '{}': Cannot add resources while app is running!",
788
789 self.GetMainSubApp().template EmplaceResource<T>(std::forward<Args>(args)...);
790 return std::forward<decltype(self)>(self);
791}

◆ GetExecutor() [1/2]

const async::Executor & helios::app::App::GetExecutor ( ) const
inlinenoexcept

Gets the async executor (const version).

Returns
Const reference to the async executor

Definition at line 545 of file app.hpp.

545{ return executor_; }

◆ GetExecutor() [2/2]

async::Executor & helios::app::App::GetExecutor ( )
inlinenoexcept

Gets the async executor.

Returns
Reference to the async executor
Examples
/home/runner/work/HeliosEngine/HeliosEngine/src/core/include/helios/core/app/app.hpp.

Definition at line 539 of file app.hpp.

539{ return executor_; }

◆ GetMainSubApp() [1/2]

const SubApp & helios::app::App::GetMainSubApp ( ) const
inlinenoexcept

Gets the main sub-application (const version).

Returns
Const reference to the main sub-application

Definition at line 527 of file app.hpp.

527{ return main_sub_app_; }

◆ GetMainSubApp() [2/2]

SubApp & helios::app::App::GetMainSubApp ( )
inlinenoexcept

Gets the main sub-application.

Returns
Reference to the main sub-application
Examples
/home/runner/work/HeliosEngine/HeliosEngine/src/core/include/helios/core/app/app.hpp.

Definition at line 521 of file app.hpp.

521{ return main_sub_app_; }

◆ GetMainWorld()

const ecs::World & helios::app::App::GetMainWorld ( ) const
inlinenoexcept

Gets the main world.

Returns
Reference to the main world
Examples
/home/runner/work/HeliosEngine/HeliosEngine/src/core/include/helios/core/app/app.hpp.

Definition at line 533 of file app.hpp.

533{ return main_sub_app_.GetWorld(); }
const ecs::World & GetWorld() const noexcept
Gets const reference to this sub-app's world.
Definition sub_app.hpp:449

◆ GetSubApp() [1/2]

template<SubAppTrait T>
const SubApp & helios::app::App::GetSubApp ( ) const
inlinenoexcept

Gets a sub-application by type (const version).

Warning
Triggers an assertion if the sub-app does not exist.
Template Parameters
TSub-application type
Returns
Const reference to the sub-application

Definition at line 881 of file app.hpp.

881 {
882 constexpr SubAppTypeId id = SubAppTypeIdOf<T>();
883 const auto it = sub_app_index_map_.find(id);
884 HELIOS_ASSERT(it != sub_app_index_map_.end(), "Failed to get sub app '{}': Sub app does not exist!",
885 SubAppNameOf<T>());
886 return sub_apps_.at(it->second);
887}

◆ GetSubApp() [2/2]

template<SubAppTrait T>
SubApp & helios::app::App::GetSubApp ( )
inlinenoexcept

Gets a sub-application by type.

Warning
Triggers an assertion if the sub-app does not exist. Reference might be invalidated due to reallocation of storage after addition of new sub apps.
Template Parameters
TSub-application type
Returns
Reference to the sub-application
Examples
/home/runner/work/HeliosEngine/HeliosEngine/src/core/include/helios/core/app/app.hpp.

Definition at line 872 of file app.hpp.

872 {
873 constexpr SubAppTypeId id = SubAppTypeIdOf<T>();
874 const auto it = sub_app_index_map_.find(id);
875 HELIOS_ASSERT(it != sub_app_index_map_.end(), "Failed to get sub app '{}': Sub app does not exist!",
876 SubAppNameOf<T>());
877 return sub_apps_.at(it->second);
878}

◆ HasEvent()

template<ecs::EventTrait T>
bool helios::app::App::HasEvent ( ) const
inlinenoexcept

Checks if a event is registered in main sub_app.

Template Parameters
TEvent type
Returns
True if event exists, false otherwise
Examples
/home/runner/work/HeliosEngine/HeliosEngine/src/core/include/helios/core/app/app.hpp.

Definition at line 471 of file app.hpp.

471 {
472 return main_sub_app_.HasEvent<T>();
473 }
bool HasEvent() const noexcept
Checks if an event type is registered in this sub-app.
Definition sub_app.hpp:412

◆ HasResource()

template<ecs::ResourceTrait T>
bool helios::app::App::HasResource ( ) const
inlinenoexcept

Checks if a resource exists in main sub_app.

Template Parameters
TResource type
Returns
True if resource exists, false otherwise
Examples
/home/runner/work/HeliosEngine/HeliosEngine/src/core/include/helios/core/app/app.hpp.

Definition at line 461 of file app.hpp.

461 {
462 return main_sub_app_.HasResource<T>();
463 }
bool HasResource() const noexcept
Checks if a resource of type T exists in this sub-app.
Definition sub_app.hpp:402

◆ Initialize()

void helios::app::App::Initialize ( )

Initializes the application and its subsystems.

Called before the main loop starts. Spawns tasks on the executor for parallel initialization.

Note
Automaticly called in Run().
Warning
Triggers assertion if app is already initialized or running.
Examples
/home/runner/work/HeliosEngine/HeliosEngine/src/core/include/helios/core/app/app.hpp.

Definition at line 116 of file app.cpp.

116 {
117 HELIOS_ASSERT(!IsInitialized(), "Failed to initialize: App is already initialized!");
118 HELIOS_ASSERT(!IsRunning(), "Failed to initialize: Cannot initialize while app is running!");
119
120 async::TaskGraph initialization_graph;
121 initialization_graph.EmplaceTask([this]() {
122 main_sub_app_.BuildScheduler();
123 main_sub_app_.ExecuteStage<helios::app::StartUpStage>(executor_);
124 main_sub_app_.GetWorld().Update();
125 });
126
127 initialization_graph.ForEach(sub_apps_, [this](const SubApp& sub_app_ref) mutable {
128 // Need non-const access to modify sub_app
129 auto& sub_app = const_cast<SubApp&>(sub_app_ref);
130
131 sub_app.BuildScheduler();
132 sub_app.ExecuteStage<helios::app::StartUpStage>(executor_);
133 sub_app.GetWorld().Update();
134 });
135
136 auto future = executor_.Run(initialization_graph);
137
138 update_graph_.ForEach(sub_apps_, [this](const SubApp& sub_app_ref) mutable {
139 if (sub_app_ref.AllowsOverlappingUpdates()) {
140 return;
141 }
142
143 // Need non-const access to modify sub_app
144 auto& sub_app = const_cast<SubApp&>(sub_app_ref);
145 sub_app.Extract(main_sub_app_.GetWorld());
146 sub_app.Update(executor_);
147 });
148
149 future.Wait();
150
151 is_initialized_ = true;
152}
bool IsInitialized() const noexcept
Checks if the app has been initialized.
Definition app.hpp:447
void BuildScheduler()
Builds execution graphs for all schedules.
Definition sub_app.hpp:575
void ExecuteStage(async::Executor &executor)
Executes all schedules in a specific stage.
Definition sub_app.hpp:589
auto Run(TaskGraph &graph) -> Future< void >
Runs a task graph once.
Definition executor.hpp:57
Task ForEach(const R &range, C &&callable)
Creates a parallel for-each task over the given range.
void Update()
Flushes buffer of pending operations.
Definition world.hpp:627
StartUpStage - application initialization phase.
Definition schedules.hpp:26

◆ InsertResource()

template<ecs::ResourceTrait T>
auto helios::app::App::InsertResource ( this auto &&  self,
T &&  resource 
) -> decltype(std::forward<decltype(self)>(self))
inline

Inserts a resource into the main sub-app.

Warning
Triggers assertion if app is initialized or running.
Template Parameters
TResource type
Parameters
resourceResource to insert
Returns
Reference to app for method chaining
Examples
/home/runner/work/HeliosEngine/HeliosEngine/src/core/include/helios/core/app/app.hpp.

Definition at line 771 of file app.hpp.

771 {
772 HELIOS_ASSERT(!self.IsInitialized(), "Failed to insert resource '{}': Cannot add resources after app initialization!",
774
775 self.GetMainSubApp().InsertResource(std::forward<T>(resource));
776 return std::forward<decltype(self)>(self);
777}

◆ IsInitialized()

bool helios::app::App::IsInitialized ( ) const
inlinenoexcept

Checks if the app has been initialized.

Returns
True if initialized, false otherwise
Examples
/home/runner/work/HeliosEngine/HeliosEngine/src/core/include/helios/core/app/app.hpp.

Definition at line 447 of file app.hpp.

447{ return is_initialized_; }

◆ IsRunning()

bool helios::app::App::IsRunning ( ) const
inlinenoexcept

Checks if the app is currently running.

Returns
True if running, false otherwise
Examples
/home/runner/work/HeliosEngine/HeliosEngine/src/core/include/helios/core/app/app.hpp.

Definition at line 453 of file app.hpp.

453{ return is_running_.load(std::memory_order_acquire); }

◆ ModuleCount()

size_t helios::app::App::ModuleCount ( ) const
inlinenoexcept

Gets the number of modules in main sub-app.

Returns
Number of modules
Examples
/home/runner/work/HeliosEngine/HeliosEngine/src/core/include/helios/core/app/app.hpp.

Definition at line 479 of file app.hpp.

479{ return modules_.size() + dynamic_modules_.size(); }

◆ operator=() [1/2]

App & helios::app::App::operator= ( App &&  )
delete

◆ operator=() [2/2]

App & helios::app::App::operator= ( const App )
delete

◆ Run()

AppExitCode helios::app::App::Run ( )

Runs the application with the given arguments.

Warning
Triggers assertion if app is initialized or running.
Returns
Exit code of the application.
Examples
/home/runner/work/HeliosEngine/HeliosEngine/src/core/include/helios/core/app/app.hpp.

Definition at line 49 of file app.cpp.

49 {
50 HELIOS_ASSERT(!IsRunning(), "Failed to run: App is already running!");
51
52 HELIOS_INFO("Starting application...");
53
54 // Register built-in resources and events if not already registered
55 RegisterBuiltins();
56
57 BuildModules();
58 FinishModules();
59 Initialize();
60
61 // Run the application using the provided runner function
62 is_running_.store(true, std::memory_order_release);
63 const AppExitCode exit_code = runner_(*this);
64 is_running_.store(false, std::memory_order_release);
65
66 HELIOS_INFO("Cleaning up application...");
67 CleanUp();
68
69 executor_.WaitForAll();
70
71 DestroyModules();
72
73 // Reset state
74 is_initialized_ = false;
75 sub_app_overlapping_futures_.clear();
76 main_sub_app_.Clear();
77 sub_apps_.clear();
78 sub_app_index_map_.clear();
79
80 HELIOS_INFO("Application exiting with code: {}", std::to_underlying(exit_code));
81 return exit_code;
82}
void Initialize()
Initializes the application and its subsystems.
Definition app.cpp:116
#define HELIOS_INFO(...)
Definition logger.hpp:685
AppExitCode
Application exit codes.
Definition app.hpp:87

◆ SetRunner()

auto helios::app::App::SetRunner ( this auto &&  self,
RunnerFn  runner 
) -> decltype(std::forward<decltype(self)>(self))
inlinenoexcept

Sets runner function for the application.

Warning
Triggers assertion if app is initialized, running, or runner is null.
Parameters
runnerA move-only function that takes an App reference and returns an AppExitCode.
Returns
Reference to app for method chaining
Examples
/home/runner/work/HeliosEngine/HeliosEngine/src/core/include/helios/core/app/app.hpp.

Definition at line 820 of file app.hpp.

820 {
821 HELIOS_ASSERT(!self.IsInitialized(), "Failed to set runner: Cannot set runner after app initialization!");
822 HELIOS_ASSERT(!self.IsRunning(), "Failed to set runner: Cannot set runner while app is running!");
823
824 HELIOS_ASSERT(runner, "Failed to set runner: Runner function cannot be null!");
825
826 self.runner_ = std::move(runner);
827 return std::forward<decltype(self)>(self);
828}

◆ SetSubAppExtraction()

template<SubAppTrait T>
auto helios::app::App::SetSubAppExtraction ( this auto &&  self,
ExtractFn  extract_fn 
) -> decltype(std::forward<decltype(self)>(self))
inline

Sets extraction function for a sub-app.

The extraction function is called before the sub-app's Update to copy data from the main world.

Warning
Triggers assertion if app is initialized, running, extraction function is null, or sub-app doesn't exist.
Template Parameters
TSub-application type
Parameters
extract_fnFunction that takes main world and sub-app world references
Returns
Reference to app for method chaining
Examples
/home/runner/work/HeliosEngine/HeliosEngine/src/core/include/helios/core/app/app.hpp.

Definition at line 831 of file app.hpp.

832 {
834 !self.IsInitialized(),
835 "Failed to set extraction function for sub app '{}': Cannot set extraction function after app initialization!",
836 SubAppNameOf<T>());
837
839 !self.IsRunning(),
840 "Failed to set extraction function for sub app '{}': Cannot set extraction function while app is running!",
841 SubAppNameOf<T>());
842
843 HELIOS_ASSERT(extract_fn, "Failed to set extraction function for sub app '{}': Extraction function cannot be null!",
844 SubAppNameOf<T>());
845
846 constexpr SubAppTypeId id = SubAppTypeIdOf<T>();
847 const auto it = self.sub_app_index_map_.find(id);
848 HELIOS_ASSERT(it != self.sub_app_index_map_.end(),
849 "Failed to set extraction function for sub app '{}': Sub app does not exist!", SubAppNameOf<T>());
850
851 self.sub_apps_.at(it->second).SetExtractFunction(std::move(extract_fn));
852 return std::forward<decltype(self)>(self);
853}

◆ SystemCount() [1/2]

size_t helios::app::App::SystemCount ( ) const
inlinenoexcept

Gets the total number of systems across all schedules in main sub-app.

Returns
Total number of systems
Examples
/home/runner/work/HeliosEngine/HeliosEngine/src/core/include/helios/core/app/app.hpp.

Definition at line 485 of file app.hpp.

485{ return main_sub_app_.SystemCount(); }
size_t SystemCount() const noexcept
Gets the total number of systems across all schedules.
Definition sub_app.hpp:432

◆ SystemCount() [2/2]

template<ScheduleTrait Schedule>
size_t helios::app::App::SystemCount ( Schedule  schedule = {}) const
inlinenoexcept

Gets the number of systems in the specified schedule of main sub-app.

Template Parameters
ScheduleSchedule type
Parameters
scheduleSchedule to query
Returns
Number of systems in the schedule

Definition at line 494 of file app.hpp.

494 {}) const noexcept {
495 return main_sub_app_.SystemCount(schedule);
496 }

◆ TickTime()

void helios::app::App::TickTime ( )
noexcept

Updates the Time resource for the current frame.

Should be called at the beginning of each frame by the runner. Does nothing if Time resource is not registered.

Examples
/home/runner/work/HeliosEngine/HeliosEngine/src/core/include/helios/core/app/app.hpp.

Definition at line 206 of file app.cpp.

206 {
207 if (main_sub_app_.GetWorld().HasResource<Time>()) [[likely]] {
208 main_sub_app_.GetWorld().WriteResource<Time>().Tick();
209 }
210}
bool HasResource() const
Checks if a resource exists.
Definition world.hpp:534
T & WriteResource()
Gets reference to a resource.
Definition world.hpp:933

◆ Update()

void helios::app::App::Update ( )

Updates the application and its subsystems.

Calls Update on the main sub-app and all registered sub-apps. Spawns async tasks as needed.

Note
Should not be called directly - use the runner function instead.
Warning
Triggers assertion if app is not initialized.
Examples
/home/runner/work/HeliosEngine/HeliosEngine/src/core/include/helios/core/app/app.hpp.

Definition at line 84 of file app.cpp.

84 {
85 // Clean up completed per-sub-app overlapping futures using cached ready flags
86 for (auto& [index, futures] : sub_app_overlapping_futures_) {
87 std::erase_if(futures, [](details::TrackedFuture& tracked) { return tracked.IsReady(); });
88 }
89
90 // Update main sub-app (synchronous)
91 main_sub_app_.Update(executor_);
92
93 // Process non-overlapping sub-apps
94 auto non_overlapping_future = executor_.Run(update_graph_);
95
96 // Launch overlapping sub-apps asynchronously (non-blocking)
97 for (size_t i = 0; i < sub_apps_.size(); ++i) {
98 auto& sub_app = sub_apps_[i];
99 if (!sub_app.AllowsOverlappingUpdates()) {
100 continue;
101 }
102
103 // Capture by reference is safe: App lifetime exceeds sub-app updates
104 auto future = executor_.Async([this, &sub_app]() {
105 sub_app.Extract(main_sub_app_.GetWorld());
106 sub_app.Update(executor_);
107 });
108
109 // Store as TrackedFuture for optimized ready-state tracking
110 sub_app_overlapping_futures_[i].push_back(details::TrackedFuture{.future = future.share(), .ready = false});
111 }
112
113 non_overlapping_future.Wait();
114}
void Update(async::Executor &executor)
Updates this sub-app by executing all scheduled systems.
Definition sub_app.hpp:521
auto Async(C &&callable) -> std::future< std::invoke_result_t< C > >
Creates an asynchronous task that runs the given callable.
Definition executor.hpp:225

◆ WaitForOverlappingUpdates() [1/3]

void helios::app::App::WaitForOverlappingUpdates ( )

Waits for all overlapping sub-app updates to complete.

Can be called explicitly when synchronization is needed. Automatically called during CleanUp().

Examples
/home/runner/work/HeliosEngine/HeliosEngine/src/core/include/helios/core/app/app.hpp.

Definition at line 172 of file app.cpp.

172 {
173 for (auto& [index, futures] : sub_app_overlapping_futures_) {
174 for (auto& tracked : futures) {
175 tracked.Wait();
176 }
177 futures.clear();
178 }
179}

◆ WaitForOverlappingUpdates() [2/3]

void helios::app::App::WaitForOverlappingUpdates ( const SubApp sub_app)

Waits for overlapping updates of a specific sub-app instance to complete.

Can be called explicitly when synchronization is needed for a specific sub-app.

Parameters
sub_appReference to the sub-app to wait for

Definition at line 181 of file app.cpp.

181 {
182 // Find the sub-app index by comparing addresses
183 auto sub_app_index = static_cast<size_t>(-1);
184 for (size_t i = 0; i < sub_apps_.size(); ++i) {
185 if (&sub_apps_[i] == &sub_app) {
186 sub_app_index = i;
187 break;
188 }
189 }
190
191 if (sub_app_index == static_cast<size_t>(-1)) [[unlikely]] {
192 return; // Sub-app not found
193 }
194
195 const auto futures_it = sub_app_overlapping_futures_.find(sub_app_index);
196 if (futures_it == sub_app_overlapping_futures_.end()) {
197 return; // No overlapping futures for this sub-app
198 }
199
200 for (auto& tracked : futures_it->second) {
201 tracked.Wait();
202 }
203 futures_it->second.clear();
204}

◆ WaitForOverlappingUpdates() [3/3]

template<SubAppTrait T>
void helios::app::App::WaitForOverlappingUpdates ( sub_app = {})
inline

Waits for overlapping updates of a specific sub-app type to complete.

Can be called explicitly when synchronization is needed for a specific sub-app.

Template Parameters
TSub-app type
Parameters
sub_appSub-app type tag

Definition at line 890 of file app.hpp.

890 {
891 constexpr SubAppTypeId id = SubAppTypeIdOf<T>();
892 const auto it = sub_app_index_map_.find(id);
893 if (it == sub_app_index_map_.end()) [[unlikely]] {
894 return; // Sub-app doesn't exist
895 }
896
897 const size_t index = it->second;
898 const auto futures_it = sub_app_overlapping_futures_.find(index);
899 if (futures_it == sub_app_overlapping_futures_.end()) {
900 return; // No overlapping futures for this sub-app
901 }
902
903 for (auto& tracked : futures_it->second) {
904 tracked.Wait();
905 }
906 futures_it->second.clear();
907}