Skip to main content

TypedPass Class Template

State-filtered pass that only executes in specific states. More...

Declaration

template <typename StateType> class helios::engine::runtime::gameloop::TypedPass<StateType> { ... }

Base class

classPass

Abstract base class for game loop passes. More...

Friends Index

template <typename StateType>
classhelios::engine::runtime::gameloop::Phase

Public Constructors Index

template <typename StateType>
TypedPass (Phase &owner, const StateType mask)

Constructs a Pass with a reference to its owning Phase. More...

Public Member Functions Index

template <typename StateType>
Phase &addCommitPoint (const CommitPoint commitPoint=CommitPoint::PassEvents) override

Marks this pass with a commit point and returns the owning Phase. More...

template <typename StateType>
CommitPointcommitPoint () const noexcept override

Returns the configured commit point for this pass. More...

template <typename StateType>
boolshouldRun (helios::engine::runtime::world::UpdateContext &updateContext) const noexcept override

Checks if this pass should execute based on current state. More...

template <typename StateType>
boolhasFlag (StateType mask, StateType value) const noexcept

Checks if a value has any bit set in the mask. More...

Private Member Functions Index

template <typename StateType>
voidupdate (helios::engine::runtime::world::UpdateContext &updateContext) override

Updates all systems registered in this pass. More...

template <typename StateType>
voidinit (helios::engine::runtime::world::GameWorld &gameWorld) override

Initializes all systems registered in this pass. More...

Private Member Attributes Index

template <typename StateType>
Phase &owner_

Reference to the owning Phase. More...

template <typename StateType>
StateTypemask_

Bitmask of states in which this pass should execute. More...

template <typename StateType>
CommitPointcommitPoint_ = CommitPoint::None

The CommitPoint configured for this Pass. More...

Description

State-filtered pass that only executes in specific states.

TypedPass extends the base Pass class with state-based filtering. The pass only executes when the current state (queried from Session) matches the configured state mask using bitwise AND.

## State Filtering

The state mask is a bitfield where each bit represents a state value. A pass runs if any bit in the mask matches the current state:

```cpp // Run only in Running state phase.addPass<GameState>(GameState::Running) .addSystem<MovementSystem>();

// Run in multiple states (bitwise OR) phase.addPass<GameState>(GameState::Running | GameState::Paused) .addSystem<InputSystem>(); ```

Template Parameters
StateType

The state enum type (e.g., GameState, MatchState).

See Also

Pass

See Also

Phase::addPass()

See Also

Session::state()

Definition at line 60 of file TypedPass.ixx.

Public Constructors

TypedPass()

template <typename StateType>
helios::engine::runtime::gameloop::TypedPass< StateType >::TypedPass (Phase & owner, const StateType mask)
inline explicit

Constructs a Pass with a reference to its owning Phase.

Parameters
owner

Reference to the parent Phase.

Definition at line 112 of file TypedPass.ixx.

112 explicit TypedPass(Phase& owner, const StateType mask) : owner_(owner), mask_(mask) {}

Reference helios::engine::runtime::gameloop::TypedPass< StateType >::helios::engine::runtime::gameloop::Phase.

Public Member Functions

addCommitPoint()

template <typename StateType>
Phase & helios::engine::runtime::gameloop::TypedPass< StateType >::addCommitPoint (const CommitPoint commitPoint=CommitPoint::PassEvents)
inline virtual

Marks this pass with a commit point and returns the owning Phase.

When a commit point is set, the specified synchronization actions are performed after this pass completes. The default is `CommitPoint::PassEvents` which only synchronizes pass-level events.

Available CommitPoint flags:

  • `PassEvents` - Events pushed via `UpdateContext::pushPass()` become readable.
  • `FlushCommands` - Pending commands from the CommandBuffer are executed.
  • `FlushManagers` - Managers process their queued requests.
  • `Structural` - Combines all three flags.

Flags can be combined using bitwise OR: ```cpp pass.addCommitPoint(CommitPoint::PassEvents | CommitPoint::FlushCommands); ```

Parameters
commitPoint

The flags specifying which actions to perform (default: PassEvents).

Returns

Reference to the owning Phase for continued configuration.

See Also

CommitPoint

See Also

UpdateContext::pushPass()

See Also

UpdateContext::readPass()

See Also

GameLoop::passCommit()

Definition at line 142 of file TypedPass.ixx.

143 commitPoint_ = commitPoint;
144 return owner_;
145 }

