Pulp 1.88.0
Cross-platform audio plugin framework
Loading...
Searching...
No Matches
pulp::view::FrameClockBinding Class Reference

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

Detailed Description

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.

Member Typedef Documentation

◆ Tick

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.

Constructor & Destructor Documentation

◆ FrameClockBinding() [1/2]

pulp::view::FrameClockBinding::FrameClockBinding ( View & owner,
Tick tick,
void * context )

◆ ~FrameClockBinding()

pulp::view::FrameClockBinding::~FrameClockBinding ( )

◆ FrameClockBinding() [2/2]

pulp::view::FrameClockBinding::FrameClockBinding ( const FrameClockBinding & )
delete

Member Function Documentation

◆ operator=()

FrameClockBinding & pulp::view::FrameClockBinding::operator= ( const FrameClockBinding & )
delete

◆ owner()

View & pulp::view::FrameClockBinding::owner ( ) const
inline

◆ refresh()

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.

◆ set_wanted()

void pulp::view::FrameClockBinding::set_wanted ( bool wanted)
inline

Declare whether the owner currently has anything to read.

Does not subscribe on its own — pair it with refresh().

◆ stop()

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.

◆ subscribed()

bool pulp::view::FrameClockBinding::subscribed ( ) const
inline

◆ subscribed_clock()

FrameClock * pulp::view::FrameClockBinding::subscribed_clock ( ) const
inline

◆ wanted()

bool pulp::view::FrameClockBinding::wanted ( ) const
inline

◆ View

friend class View
friend

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