Unravel Engine C++ Reference
Loading...
Searching...
No Matches
seq_manager.h
Go to the documentation of this file.
1#pragma once
2#include "seq_action.h"
3#include <set>
4#include <unordered_map>
5
10namespace seq
11{
12
18{
23 struct seq_info
24 {
29
33 uint32_t depth = 0;
34
38 std::vector<std::string> scopes;
39 };
40
44 using action_collection_t = std::map<seq_id_t, seq_info>;
45
52 seq_id_t start(seq_action action, const seq_scope_policy& scope_policy = {});
53
58 void stop(seq_id_t id);
59
64 void stop_all(const std::string& scope = {});
65
70 void pause(seq_id_t id);
71
77 void pause_all(const std::string& scope = {}, const std::string& key = {});
78
83 void resume(seq_id_t id);
84
90 void resume_all(const std::string& scope = {}, const std::string& key = {});
91
97
102 void stop_when_finished_all(const std::string& scope = {});
103
109 void stop_and_finish(seq_id_t id, duration_t finish_after = 0ms);
110
115 void stop_and_finish_all(const std::string& scope = {});
116
122 auto is_stopping(seq_id_t id) const -> bool;
123
129 auto is_running(seq_id_t id) const -> bool;
130
136 auto is_paused(seq_id_t id) const -> bool;
137
143 auto is_finished(seq_id_t id) const -> bool;
144
150 bool has_action_with_scope(const std::string& scope_id);
151
157 void set_speed_multiplier(seq_id_t id, float speed_multiplier = 1.0f);
158
164 auto get_speed_multiplier(seq_id_t id) -> float;
165
171 auto get_elapsed(seq_id_t id) const -> duration_t;
172
178 auto get_duration(seq_id_t id) const -> duration_t;
179
185 auto get_overflow(seq_id_t id) const -> duration_t;
186
192 void update(seq_id_t id, duration_t delta);
193
200
205 void update(duration_t delta);
206
211 void push_scope(const std::string& scope);
212
217 void close_scope(const std::string& scope);
218
222 void pop_scope();
223
227 void clear_scopes();
228
233 auto get_current_scope() const -> const std::string&;
234
239 auto get_scopes() const -> const std::vector<std::string>&;
240
245 auto get_actions() const -> const action_collection_t&;
246
247private:
252 void start_action(seq_info& info);
253
258 auto get_ids() const -> std::vector<seq_id_t>;
262 std::vector<std::string> scopes_;
263
267 int32_t current_scope_idx_ = -1;
268
272 std::set<std::pair<std::string, std::string>> paused_scopes_;
273
277 action_collection_t actions_;
278
282 action_collection_t pending_actions_;
283};
284
285} // namespace seq
float elapsed
Provides a sequence-based action management system for controlling and scheduling actions.
size_t seq_id_t
Represents a unique identifier for sequence actions.
Definition seq_common.h:53
std::chrono::nanoseconds duration_t
Represents a duration in nanoseconds.
Definition seq_common.h:41
Represents an action within the sequence management system. Contains lifecycle events and management ...
Definition seq_action.h:18
Stores information about an action, including its state, depth, and associated scopes.
Definition seq_manager.h:24
uint32_t depth
The depth of the action in a sequence hierarchy.
Definition seq_manager.h:33
seq_action action
The action being managed.
Definition seq_manager.h:28
std::vector< std::string > scopes
The scopes associated with the action.
Definition seq_manager.h:38
Manages and coordinates multiple sequence actions with scoping, pausing, and updating capabilities.
Definition seq_manager.h:18
void resume(seq_id_t id)
Resumes the action associated with the specified ID.
void close_scope(const std::string &scope)
Closes a scope, removing it from the stack.
auto get_elapsed(seq_id_t id) const -> duration_t
Gets the elapsed time of an action.
auto get_duration(seq_id_t id) const -> duration_t
Gets the total duration of an action.
void stop_and_finish(seq_id_t id, duration_t finish_after=0ms)
Stops an action and ensures it completes after the specified duration.
void resume_all(const std::string &scope={}, const std::string &key={})
Resumes all actions within the specified scope and key.
auto is_stopping(seq_id_t id) const -> bool
Checks if an action is stopping.
void push_scope(const std::string &scope)
Pushes a scope onto the scope stack.
auto is_finished(seq_id_t id) const -> bool
Checks if an action has finished.
auto get_overflow(seq_id_t id) const -> duration_t
Gets the overflow time of an action.
void stop_and_finish_all(const std::string &scope={})
Stops all actions in the specified scope and ensures they complete.
auto get_current_scope() const -> const std::string &
Gets the current scope from the scope stack.
void clear_scopes()
Clears all scopes from the scope stack.
void stop_all(const std::string &scope={})
Stops all actions within the specified scope.
auto get_speed_multiplier(seq_id_t id) -> float
Gets the speed multiplier of an action.
auto get_scopes() const -> const std::vector< std::string > &
Gets the list of all active scopes.
auto is_paused(seq_id_t id) const -> bool
Checks if an action is paused.
void set_elapsed(seq_id_t id, duration_t elapsed)
Sets the elapsed time of an action (use with caution).
void set_speed_multiplier(seq_id_t id, float speed_multiplier=1.0f)
Sets the speed multiplier for an action.
void pause_all(const std::string &scope={}, const std::string &key={})
Pauses all actions within the specified scope and key.
void pause(seq_id_t id)
Pauses the action associated with the specified ID.
void update(seq_id_t id, duration_t delta)
Updates the elapsed time of a specific action.
void stop_when_finished_all(const std::string &scope={})
Marks all actions in the specified scope to stop when they finish.
auto get_actions() const -> const action_collection_t &
Gets the collection of all managed actions.
seq_id_t start(seq_action action, const seq_scope_policy &scope_policy={})
Starts a new action and associates it with the specified scope policy.
std::map< seq_id_t, seq_info > action_collection_t
Alias for the collection of actions managed by the seq_manager.
Definition seq_manager.h:44
void stop_when_finished(seq_id_t id)
Marks an action to stop when it finishes.
bool has_action_with_scope(const std::string &scope_id)
Checks if there is any action associated with the specified scope ID.
void pop_scope()
Pops the current scope from the scope stack.
void stop(seq_id_t id)
Stops the action associated with the specified ID.
auto is_running(seq_id_t id) const -> bool
Checks if an action is running.
Defines policies for scoping actions in a sequence.
Definition seq_common.h:92