Helios Engine 0.1.0
A modular ECS based data-oriented C++23 game engine
 
Loading...
Searching...
No Matches
helios::app::SystemConfig< Schedule, Systems > Class Template Reference

#include <system_config.hpp>

Public Member Functions

 SystemConfig (SubApp &sub_app, Schedule schedule={}) noexcept
 Constructs a system configuration builder.
 
 SystemConfig (const SystemConfig &)=delete
 
 SystemConfig (SystemConfig &&) noexcept=default
 
 ~SystemConfig ()
 Destructor - automatically applies configuration if not already applied.
 
SystemConfigoperator= (const SystemConfig &)=delete
 
SystemConfigoperator= (SystemConfig &&) noexcept=default
 
template<ecs::SystemTrait... AfterSystems>
requires (sizeof...(AfterSystems) > 0 && utils::UniqueTypes<AfterSystems...>)
SystemConfigAfter ()
 Adds ordering constraint: these systems run after specified systems.
 
template<ecs::SystemTrait... BeforeSystems>
requires (sizeof...(BeforeSystems) > 0 && utils::UniqueTypes<BeforeSystems...>)
SystemConfigBefore ()
 Adds ordering constraint: these systems run before specified systems.
 
template<SystemSetTrait... Sets>
requires (sizeof...(Sets) > 0 && utils::UniqueTypes<Sets...>)
SystemConfigInSet ()
 Adds these systems to specified system sets.
 
template<SystemSetTrait... AfterSets>
requires (sizeof...(AfterSets) > 0 && utils::UniqueTypes<AfterSets...>)
SystemConfigAfterSet ()
 Adds ordering constraint: these systems run after specified system sets.
 
template<SystemSetTrait... BeforeSets>
requires (sizeof...(BeforeSets) > 0 && utils::UniqueTypes<BeforeSets...>)
SystemConfigBeforeSet ()
 Adds ordering constraint: these systems run before specified system sets.
 
SystemConfigSequence () noexcept
 Creates an ordered sequence of systems.
 
void Apply ()
 Explicitly applies the configuration and adds systems to the sub-app.
 
template<ecs::SystemTrait... AfterSystems>
requires (sizeof...(AfterSystems) > 0 && utils::UniqueTypes<AfterSystems...>)
auto After () -> SystemConfig &
 
template<ecs::SystemTrait... BeforeSystems>
requires (sizeof...(BeforeSystems) > 0 && utils::UniqueTypes<BeforeSystems...>)
auto Before () -> SystemConfig &
 
template<SystemSetTrait... Sets>
requires (sizeof...(Sets) > 0 && utils::UniqueTypes<Sets...>)
auto InSet () -> SystemConfig &
 
template<SystemSetTrait... AfterSets>
requires (sizeof...(AfterSets) > 0 && utils::UniqueTypes<AfterSets...>)
auto AfterSet () -> SystemConfig &
 
template<SystemSetTrait... BeforeSets>
requires (sizeof...(BeforeSets) > 0 && utils::UniqueTypes<BeforeSets...>)
auto BeforeSet () -> SystemConfig &
 

Detailed Description

template<ScheduleTrait Schedule, ecs::SystemTrait... Systems>
requires (sizeof...(Systems) > 0 && utils::UniqueTypes<Systems...>)
class helios::app::SystemConfig< Schedule, Systems >

Definition at line 44 of file system_config.hpp.

Constructor & Destructor Documentation

◆ SystemConfig() [1/3]

template<ScheduleTrait Schedule, ecs::SystemTrait... Systems>
helios::app::SystemConfig< Schedule, Systems >::SystemConfig ( SubApp sub_app,
Schedule  schedule = {} 
)
inlineexplicitnoexcept

Constructs a system configuration builder.

Parameters
sub_appReference to the sub-app where systems will be added
scheduleSchedule instance where systems are added

Definition at line 51 of file system_config.hpp.

51{}) noexcept : sub_app_(sub_app), schedule_(schedule) {}

◆ SystemConfig() [2/3]

template<ScheduleTrait Schedule, ecs::SystemTrait... Systems>
helios::app::SystemConfig< Schedule, Systems >::SystemConfig ( const SystemConfig< Schedule, Systems > &  )
delete

