Skip to main content

ecs Folder

Folders Index

foldercomponents
folderconcepts
folderstrategies
foldertypes

Files Index

filehelios/ecs/_module.ixx

Module aggregator for helios.ecs. More...

fileecs/ComponentOpsRegistry.ixx

Global registry mapping ComponentTypeId to ComponentOps. More...

fileecs/ComponentReflector.ixx

Compile-time reflection for component lifecycle hook registration. More...

fileEntity.ixx

High-level facade for entity manipulation in the ECS. More...

fileecs/EntityManager.ixx

Central manager for entity lifecycle and component storage. More...

fileecs/EntityRegistry.ixx

Generic, policy-based entity registry for managing entity lifecycles. More...

fileecs/EntityResolver.ixx

Lightweight callable for resolving EntityHandles to Entity wrappers. More...

fileecs/registry.ixx

Component registration for ecs module. More...

fileecs/SparseSet.ixx

Generic sparse set data structure for efficient entity-keyed storage. More...

fileTypedHandleWorld.ixx

Multi-domain entity world with compile-time handle-to-manager dispatch. More...

fileecs/View.ixx

Lightweight view for iterating entities with specific components. More...

Description

helios::ecs

Generic, reusable ECS primitives shared across the engine.

Overview

This module provides the complete set of building blocks for entity management, component storage, querying and lifecycle reflection. All types are policy-based templates that can be specialised for different domains (e.g. game entities, UI widgets, audio sources).

The classes were previously located in helios.ecs (which is now retained only for backward compatibility) and have been generalised through template parameters so they are independent of any specific engine subsystem.

Module Structure

The helios.ecs module exports the following types:

Entity Management

ClassTemplate ParametersPurpose
EntityHandle<TStrongId>TStrongId — domain-specific strong ID typeVersioned, strongly-typed entity reference
EntityRegistry<TStrongId, TLookupStrategy, TAllowRemoval, TCapacity>Strong ID type, lookup strategy, removal policy, capacityHandle allocation, version tracking, validation
EntityManager<THandle, TEntityRegistry, TCapacity>Handle type, registry type, capacityUnified entity creation and component storage
Entity<THandle, TEntityManager>Handle type, manager typeLightweight entity facade (~16 bytes, pass-by-value)
EntityResolver<TEntityManager>Manager typeCallable for resolving handles to Entity wrappers
TypedHandleWorld<TEntityManagers...>One or more EntityManager specialisationsMulti-domain world with compile-time handle dispatch

Component Infrastructure

ClassTemplate ParametersPurpose
ComponentTypeId<THandle>Handle type (scoping)Compile-time unique type identifier for components
ComponentOps(none)Type-erased function pointers for lifecycle callbacks
ComponentOpsRegistry<THandle>Handle type (scoping)Global O(1) registry mapping type IDs to ComponentOps
ComponentReflector<THandle, TEntityManager>Handle type, manager typeCompile-time trait-based lifecycle registration

Storage & Iteration

ClassTemplate ParametersPurpose
SparseSet<T>Element typeGeneric O(1) entity-keyed storage
SparseSetBase(none)Type-erased base for polymorphic sparse set access
View<TEntityManager, Components...>Manager type, component typesLightweight component-based entity queries

Lookup Strategies

StrategyLookupInsertionRemovalUse Case
HashedLookupStrategyO(1) avgO(1) avgO(1) avgDefault — large registries
LinearLookupStrategyO(n)O(n)O(1)Small registries

Traits (Compile-Time Concepts)

TraitRequired Method(s)Purpose
HasOnAcquireonAcquire()Pool acquisition callback
HasOnReleaseonRelease()Pool release callback
HasOnRemoveonRemove() → boolRemoval interception
HasToggleableenable(), disable()Component enable/disable
HasCloneonClone(const T&)Post-copy initialisation
HasActivatableonActivate(), onDeactivate()Entity activation response

Template Parameter Overview

The move from helios.engine.ecs to helios.ecs introduced the following new template parameters:

ParameterUsed InPurpose
TStrongIdEntityHandle, EntityRegistryDomain-specific strong ID type satisfying IsStrongIdLike
THandleEntityManager, Entity, ComponentTypeId, ComponentOpsRegistry, ComponentReflectorThe concrete EntityHandle<TStrongId> specialisation, scoping type IDs and ops per domain
TEntityRegistryEntityManagerThe concrete EntityRegistry specialisation used for handle allocation
TEntityManagerEntity, View, EntityResolver, ComponentReflectorThe concrete EntityManager specialisation providing component storage
TLookupStrategyEntityRegistryPluggable collision detection strategy for strong IDs
TAllowRemovalEntityRegistrybool policy — false disables destroy() at compile time
TCapacityEntityRegistry, EntityManagerDefault initial capacity hint

TypedHandleWorld

TypedHandleWorld<TEntityManagers...> is a multi-domain entity world that holds one EntityManager per domain inside a std::tuple. The handle type of each manager serves as a compile-time key: calling world.addEntity<MyHandle>() selects the correct manager automatically.

 using GameHandle = EntityHandle<GameStrongId>;
 using UiHandle = EntityHandle<UiStrongId>;
 
 using GameEM = EntityManager<GameHandle, GameRegistry, 4096>;
 using UiEM = EntityManager<UiHandle, UiRegistry, 512>;
 
 TypedHandleWorld<GameEM, UiEM> world;
 
 auto player = world.addEntity<GameHandle>(); // → GameEM
 auto button = world.addEntity<UiHandle>(); // → UiEM

Quick Start

 import helios.ecs;
 
 // 1 Define domain types
 struct MyStrongId { /* ... */ };
 
 // 2 Create manager and entity
 Manager em;
 auto handle = em.create();
 
 // 3 Attach components
 auto* transform = em.emplace<TransformComponent>(handle, position);
 
 // 4 Use the Entity facade
 entity.add<HealthComponent>(100.0f);
 
 // 5 Iterate via View
 for (auto [e, t, v] :
  // process
 }

See Also

  • Engine ECS — backward-compatible wrappers (GameObject, etc.)
  • Core TypesEntityId, VersionId, EntityTombstone, StrongId_t


Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.