Unravel Engine C++ Reference
Loading...
Searching...
No Matches
seq.cpp
Go to the documentation of this file.
1#include "seq.h"
3#include "seq_inspector.h"
4
5namespace seq
6{
7
8auto start(seq_action action, const seq_scope_policy& scope_policy, hpp::source_location location) -> seq_id_t
9{
10 inspector::add_location(action, location);
11 return detail::get_manager().start(std::move(action), scope_policy);
12}
13
14void stop(seq_id_t id)
15{
16 detail::get_manager().stop(id);
17}
18
19void pause(const seq_id_t id)
20{
21 detail::get_manager().pause(id);
22}
23
24void resume(const seq_id_t id)
25{
26 detail::get_manager().resume(id);
27}
28
30{
31 detail::get_manager().stop_when_finished(id);
32}
33
34void stop_and_finish(seq_id_t id, duration_t finish_after)
35{
36 detail::get_manager().stop_and_finish(id, finish_after);
37}
38
39auto is_stopping(seq_id_t id) -> bool
40{
41 return detail::get_manager().is_stopping(id);
42}
43
44auto is_running(seq_id_t id) -> bool
45{
46 return detail::get_manager().is_running(id);
47}
48
49auto is_paused(seq_id_t id) -> bool
50{
51 return detail::get_manager().is_paused(id);
52}
53
54auto is_finished(seq_id_t id) -> bool
55{
56 return detail::get_manager().is_finished(id);
57}
58
59auto has_action_with_scope(const std::string& scope_id) -> bool
60{
61 return detail::get_manager().has_action_with_scope(scope_id);
62}
63
64void set_speed_multiplier(seq_id_t id, float speed_multiplier)
65{
66 detail::get_manager().set_speed_multiplier(id, speed_multiplier);
67}
68
70{
71 return detail::get_manager().get_speed_multiplier(id);
72}
73
75{
76 return detail::get_manager().get_elapsed(id);
77}
78
80{
81 detail::get_manager().set_elapsed(id, duration);
82}
83
85{
86 return detail::get_manager().get_duration(id);
87}
88
90{
91 return detail::get_manager().get_overflow(id);
92}
93
94void update(seq_id_t id, duration_t delta)
95{
96 detail::get_manager().update(id, delta);
97}
98
99auto get_percent(seq_id_t id) -> float
100{
101 auto dur = get_duration(id);
102 if(dur == duration_t::zero())
103 {
104 return 0.0f;
105 }
106 float elapsed = float(get_elapsed(id).count());
107 float total_dur = float(dur.count());
108 return elapsed / total_dur;
109}
110
112{
113 detail::get_manager().update(delta);
114}
115
117{
118 update(std::chrono::duration_cast<seq::duration_t>(delta));
119}
120
121
123{
124 detail::get_manager() = {};
125}
126
127namespace scope
128{
129void push(const std::string& scope)
130{
131 detail::get_manager().push_scope(scope);
132}
133
134void pop()
135{
136 detail::get_manager().pop_scope();
137}
138
139void close(const std::string& scope)
140{
141 detail::get_manager().close_scope(scope);
142}
143
144void clear()
145{
146 detail::get_manager().clear_scopes();
147}
148
149auto get_current() -> const std::string&
150{
151 return detail::get_manager().get_current_scope();
152}
153
154void stop_all(const std::string& scope)
155{
156 detail::get_manager().stop_all(scope);
157}
158
159void pause_all(const std::string& scope)
160{
161 detail::get_manager().pause_all(scope);
162}
163
164void resume_all(const std::string& scope)
165{
166 detail::get_manager().resume_all(scope);
167}
168
169void pause_all(const std::string& scope, const std::string& key)
170{
171 detail::get_manager().pause_all(scope, key);
172}
173
174void resume_all(const std::string& scope, const std::string& key)
175{
176 detail::get_manager().resume_all(scope, key);
177}
178
179void stop_and_finish_all(const std::string& scope)
180{
181 detail::get_manager().stop_and_finish_all(scope);
182}
183
184void stop_when_finished_all(const std::string& scope)
185{
186 detail::get_manager().stop_when_finished_all(scope);
187}
188
189} // namespace scope
190
191namespace manager
192{
194{
195 detail::push(mgr);
196}
197void pop()
198{
199 detail::pop();
200}
201} // namespace manager
202} // namespace seq
float elapsed
auto get_manager() -> seq_manager &
void push(seq_manager &mgr)
void add_location(seq_action &action, const hpp::source_location &location)
void pop()
Pops the top sequence manager from the stack.
Definition seq.cpp:197
void push(seq_manager &mgr)
Pushes a sequence manager to the stack.
Definition seq.cpp:193
void pause_all(const std::string &scope)
Pauses all actions within the specified scope.
Definition seq.cpp:159
void stop_when_finished_all(const std::string &scope)
Marks all actions within the specified scope to stop when they finish.
Definition seq.cpp:184
void push(const std::string &scope)
Pushes a new scope to the stack.
Definition seq.cpp:129
void stop_all(const std::string &scope)
Stops all actions within the specified scope.
Definition seq.cpp:154
auto get_current() -> const std::string &
Gets the name of the current scope.
Definition seq.cpp:149
void pop()
Pops the current scope from the stack.
Definition seq.cpp:134
void close(const std::string &scope)
Closes the specified scope.
Definition seq.cpp:139
void clear()
Clears all scopes from the stack.
Definition seq.cpp:144
void resume_all(const std::string &scope)
Resumes all actions within the specified scope.
Definition seq.cpp:164
void stop_and_finish_all(const std::string &scope)
Stops and finishes all actions within the specified scope.
Definition seq.cpp:179
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
void update(seq_id_t id, duration_t delta)
Updates the elapsed duration of a specific action.
Definition seq.cpp:94
auto is_finished(seq_id_t id) -> bool
Checks if the action has finished.
Definition seq.cpp:54
std::chrono::duration< float > duraiton_secs_t
Represents a duration in seconds as a floating-point value.
Definition seq_common.h:35
void set_elapsed(seq_id_t id, duration_t duration)
Sets the elapsed duration of an action.
Definition seq.cpp:79
auto is_paused(seq_id_t id) -> bool
Checks if the action is paused.
Definition seq.cpp:49
void resume(const seq_id_t id)
Resumes the action associated with the given ID.
Definition seq.cpp:24
auto start(seq_action action, const seq_scope_policy &scope_policy, hpp::source_location location) -> seq_id_t
Starts a new action.
Definition seq.cpp:8
auto get_duration(seq_id_t id) -> duration_t
Gets the total duration of an action.
Definition seq.cpp:84
auto get_overflow(seq_id_t id) -> duration_t
Gets the overflow duration of an action.
Definition seq.cpp:89
void stop_and_finish(seq_id_t id, duration_t finish_after)
Stops the action after a specified duration.
Definition seq.cpp:34
auto is_running(seq_id_t id) -> bool
Checks if the action is running.
Definition seq.cpp:44
void shutdown()
Shuts down the action management system, stopping all actions.
Definition seq.cpp:122
void set_speed_multiplier(seq_id_t id, float speed_multiplier)
Sets the speed multiplier for an action.
Definition seq.cpp:64
auto is_stopping(seq_id_t id) -> bool
Checks if the action is stopping.
Definition seq.cpp:39
auto get_speed_multiplier(seq_id_t id) -> float
Gets the speed multiplier of an action.
Definition seq.cpp:69
auto get_elapsed(seq_id_t id) -> duration_t
Gets the elapsed duration of an action.
Definition seq.cpp:74
void stop_when_finished(seq_id_t id)
Marks the action to stop when it finishes.
Definition seq.cpp:29
auto has_action_with_scope(const std::string &scope_id) -> bool
Checks if there is an action associated with the given scope ID.
Definition seq.cpp:59
auto get_percent(seq_id_t id) -> float
Gets the percentage completion of an action.
Definition seq.cpp:99
void stop(seq_id_t id)
Stops the action associated with the given ID.
Definition seq.cpp:14
std::chrono::nanoseconds duration_t
Represents a duration in nanoseconds.
Definition seq_common.h:41
void pause(const seq_id_t id)
Pauses the action associated with the given ID.
Definition seq.cpp:19
Represents an action within the sequence management system. Contains lifecycle events and management ...
Definition seq_action.h:18
Manages and coordinates multiple sequence actions with scoping, pausing, and updating capabilities.
Definition seq_manager.h:18
Defines policies for scoping actions in a sequence.
Definition seq_common.h:92