◆ SystemConfig() [3/3]

template<ScheduleTrait Schedule, ecs::SystemTrait... Systems>
helios::app::SystemConfig< Schedule, Systems >::SystemConfig ( SystemConfig< Schedule, Systems > &&  )
defaultnoexcept

◆ ~SystemConfig()

template<ScheduleTrait Schedule, ecs::SystemTrait... Systems>
requires (sizeof...(Systems) > 0 && utils::UniqueTypes<Systems...>)
helios::app::SystemConfig< Schedule, Systems >::~SystemConfig ( )
inline

Destructor - automatically applies configuration if not already applied.

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

Definition at line 148 of file system_config.hpp.

148 {
149 if (!applied_) {
150 Apply();
151 }
152}
void Apply()
Explicitly applies the configuration and adds systems to the sub-app.

Member Function Documentation

◆ After() [1/2]

template<ScheduleTrait Schedule, ecs::SystemTrait... Systems>
template<ecs::SystemTrait... AfterSystems>
requires (sizeof...(AfterSystems) > 0 && utils::UniqueTypes<AfterSystems...>)
SystemConfig & helios::app::SystemConfig< Schedule, Systems >::After ( )

Adds ordering constraint: these systems run after specified systems.

Creates a dependency edge from each specified system to each system in this config.

Template Parameters
AfterSystemsSystem types that must run before these systems
Returns
Reference to this config for method chaining
Examples
/home/runner/work/HeliosEngine/HeliosEngine/src/core/include/helios/core/app/system_config.hpp.

◆ After() [2/2]

template<ScheduleTrait Schedule, ecs::SystemTrait... Systems>
template<ecs::SystemTrait... AfterSystems>
requires (sizeof...(AfterSystems) > 0 && utils::UniqueTypes<AfterSystems...>)
auto helios::app::SystemConfig< Schedule, Systems >::After ( ) -> SystemConfig&
inline

Definition at line 158 of file system_config.hpp.

158 {
159 (after_systems_.push_back(ecs::SystemTypeIdOf<AfterSystems>()), ...);
160 return *this;
161}
BasicQuery< World, Allocator, Components... > Query
Type alias for query with mutable world access.
Definition query.hpp:2481

◆ AfterSet() [1/2]

template<ScheduleTrait Schedule, ecs::SystemTrait... Systems>
template<SystemSetTrait... AfterSets>
requires (sizeof...(AfterSets) > 0 && utils::UniqueTypes<AfterSets...>)
SystemConfig & helios::app::SystemConfig< Schedule, Systems >::AfterSet ( )

Adds ordering constraint: these systems run after specified system sets.

Creates a dependency edge from each specified set to all systems in this config. All systems that belong to the specified sets will run before these systems.

Template Parameters
AfterSetsSystem set types that must run before these systems
Returns
Reference to this config for method chaining
Examples
/home/runner/work/HeliosEngine/HeliosEngine/src/core/include/helios/core/app/system_config.hpp.

◆ AfterSet() [2/2]

template<ScheduleTrait Schedule, ecs::SystemTrait... Systems>
template<SystemSetTrait... AfterSets>
requires (sizeof...(AfterSets) > 0 && utils::UniqueTypes<AfterSets...>)
auto helios::app::SystemConfig< Schedule, Systems >::AfterSet ( ) -> SystemConfig&
inline

Definition at line 185 of file system_config.hpp.

185 {
186 (after_sets_.push_back(SystemSetIdOf<AfterSets>()), ...);
187 return *this;
188}

◆ Apply()

template<ScheduleTrait Schedule, ecs::SystemTrait... Systems>
requires (sizeof...(Systems) > 0 && utils::UniqueTypes<Systems...>)
void helios::app::SystemConfig< Schedule, Systems >::Apply ( )
inline

Explicitly applies the configuration and adds systems to the sub-app.

Called automatically by destructor if not already applied. Can be called explicitly to control when configuration is finalized.

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

Definition at line 210 of file system_config.hpp.

