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, helios::engine::runtime::world::GameWorld &gameWorld)

Constructs a typed pass for a state mask. 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.

Definition at line 55 of file TypedPass.ixx.

Friends

helios::engine::runtime::gameloop::Phase

Public Constructors

TypedPass()

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

Constructs a typed pass for a state mask.

Parameters
owner

Reference to the parent Phase.

mask

State mask controlling when this pass runs.

gameWorld

GameWorld used by the base Pass for buffer injection.

Definition at line 107 of file TypedPass.ixx.

107 explicit TypedPass(Phase& owner, const StateType mask, helios::engine::runtime::world::GameWorld& gameWorld) : owner_(owner), mask_(mask), Pass(gameWorld) {}

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:

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 137 of file TypedPass.ixx.

138 commitPoint_ = commitPoint;
139 return owner_;
140 }

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

commitPoint()

template <typename StateType>
CommitPoint helios::engine::runtime::gameloop::TypedPass< StateType >::commitPoint ()
inline 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 154 of file TypedPass.ixx.

155 return commitPoint_;
156 }

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 182 of file TypedPass.ixx.

182 bool hasFlag(StateType mask, StateType value) const noexcept {
183 using U = std::underlying_type_t<StateType>;
184 return (static_cast<U>(mask) & static_cast<U>(value)) != 0;
185 }

Reference helios::engine::runtime::registerComponents.

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 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 169 of file TypedPass.ixx.

170 auto state = updateContext.session().state<StateType>();
171 return hasFlag(mask_, state);
172 }

References helios::engine::runtime::gameloop::TypedPass< StateType >::hasFlag and helios::engine::runtime::registerComponents.

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 86 of file TypedPass.ixx.

86 void init(helios::engine::runtime::world::GameWorld& gameWorld) override {
87
88 }

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 74 of file TypedPass.ixx.

75 for (auto& sys : systemRegistry_.items()) {
76 sys->update(updateContext);
77 }
78 }

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 94 of file TypedPass.ixx.

94 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 67 of file TypedPass.ixx.

67 StateType mask_;

owner_

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

Reference to the owning Phase.

Definition at line 62 of file TypedPass.ixx.

62 Phase& owner_;

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


Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.9.8.