Subscription lifecycle for a view that pulls a value once per frame. More...
#include <value_source_binding.hpp>
Public Types | |
| using | Tick = bool (*)(void* context, float dt) |
| Per-frame callback. | |
Public Member Functions | |
| FrameClockBinding (View &owner, Tick tick, void *context) | |
| ~FrameClockBinding () | |
| FrameClockBinding (const FrameClockBinding &)=delete | |
| FrameClockBinding & | operator= (const FrameClockBinding &)=delete |
| void | set_wanted (bool wanted) |
| Declare whether the owner currently has anything to read. | |
| bool | wanted () const |
| void | refresh () |
| (Re)point the subscription at the owner's currently reachable clock, unsubscribing when wanted() is false. | |
| void | stop () |
| Unsubscribe from the cached clock, if subscribed. | |
| bool | subscribed () const |
| FrameClock * | subscribed_clock () const |
| View & | owner () const |
Friends | |
| class | View |
Subscription lifecycle for a view that pulls a value once per frame.
Owns one FrameClock render subscription on behalf of owner, keeps it pointed at whatever clock the owner can currently reach, and drops it when the owner detaches or the source goes away. A subscribed binding counts as a render subscriber, so a bound-and-attached view keeps an editor's frames alive (see FrameClock::has_active_subscribers) — which is why a binding that has nothing to read must not stay subscribed.
A binding enrols itself with its owner on construction and withdraws on destruction, and the owner re-points every enrolled binding from View::notify_frame_clock_changed() — a NON-virtual funnel that runs before the on_frame_clock_changed() hook. So a view holding extra bindings of its own (one per element, say) does not have to forward anything, and no subclass can strand a binding on a stale clock by overriding a hook without chaining to the base. wanted is the owner's "I have something to read" gate: set it, and the enrolment machinery does the rest.
| using pulp::view::FrameClockBinding::Tick = bool (*)(void* context, float dt) |
Per-frame callback.
dt is the clock delta in seconds. Returning false unsubscribes: the binding is torn down and will not be ticked again until something re-points it.
| pulp::view::FrameClockBinding::~FrameClockBinding | ( | ) |
|
delete |
|
delete |
|
inline |
| void pulp::view::FrameClockBinding::refresh | ( | ) |
(Re)point the subscription at the owner's currently reachable clock, unsubscribing when wanted() is false.
Idempotent. A no-op when no clock is reachable yet — a view built before hosting subscribes later, once a clock appears.
|
inline |
Declare whether the owner currently has anything to read.
Does not subscribe on its own — pair it with refresh().
| void pulp::view::FrameClockBinding::stop | ( | ) |
Unsubscribe from the cached clock, if subscribed.
Safe to call repeatedly, and safe during destruction: it uses the cached clock pointer rather than walking the (possibly torn-down) parent chain.
|
inline |
|
inline |
|
inline |
|
friend |