210 {
211 if (applied_) [[unlikely]] {
212 return;
213 }
214
215 applied_ = true;
216
217 auto& sub_app = sub_app_.get();
218 auto& scheduler = sub_app.GetScheduler();
219
220 // Add systems to the schedule first so that scheduler storage is populated.
221 (sub_app.template AddSystem<Systems>(schedule_), ...);
222
223 // Helper to register explicit system-to-system ordering with scheduler.
224 const auto register_ordering_for = [&scheduler, this]<typename T>(std::span<const ecs::SystemTypeId> before_ids,
225 std::span<const ecs::SystemTypeId> after_ids) {
226 if (!before_ids.empty() || !after_ids.empty()) {
227 details::SystemOrdering ordering{};
228 ordering.before.assign(before_ids.begin(), before_ids.end());
229 ordering.after.assign(after_ids.begin(), after_ids.end());
230 scheduler.template RegisterOrdering<T>(schedule_, std::move(ordering));
231 }
232 };
233
234 // Helper to append metadata to SystemInfo via Scheduler helper APIs and register set membership.
235 const auto append_metadata_for = [&scheduler, this]<typename T>() {
236 if (!before_systems_.empty() || !after_systems_.empty()) {
237 scheduler.template AppendSystemOrderingMetadata<T>(schedule_, std::span<const ecs::SystemTypeId>(before_systems_),
238 std::span<const ecs::SystemTypeId>(after_systems_));
239 }
240 if (!system_sets_.empty()) {
241 // Record membership in each configured set
242 constexpr ecs::SystemTypeId system_id = ecs::SystemTypeIdOf<T>();
243 for (const auto set_id : system_sets_) {
244 scheduler.AddSystemToSet(set_id, system_id);
245 }
246
247 scheduler.template AppendSystemSetMetadata<T>(schedule_, std::span<const SystemSetId>(system_sets_));
248 }
249 };
250
251 if (sequence_ && sizeof...(Systems) > 1) {
252 // Sequence: each system runs after the previous one in template parameter order.
253 constexpr std::array system_ids = {ecs::SystemTypeIdOf<Systems>()...};
254
255 size_t idx = 0;
256
257 (
258 [&]<typename T>() {
259 std::vector<ecs::SystemTypeId> before_ids(before_systems_.begin(), before_systems_.end());
260 std::vector<ecs::SystemTypeId> after_ids(after_systems_.begin(), after_systems_.end());
261
262 if (idx > 0) {
263 // Current system must run after the previous system in the sequence.
264 after_ids.push_back(system_ids[idx - 1]);
265 }
266
267 register_ordering_for.template operator()<T>(before_ids, after_ids);
268 append_metadata_for.template operator()<T>();
269
270 ++idx;
271 }.template operator()<Systems>(),
272 ...);
273 } else {
274 // No sequence: each system just gets the accumulated before/after system constraints.
275 (
276 [&]<typename T>() {
277 register_ordering_for.template operator()<T>(std::span<const ecs::SystemTypeId>(before_systems_),
278 std::span<const ecs::SystemTypeId>(after_systems_));
279 append_metadata_for.template operator()<T>();
280 }.template operator()<Systems>(),
281 ...);
282 }
283
284 // NOTE:
285 // - before_sets_ / after_sets_ are collected by the builder API,
286 // but the current scheduler implementation does not yet track SystemSetInfo
287 // or set-level ordering constraints. Once such infrastructure exists,
288 // these vectors can be propagated similarly to the system-level constraints.
289}
size_t SystemTypeId
Type ID for systems.
Definition system.hpp:93

◆ Before() [1/2]

template<ScheduleTrait Schedule, ecs::SystemTrait... Systems>
template<ecs::SystemTrait... BeforeSystems>
requires (sizeof...(BeforeSystems) > 0 && utils::UniqueTypes<BeforeSystems...>)
SystemConfig & helios::app::SystemConfig< Schedule, Systems >::Before ( )

Adds ordering constraint: these systems run before specified systems.

Creates a dependency edge from each system in this config to each specified system.

Template Parameters
BeforeSystemsSystem types that must run after these systems
Returns
Reference to this config for method chaining
Examples
/home/runner/work/HeliosEngine/HeliosEngine/src/core/include/helios/core/app/system_config.hpp.

◆ Before() [2/2]

