15 for(
auto& action : actions)
20 auto updater = [actions = actions,
22 current_action_idx = size_t(0),
23 prev_overflow = duration_t::zero(),
24 prev_elapsed = duration_t::zero(),
25 start_required =
true,
34 if(sentinel.expired())
43 prev_elapsed = duration_t::zero();
44 start_required =
false;
49 for(
auto& action : actions)
55 auto& current_action = actions.at(current_action_idx);
59 delta += prev_overflow;
65 auto elapsed_diff =
elapsed - prev_elapsed;
72 prev_overflow = duration_t::zero();
77 if(current_action_idx == actions.size())
84 start_required =
true;
89 auto creator = [updater = std::move(updater)]()
117 for(
const auto& action : actions)
123 [actions = actions, sentinel = sentinel, start_required =
true,
finished =
false](
duration_t delta,
131 if(sentinel.expired())
139 for(
auto& action : actions)
143 start_required =
false;
148 for(
auto& action : actions)
155 for(
auto& action : actions)
172 auto creator = [updater = std::move(updater)]()
191 if(sentinel.expired())
211 auto creator = [updater = std::move(updater)]()
226 auto updater = [action = action,
231 prev_overflow = duration_t::zero(),
239 if(sentinel.expired())
255 delta += prev_overflow;
266 prev_overflow = duration_t::zero();
300 auto creator = [updater = std::move(updater)]()
mutable
323 return repeat_impl(action, times,
false, sentinel);
void add_repeat_info(seq_action &repeat_action, const seq_action &action, size_t times)
void add_together_info(seq_action &action, const std::vector< seq_action > &actions)
void add_sequence_info(seq_action &action, const std::vector< seq_action > &actions)
void update_action_status(seq_action &action)
void add_delay_info(seq_action &action)
Provides a sequence-based action management system for controlling and scheduling actions.
hpp::sentinel sentinel_t
Alias for a sentinel object used for lifecycle management.
@ running
The action is running.
@ finished
The action has finished.
auto sequence_precise(const std::vector< seq_action > &actions, const sentinel_t &sentinel) -> seq_action
Creates a precise sequential action that executes a list of actions with exact timing.
seq::seq_action creator(const std::string &type, values_t< T > &values, T &begin, const T &end, seq::duration_t duration)
auto repeat(const seq_action &action, size_t times) -> seq_action
Repeats an action a specified number of times.
auto repeat_impl(const seq_action &action, size_t times, bool precise, const sentinel_t &sentinel=hpp::eternal_sentinel()) -> seq_action
auto repeat_precise(const seq_action &action, size_t times) -> seq_action
Precisely repeats an action a specified number of times.
auto delay(const duration_t &duration, const sentinel_t &sentinel) -> seq_action
Creates a delay action.
auto sequence(const std::vector< seq_action > &actions, const sentinel_t &sentinel) -> seq_action
Creates a sequential action that executes a list of actions one after another.
std::chrono::nanoseconds duration_t
Represents a duration in nanoseconds.
auto together(const std::vector< seq_action > &actions, const sentinel_t &sentinel) -> seq_action
Creates a simultaneous action that executes a list of actions together.
auto sequence_impl(const std::vector< seq_action > &actions, const sentinel_t &sentinel, bool precise) -> seq_action
Represents an action within the sequence management system. Contains lifecycle events and management ...
static auto get_duration(const seq_action &self) -> duration_t
Gets the total duration of a given action.
static void start(seq_action &action)
Starts a given action.
static auto update(seq_action &action, duration_t delta) -> state_t
Updates a given action with a time delta.
static void update_elapsed(seq_action &self, duration_t update_time)
Updates the elapsed time of a given action.
static void stop_when_finished(seq_action &action)
Marks a given action to stop when finished.
static auto get_overflow(const seq_action &self) -> duration_t
Computes the overflow duration of a given action if it exceeds its total duration.
static auto is_stop_when_finished_requested(const seq_action &action) -> bool
Checks if the action is requested to stop when finished.
static auto get_elapsed(const seq_action &self) -> duration_t
Gets the elapsed time of a given action.