MayaFlux 1.0.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches
MayaFlux::Nexus::Wiring Class Reference

Fluent builder that wires an entity into Fabric's scheduling infrastructure. More...

#include <Wiring.hpp>

+ Collaboration diagram for MayaFlux::Nexus::Wiring:

Classes

struct  EventTrigger
 
struct  KeyTrigger
 
struct  MouseTrigger
 
struct  MoveStep
 
struct  NetworkTrigger
 
struct  ScrollTrigger
 
struct  WindowEventTrigger
 

Public Types

using CrossFactory = std::function< Vruta::CrossRoutine()>
 
using EventFactory = std::function< Vruta::Event(Vruta::TaskScheduler &)>
 
using GraphicsFactory = std::function< Vruta::GraphicsRoutine()>
 
using NullFunc = std::nullptr_t
 
using PositionFn = std::function< glm::vec3()>
 
using SoundFactory = std::function< Vruta::SoundRoutine()>
 

Public Member Functions

Wiring & bind ()
 Call the entity's influence function once immediately.
 
Wiring & bind (std::function< void()> attach, std::function< void()> detach)
 Call attach immediately; call detach after for_duration expires or on explicit cancel().
 
Wiring & bind (std::function< void()> fn)
 Call a custom function once immediately instead of the entity's own.
 
Wiring & bind (std::string attach_name, std::function< void()> attach, std::string detach_name, std::function< void()> detach)
 Call named attach/detach functions.
 
Wiring & bind (std::string fn_name, std::function< void()> fn)
 Call a named custom function once immediately.
 
const std::string & bind_attach_name () const
 Name of the bind attach function, empty if anonymous or none.
 
const std::string & bind_detach_name () const
 Name of the bind detach function, empty if anonymous or none.
 
void cancel ()
 Cancel an active wiring and release any owned coroutine.
 
std::optional< double > duration () const
 Active duration in seconds, if for_duration was called.
 
uint32_t entity_id () const
 Stable id of the wired entity.
 
const EFactory & event_factory () const
 Active event-factory, if use(EventFactory) was called.
 
Wiring & every (double interval_seconds, Vruta::ProcessingToken token=Vruta::ProcessingToken::SAMPLE_ACCURATE)
 Fire the entity on a recurring interval.
 
const Factory & factory () const
 Active factory variant set by use for non-Event factories.
 
const std::string & factory_name () const
 Name of the active factory, empty if anonymous or none.
 
void finalise ()
 Apply the configured wiring.
 
Wiring & for_duration (double seconds, Vruta::ProcessingToken token=Vruta::ProcessingToken::SAMPLE_ACCURATE)
 Limit a recurring registration to a fixed duration then cancel.
 
bool has_bind () const
 True if any bind overload was called.
 
bool has_bind_detach () const
 True if bind(attach, detach) was called.
 
bool has_position_fn () const
 True if position_from was called.
 
std::optional< double > interval () const
 Recurring interval in seconds, if every was called.
 
bool is_scroll () const
 True if on_scroll was called.
 
const std::vector< MoveStep > & move_steps () const
 Choreography steps from move_to calls.
 
Wiring & move_to (const glm::vec3 &pos, double delay_seconds=0.0)
 Choreograph a position move as an EventChain step.
 
Wiring & on (std::shared_ptr< Core::Window > window, IO::Keys key)
 Fire the entity on a key event from a window.
 
Wiring & on (std::shared_ptr< Core::Window > window, IO::Keys key, bool held, std::function< void()> on_release=nullptr)
 Fire the entity repeatedly while a key is held, invoking a release callback on release.
 
Wiring & on (std::shared_ptr< Core::Window > window, IO::MouseButtons button)
 Fire the entity on a mouse button event from a window.
 
Wiring & on (std::shared_ptr< Core::Window > window, IO::MouseButtons button, bool held, std::function< void(double, double)> on_release=nullptr)
 Fire the entity on mouse-motion events while button is held.
 