template<ScheduleTrait Schedule, ecs::SystemTrait... Systems>
template<ecs::SystemTrait... BeforeSystems>
requires (sizeof...(BeforeSystems) > 0 && utils::UniqueTypes<BeforeSystems...>)
auto helios::app::SystemConfig< Schedule, Systems >::Before ( ) -> SystemConfig&
inline

Definition at line 167 of file system_config.hpp.

167 {
168 (before_systems_.push_back(ecs::SystemTypeIdOf<BeforeSystems>()), ...);
169 return *this;
170}

◆ BeforeSet() [1/2]

template<ScheduleTrait Schedule, ecs::SystemTrait... Systems>
template<SystemSetTrait... BeforeSets>
requires (sizeof...(BeforeSets) > 0 && utils::UniqueTypes<BeforeSets...>)
SystemConfig & helios::app::SystemConfig< Schedule, Systems >::BeforeSet ( )

Adds ordering constraint: these systems run before specified system sets.

Creates a dependency edge from all systems in this config to each specified set. All systems in this config will run before systems that belong to the specified sets.

Template Parameters
BeforeSetsSystem set types that must run after these systems
Returns
Reference to this config for method chaining
Examples
/home/runner/work/HeliosEngine/HeliosEngine/src/core/include/helios/core/app/system_config.hpp.

◆ BeforeSet() [2/2]

template<ScheduleTrait Schedule, ecs::SystemTrait... Systems>
template<SystemSetTrait... BeforeSets>
requires (sizeof...(BeforeSets) > 0 && utils::UniqueTypes<BeforeSets...>)
auto helios::app::SystemConfig< Schedule, Systems >::BeforeSet ( ) -> SystemConfig&
inline

Definition at line 194 of file system_config.hpp.

194 {
195 (before_sets_.push_back(SystemSetIdOf<BeforeSets>()), ...);
196 return *this;
197}

◆ InSet() [1/2]

template<ScheduleTrait Schedule, ecs::SystemTrait... Systems>
template<SystemSetTrait... Sets>
requires (sizeof...(Sets) > 0 && utils::UniqueTypes<Sets...>)
SystemConfig & helios::app::SystemConfig< Schedule, Systems >::InSet ( )

Adds these systems to specified system sets.

Systems inherit ordering constraints and run conditions from their sets. Systems can belong to multiple sets.

Template Parameters
SetsSystem set types
Returns
Reference to this config for method chaining
Examples
/home/runner/work/HeliosEngine/HeliosEngine/src/core/include/helios/core/app/system_config.hpp.

◆ InSet() [2/2]

template<ScheduleTrait Schedule, ecs::SystemTrait... Systems>
template<SystemSetTrait... Sets>
requires (sizeof...(Sets) > 0 && utils::UniqueTypes<Sets...>)
auto helios::app::SystemConfig< Schedule, Systems >::InSet ( ) -> SystemConfig&
inline

Definition at line 176 of file system_config.hpp.

176 {
177 (system_sets_.push_back(SystemSetIdOf<Sets>()), ...);
178 return *this;
179}

◆ operator=() [1/2]

template<ScheduleTrait Schedule, ecs::SystemTrait... Systems>
SystemConfig & helios::app::SystemConfig< Schedule, Systems >::operator= ( const SystemConfig< Schedule, Systems > &  )
delete

◆ operator=() [2/2]

template<ScheduleTrait Schedule, ecs::SystemTrait... Systems>
SystemConfig & helios::app::SystemConfig< Schedule, Systems >::operator= ( SystemConfig< Schedule, Systems > &&  )
defaultnoexcept

◆ Sequence()

template<ScheduleTrait Schedule, ecs::SystemTrait... Systems>
requires (sizeof...(Systems) > 1)
auto helios::app::SystemConfig< Schedule, Systems >::Sequence ( )
inlinenoexcept

Creates an ordered sequence of systems.

Each system runs after the previous one in the template parameter order. Equivalent to manually adding After constraints: System2.After<System1>(), System3.After<System2>(), etc.

Warning
Only valid when configuring multiple systems (sizeof...(Systems) > 1).
Returns
Reference to this config for method chaining
Examples
/home/runner/work/HeliosEngine/HeliosEngine/src/core/include/helios/core/app/system_config.hpp.

Definition at line 201 of file system_config.hpp.

203{
204 sequence_ = true;
205 return *this;
206}