MayaFlux 0.4.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
 

Public Types

using ComplexFactory = std::function< Vruta::ComplexRoutine(Vruta::TaskScheduler &)>
 
using EventFactory = std::function< Vruta::Event(Vruta::TaskScheduler &)>
 
using GraphicsFactory = std::function< Vruta::GraphicsRoutine(Vruta::TaskScheduler &)>
 
using PositionFn = std::function< glm::vec3()>
 
using SoundFactory = std::function< Vruta::SoundRoutine(Vruta::TaskScheduler &)>
 

Public Member Functions

Wiringbind ()
 Call the entity's influence function once immediately.
 
Wiringbind (std::function< void()> attach, std::function< void()> detach)
 Call attach immediately; call detach after for_duration expires or on explicit cancel().
 
Wiringbind (std::function< void()> fn)
 Call a custom function once immediately instead of the entity's own.
 
Wiringbind (std::string attach_name, std::function< void()> attach, std::string detach_name, std::function< void()> detach)
 Call named attach/detach functions.
 
Wiringbind (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 EFactoryevent_factory () const
 Active event-factory, if use(EventFactory) was called.
 
Wiringevery (double interval_seconds)
 Fire the entity on a recurring interval.
 
const Factoryfactory () 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.
 
Wiringfor_duration (double seconds)
 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.
 
const std::vector< MoveStep > & move_steps () const
 Choreography steps from move_to calls.
 
Wiringmove_to (const glm::vec3 &pos, double delay_seconds=0.0)
 Choreograph a position move as an EventChain step.
 
Wiringon (std::shared_ptr< Core::Window > window, IO::Keys key)
 Fire the entity on a key event from a window.
 
Wiringon (std::shared_ptr< Core::Window > window, IO::MouseButtons button)
 Fire the entity on a mouse button event from a window.
 
Wiringon (Vruta::EventSource &source, Vruta::EventFilter filter={})
 Fire the entity on each matching window event.
 
Wiringon (Vruta::NetworkSource &source)
 Fire the entity on each incoming message from a network source.
 
Wiringoperator= (const Wiring &)=delete
 
Wiringoperator= (Wiring &&)=delete
 
const std::string & position_fn_name () const
 Name of the position function, empty if anonymous.
 
Wiringposition_from (PositionFn fn)
 Drive position from a callable evaluated on each every() tick.
 
Wiringposition_from (std::string fn_name, PositionFn fn)
 Drive position from a named callable evaluated on each every() tick.
 
Wiringtimes (size_t count)
 Repeat the configured sequence or choreography N times.
 
size_t times_count () const
 Repetition count set by times, default 1.
 
const Triggertrigger () const
 Active trigger variant set by on.
 
Wiringuse (ComplexFactory factory)
 
Wiringuse (EventFactory factory)
 
Wiringuse (GraphicsFactory factory)
 
Wiringuse (SoundFactory factory)
 Delegate coroutine creation entirely to the caller.
 
Wiringuse (std::string fn_name, ComplexFactory factory)
 
Wiringuse (std::string fn_name, EventFactory factory)
 
Wiringuse (std::string fn_name, GraphicsFactory factory)
 
Wiringuse (std::string fn_name, SoundFactory factory)
 Register a named factory.
 
 Wiring (const Wiring &)=delete
 
 Wiring (Wiring &&) noexcept=default
 
 ~Wiring ()=default
 

Private Types

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

Private Member Functions

std::string make_name (const char *prefix) const
 
 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
 
uint32_t m_entity_id
 
EFactory m_event_factory
 
Fabricm_fabric
 
Factory m_factory
 
std::string m_factory_name
 
bool m_has_scheduling {}
 
std::optional< double > m_interval
 
std::vector< MoveStepm_move_steps
 
std::optional< PositionFnm_position_fn
 
std::string m_position_fn_name
 
size_t m_times { 1 }
 
Trigger m_trigger
 

Friends

class Fabric
 

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 39 of file Wiring.hpp.


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