Wiring & on (std::shared_ptr< Core::Window > window, IO::MouseButtons button, std::function< void(double, double)> on_release)
 Fire the entity on mouse button press and invoke a release callback on release.
 
Wiring & on (Vruta::NetworkSource &source)
 Fire the entity on each incoming message from a network source.
 
Wiring & on (Vruta::WindowEventSource &source, Vruta::WindowEventFilter filter={})
 Fire the entity on each matching window event.
 
Wiring & on_scroll (std::shared_ptr< Core::Window > window, std::function< void(double, double)> fn)
 Fire the entity on each mouse scroll event from a window.
 
Wiring & operator= (const Wiring &)=delete
 
Wiring & operator= (Wiring &&)=delete
 
const std::string & position_fn_name () const
 Name of the position function, empty if anonymous.
 
Wiring & position_from (PositionFn fn)
 Drive position from a callable evaluated on each every() tick.
 
Wiring & position_from (std::string fn_name, PositionFn fn)
 Drive position from a named callable evaluated on each every() tick.
 
Wiring & times (size_t count)
 Repeat the configured sequence or choreography N times.
 
size_t times_count () const
 Repetition count set by times, default 1.
 
const Trigger & trigger () const
 Active trigger variant set by on.
 
Wiring & use (CrossFactory factory)
 
Wiring & use (EventFactory factory)
 
Wiring & use (GraphicsFactory factory)
 
Wiring & use (SoundFactory factory)
 Delegate coroutine creation entirely to the caller.
 
Wiring & use (std::string fn_name, CrossFactory factory)
 
Wiring & use (std::string fn_name, EventFactory factory)
 
Wiring & use (std::string fn_name, GraphicsFactory factory)
 
Wiring & use (std::string fn_name, SoundFactory factory)
 Register a named factory.
 
 Wiring (const Wiring &)=delete
 
 Wiring (Wiring &&) noexcept=default
 
 ~Wiring ()=default
 

Static Public Attributes

static constexpr NullFunc no_release = nullptr
 

Private Types

using EFactory = std::optional< EventFactory >
 
using Factory = std::variant< std::monostate, SoundFactory, GraphicsFactory, CrossFactory >
 
using Trigger = std::variant< std::monostate, KeyTrigger, MouseTrigger, NetworkTrigger, EventTrigger, WindowEventTrigger, ScrollTrigger >
 

Private Member Functions

std::string make_name (const char *prefix) const
 
Vruta::Event window_event_source_loop (Vruta::WindowEventSource &source, Vruta::WindowEventFilter filter, Fabric &fabric, uint32_t id)
 
 Wiring (Fabric &fabric, uint32_t entity_id)
 

Private Attributes

std::optional< std::function< void()> > m_bind_attach
 
std::string m_bind_attach_name
 
std::optional< std::function< void()> > m_bind_detach
 
std::string m_bind_detach_name
 
std::optional< double > m_duration
 
Vruta::ProcessingToken m_duration_token { Vruta::ProcessingToken::SAMPLE_ACCURATE }
 
uint32_t m_entity_id
 
EFactory m_event_factory
 
Fabric & m_fabric
 
Factory m_factory
 
std::string m_factory_name
 
bool m_has_scheduling {}
 
std::optional< double > m_interval
 
Vruta::ProcessingToken m_metro_token { Vruta::ProcessingToken::SAMPLE_ACCURATE }
 
std::vector< MoveStep > m_move_steps
 
std::optional< PositionFn > m_position_fn
 
std::string m_position_fn_name
 
size_t m_times { 1 }
 
Trigger m_trigger
 

Friends

class Fabric
 
class StateEncoder
 

Detailed Description

Fluent builder that wires an entity into Fabric's scheduling infrastructure.

Obtained via Fabric::wire. Describes when and how the object's function is invoked. Call finalise() to apply the configuration.

No coroutine is created unless a scheduling modifier is set. bind() performs an immediate single call with no coroutine. Any scheduling modifier (every, on, move_to, position_from, use) creates and registers a coroutine owned by Fabric.

Definition at line 42 of file Wiring.hpp.


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