MayaFlux 1.0.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ register_element() [2/2]

template<typename T >
void MayaFlux::Portal::Forma::Bridge::register_element ( Layer &  layer,
Mapped< T >  mapped,
std::function< float(T)>  project = {} 
)
inline

Register a Mapped element and scope its presentation sync to a Layer.

Each frame's sync pushes the geometry function's bounds_hint and contains back into layer, so hit testing follows the drawn shape. The Layer scope also stops presentation sync when its Surface closes. unbind(ref) cancels the sync task as well.

layer must be owned by a shared_ptr, as Surface and Forma::create_layer do; otherwise the call logs an error and does nothing.

Parameters
layerLayer owning the element.
mappedFully constructed Mapped element.
projectOptional T to float projection for outbound readers.

Definition at line 485 of file Bridge.hpp.

488 {})
489 {
490 auto owner = layer.weak_from_this();
491 if (owner.expired()) {
493 "Bridge::register_element: element {} belongs to a Layer with no shared owner", mapped.element.id);
494 return;
495 }
496
497 register_element(ElementRef { std::move(owner), mapped.element.id },
498 mapped.state, mapped.element.buffer.buffer(), std::move(project));
499 spawn_sync(layer, mapped.element.id,
500 [m = std::move(mapped), target = &layer]() mutable { m.sync(target); });
501 }
#define MF_ERROR(comp, ctx,...)
void register_element(const ElementRef &ref, std::shared_ptr< MappedState< T > > state, std::shared_ptr< Buffers::FormaBuffer > buffer, std::function< float(T)> project={})
Register a MappedState<T> so that MappedState overloads and outbound bindings can resolve to the corr...
Definition Bridge.hpp:378
void spawn_sync(Layer &layer, uint32_t id, std::function< void()> sync_fn)
Spawn a presentation sync task scoped to a Layer.
Definition Bridge.cpp:450
@ Init
Engine/subsystem initialization.
@ Portal
High-level user-facing API layer.
std::pair< std::weak_ptr< Layer >, uint32_t > ElementRef
Layer-scoped element identity.
Definition Bridge.hpp:34