References helios::engine::runtime::gameloop::TypedPass< StateType >::commitPoint, helios::engine::runtime::gameloop::TypedPass< StateType >::helios::engine::runtime::gameloop::Phase and helios::engine::runtime::gameloop::PassEvents.

commitPoint()

template <typename StateType>
CommitPoint helios::engine::runtime::gameloop::TypedPass< StateType >::commitPoint ()
inline nodiscard noexcept virtual

Returns the configured commit point for this pass.

The commit point determines what synchronization actions are performed after this pass completes. If no commit point was added, returns CommitPoint::None.

Returns

The commit point flags for this pass.

See Also

CommitPoint

See Also

addCommitPoint()

Definition at line 159 of file TypedPass.ixx.

159 [[nodiscard]] CommitPoint commitPoint() const noexcept override {
160 return commitPoint_;
161 }

Referenced by helios::engine::runtime::gameloop::TypedPass< StateType >::addCommitPoint.

hasFlag()

template <typename StateType>
bool helios::engine::runtime::gameloop::TypedPass< StateType >::hasFlag (StateType mask, StateType value)
inline noexcept

Checks if a value has any bit set in the mask.

Parameters
mask

The bitmask to check against.

value

The value to test.

Returns

True if any bit in mask matches value.

Definition at line 187 of file TypedPass.ixx.

187 bool hasFlag(StateType mask, StateType value) const noexcept {
188 using U = std::underlying_type_t<StateType>;
189 return (static_cast<U>(mask) & static_cast<U>(value)) != 0;
190 }

Referenced by helios::engine::runtime::gameloop::TypedPass< StateType >::shouldRun.

shouldRun()

template <typename StateType>
bool helios::engine::runtime::gameloop::TypedPass< StateType >::shouldRun (helios::engine::runtime::world::UpdateContext & updateContext)
inline nodiscard noexcept virtual

Checks if this pass should execute based on current state.

Queries the current state from the Session and compares it against the configured mask using bitwise AND. The pass runs if any bit in the mask matches the current state.

Parameters
updateContext

The current update context.

Returns

True if the pass should execute.

Definition at line 174 of file TypedPass.ixx.

174 [[nodiscard]] bool shouldRun(helios::engine::runtime::world::UpdateContext& updateContext) const noexcept override {
175 auto state = updateContext.session().state<StateType>();
176 return hasFlag(mask_, state);
177 }

References helios::engine::runtime::gameloop::TypedPass< StateType >::hasFlag, helios::engine::runtime::world::UpdateContext::session and helios::engine::runtime::world::Session::state.

Private Member Functions

init()

template <typename StateType>
void helios::engine::runtime::gameloop::TypedPass< StateType >::init (helios::engine::runtime::world::GameWorld & gameWorld)
inline virtual

Initializes all systems registered in this pass.

Parameters
gameWorld

Reference to the game world.

Definition at line 91 of file TypedPass.ixx.

91 void init(helios::engine::runtime::world::GameWorld& gameWorld) override {
92 for (auto& sys : systemRegistry_.items()) {
93 sys->init(gameWorld);
94 }
95 }

update()

template <typename StateType>
void helios::engine::runtime::gameloop::TypedPass< StateType >::update (helios::engine::runtime::world::UpdateContext & updateContext)
inline virtual

Updates all systems registered in this pass.

Parameters
updateContext

The current update context.

Definition at line 79 of file TypedPass.ixx.

79 void update(helios::engine::runtime::world::UpdateContext& updateContext) override {
80 for (auto& sys : systemRegistry_.items()) {
81 sys->update(updateContext);
82 }
83 }

Private Member Attributes

commitPoint_

template <typename StateType>
CommitPoint helios::engine::runtime::gameloop::TypedPass< StateType >::commitPoint_ = CommitPoint::None

The CommitPoint configured for this Pass.

Definition at line 101 of file TypedPass.ixx.

101 CommitPoint commitPoint_ = CommitPoint::None;

mask_

template <typename StateType>
StateType helios::engine::runtime::gameloop::TypedPass< StateType >::mask_

Bitmask of states in which this pass should execute.

Definition at line 72 of file TypedPass.ixx.

72 StateType mask_;

owner_

template <typename StateType>
Phase& helios::engine::runtime::gameloop::TypedPass< StateType >::owner_

Reference to the owning Phase.

Definition at line 67 of file TypedPass.ixx.

67 Phase& owner_;

The documentation for this class was generated from the following file:


Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.