MayaFlux 0.1.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches
MayaFlux::Kriya::EventChain Class Reference

A sequential chain of timed events with precise temporal control. More...

#include <Chain.hpp>

+ Collaboration diagram for MayaFlux::Kriya::EventChain:

Classes

struct  TimedEvent
 Structure representing a timed event in the chain. More...
 

Public Member Functions

 EventChain ()
 Constructs an EventChain using the global scheduler.
 
 EventChain (Vruta::TaskScheduler &scheduler)
 Constructs an EventChain with an explicit scheduler.
 
EventChainthen (std::function< void()> action, double delay_seconds=0.F)
 Adds an event to the chain with a specified delay.
 
void start ()
 Starts executing the event chain.
 

Private Attributes

std::vector< TimedEventm_events
 Collection of events in this chain.
 
Vruta::TaskSchedulerm_Scheduler
 Reference to the scheduler that manages timing.
 
std::shared_ptr< Vruta::SoundRoutinem_routine
 The underlying computational routine that implements the chain.
 

Detailed Description

A sequential chain of timed events with precise temporal control.

The EventChain class provides a way to schedule a sequence of events to occur at specific time intervals. It's designed for creating temporal sequences of actions with sample-accurate timing, which is essential for deterministic computational flows.

This approach is inspired by reactive programming and temporal logic systems where precise sequencing of operations is critical. It allows for creating complex temporal behaviors with a simple, declarative API.

Example usage:

// Create an event chain
EventChain chain(*scheduler);
// Add events with specific delays
chain.then([]() { process_initial_state(); }) // Immediate
.then([]() { transform_data(); }, 0.5) // After 0.5 seconds
.then([]() { apply_filter(); }, 0.25) // After another 0.25 seconds
.then([]() { finalize_output(); }, 0.25); // After another 0.25 seconds
// Start the chain
chain.start();
EventChain & then(std::function< void()> action, double delay_seconds=0.F)
Adds an event to the chain with a specified delay.
Definition Chain.cpp:22
void start()
Starts executing the event chain.
Definition Chain.cpp:28
A sequential chain of timed events with precise temporal control.
Definition Chain.hpp:39

The EventChain is particularly useful for creating precisely timed computational sequences, state transitions, or any series of time-based events that need to occur in a specific order with deterministic timing.

Definition at line 39 of file Chain.hpp.


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