|
MayaFlux 0.3.0
Digital-First Multimedia Processing Framework
|
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 (Vruta::TaskScheduler &scheduler, std::string name="") | |
| Constructs an EventChain with an explicit scheduler. | |
| EventChain & | then (std::function< void()> action, double delay_seconds=0.F) |
| Adds an event to the chain with a specified delay. | |
| EventChain & | repeat (size_t count) |
| Repeat the last event N times. | |
| EventChain & | times (size_t count) |
| Repeat entire chain N times. | |
| EventChain & | wait (double delay_seconds) |
| Add a wait/delay without an action. | |
| EventChain & | every (double interval_seconds, std::function< void()> action) |
| Convenience method for repeating an action at regular intervals. | |
| void | start () |
| Starts executing the event chain. | |
| void | cancel () |
| Cancels the event chain if it's currently executing. | |
| bool | is_active () const |
| Checks if the event chain is currently active. | |
| EventChain & | on_complete (std::function< void()> callback) |
| Sets a callback to execute when the chain stops executing. | |
| const std::string & | name () const |
| Gets the name of the event chain. | |
| size_t | event_count () const |
| Gets the number of events in the chain. | |
| size_t | repeat_count () const |
| Gets the repeat count for the entire chain. | |
Private Member Functions | |
| void | fire_on_complete () |
| Internal method to safely fire the on_complete callback. | |
Private Attributes | |
| std::vector< TimedEvent > | m_events |
| Collection of events in this chain. | |
| Vruta::TaskScheduler & | m_Scheduler |
| Reference to the scheduler that manages timing. | |
| std::shared_ptr< Vruta::SoundRoutine > | m_routine |
| The underlying computational routine that implements the chain. | |
| std::function< void()> | m_on_complete |
| Optional callback to execute when the chain completes. | |
| std::string | m_name |
| Optional name for the event chain. | |
| bool | m_on_complete_fired {} |
| Flag to ensure on_complete is only fired once. | |
| size_t | m_repeat_count { 1 } |
| Number of times to repeat the entire chain. | |
| uint64_t | m_default_rate { 48000 } |
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:
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.