2#include <ossia/detail/config.hpp>
4#include <ossia/dataflow/graph/small_graph.hpp>
5#include <ossia/detail/flat_map.hpp>
6#include <ossia/detail/flat_set.hpp>
7#include <ossia/detail/pod_vector.hpp>
9#include <ossia/detail/ptr_set.hpp>
10#include <ossia/detail/small_vector.hpp>
14#include <boost/graph/adjacency_list.hpp>
16#include <ankerl/unordered_dense.h>
23using interval_set = ossia::flat_set<time_interval*>;
24using sync_set = ossia::flat_set<time_sync*>;
25using small_sync_vec = ossia::small_vector<time_sync*, 4>;
26using small_event_vec = std::vector<time_event*>;
35 int32_t start_sample{-1};
37using overtick_map = ossia::flat_map<time_sync*, overtick>;
40using scenario_graph_vertex = time_sync*;
41using scenario_graph_edge = time_interval*;
43using scenario_graph_t = boost::adjacency_list<
44 boost::smallvecS, boost::smallvecS, boost::undirectedS, scenario_graph_vertex,
48remove_vertex(
typename scenario_graph_t::vertex_descriptor v, scenario_graph_t& g)
50 typedef typename scenario_graph_t::directed_category Cat;
51 g.removing_vertex(v, boost::graph_detail::iterator_stability(g.m_vertices));
52 boost::detail::remove_vertex_dispatch(g, v, Cat());
86class OSSIA_EXPORT scenario final :
public looping_process<scenario>
88 friend class looping_process<scenario>;
98 void add_time_interval(std::shared_ptr<time_interval>);
103 void remove_time_interval(
const std::shared_ptr<time_interval>&);
107 void add_time_sync(std::shared_ptr<time_sync>);
111 void remove_time_sync(
const std::shared_ptr<time_sync>&);
115 const std::shared_ptr<time_sync>& get_start_time_sync()
const;
119 const ptr_container<time_sync>& get_time_syncs()
const;
123 const ptr_container<time_interval>& get_time_intervals()
const;
125 friend struct scenario_graph;
128 void state_impl(
const ossia::token_request& req);
130 void start()
override;
131 void stop()
override;
132 void pause()
override;
133 void resume()
override;
136 void mute_impl(
bool)
override;
151 small_sync_vec get_roots() const noexcept;
154 const ptr_container<time_sync>&, const ptr_container<time_interval>&,
157 ossia::time_value last_date() const noexcept {
return m_last_date; }
159 void set_exclusive(
bool excl)
noexcept;
160 bool exclusive(
bool excl)
const noexcept;
163 void stop_all_intervals();
166 ptr_container<time_interval> m_intervals;
167 ptr_container<time_sync> m_nodes;
170 interval_set m_runningIntervals;
171 sync_set m_waitingNodes;
172 small_sync_vec m_rootNodes;
173 small_event_vec m_pendingEvents;
174 small_event_vec m_maxReachedEvents;
175 overtick_map m_overticks;
176 ossia::flat_map<time_interval*, time_value> m_itv_end_map;
177 sync_set m_retry_syncs;
181 overtick_map m_backward_overticks;
182 sync_set m_startNodes;
185 sync_set m_component_visit_cache;
186 std::vector<ossia::time_sync*> m_component_visit_stack;
191 struct quantized_interval
194 double quantization_ratio{};
198 ossia::small_vector<quantized_interval, 2> m_itv_to_start;
199 ossia::small_vector<quantized_interval, 2> m_itv_to_stop;
201 static void make_happen(
202 time_event& event, interval_set& started, interval_set& stopped,
205 static void make_dispose(time_event& event, interval_set& stopped);
207 sync_status process_this(
208 time_sync& node, small_event_vec& pendingEvents, small_event_vec& maxReachedEvents,
210 const token_request& tok);
212 sync_status trigger_sync(
213 time_sync& node, small_event_vec& pending, small_event_vec& maxReachedEv,
215 const token_request& req,
bool maxReached);
217 sync_status process_this_musical(
218 time_sync& node, small_event_vec& pendingEvents, small_event_vec& maxReachedEvents,
221 sync_status trigger_sync_musical(
222 time_sync& node, small_event_vec& maxReachedEvents,
ossia::time_value tick_offset,
223 const token_request& req,
bool maxReached)
noexcept;
226 quantify_time_sync(time_sync& sync,
const ossia::token_request& tk)
noexcept;
229 trigger_quantified_time_sync(time_sync& sync,
bool& maximalDurationReached)
noexcept;
237 int32_t start_sample, int32_t end_sample);
243 void state_impl_backward(
const ossia::token_request& tk, time_value tick_amount);
244 void run_interval_backward(
247 int32_t start_sample, int32_t end_sample);
The time_interval class.
Definition time_interval.hpp:49
time_sync is use to describe temporal structure to synchronize each attached #time_event evaluation.
Definition time_sync.hpp:103
OSSIA_INLINE constexpr auto min(const T a, const U b) noexcept -> typename std::conditional<(sizeof(T) > sizeof(U)), T, U >::type
min function tailored for values
Definition math.hpp:125
OSSIA_INLINE constexpr auto max(const T a, const U b) noexcept -> typename std::conditional<(sizeof(T) > sizeof(U)), T, U >::type
max function tailored for values
Definition math.hpp:96
The time_value class.
Definition ossia/editor/scenario/time_value.hpp:30