Base class for per-frame dispatchers in the Malena event system. More...
#include <FrameDispatcher.h>
Public Member Functions | |
| FrameDispatcher () | |
| void | fire () override=0 |
| Deliver the per-frame callback to all matching components. | |
| bool | occurred () override=0 |
Return true when this dispatcher should fire this frame. | |
Base class for per-frame dispatchers in the Malena event system.
FrameDispatcher is the frame-tick counterpart to EventDispatcher. Where EventDispatcher responds to SFML input events (mouse clicks, key presses, etc.), FrameDispatcher fires unconditionally once per frame — before drawing — making it the correct base for traits like Updatable that need to run every tick regardless of user input.
The constructor automatically passes DispatchType::FRAME to Fireable, so the framework routes this dispatcher through the per-frame loop rather than the per-event loop. No manual setup is needed.
The SFML-event–taking overloads inherited from Fireable are sealed final so you only need to implement the two no-argument versions.
The same three-piece pattern as EventDispatcher applies:
EventReceiver and exposes a friendly callback registration method that stores a callback via Fireable::addCallback.FrameDispatcher and implements occurred() and fire(). Registered as a singleton via ML_EXPORT.ML_EXPORT(MyDispatcher) — placed after the class definition.| Method | Purpose |
|---|---|
occurred() | Return true when this dispatcher should fire this frame. Return false to skip the pass entirely. Typically always returns true for unconditional per-frame traits. |
fire() | Iterate registered components and deliver the per-frame callback. |
Definition at line 86 of file FrameDispatcher.h.
|
inline |
Definition at line 88 of file FrameDispatcher.h.
|
overridepure virtual |
Deliver the per-frame callback to all matching components.
Called by the framework each frame after occurred() returns true. Typically iterates the component list and calls process() on each relevant component.
|
overridepure virtual |
Return true when this dispatcher should fire this frame.
Called once per frame by the framework. Return false to skip the entire delivery pass for this frame. Most per-frame traits simply return true unconditionally.
true if fire() should be called this frame.