2 #include <ossia/detail/config.hpp>
4 #include <ossia/detail/flicks.hpp>
18 class expression_base;
22 struct OSSIA_EXPORT time_sync_callback
24 virtual ~time_sync_callback();
26 virtual void triggered();
29 virtual void entered_evaluation();
32 virtual void entered_triggering();
39 virtual void left_evaluation();
42 virtual void finished_evaluation(
bool);
45 struct OSSIA_EXPORT time_sync_callbacks
47 ossia::small_vector<time_sync_callback*, 2> callbacks;
51 for(
auto cb : callbacks)
58 for(
auto v : callbacks)
62 void entered_evaluation()
64 for(
auto v : callbacks)
65 v->entered_evaluation();
68 void entered_triggering()
70 for(
auto v : callbacks)
71 v->entered_triggering();
76 for(
auto v : callbacks)
77 v->trigger_date_fixed(t);
80 void left_evaluation()
82 for(
auto v : callbacks)
86 void finished_evaluation(
bool b)
88 for(
auto v : callbacks)
89 v->finished_evaluation(b);
104 friend class ossia::scenario;
107 using container = ossia::small_vector<std::shared_ptr<time_event>, 2>;
108 using iterator = container::iterator;
109 using const_iterator = container::const_iterator;
119 [[nodiscard]]
time_value get_date()
const noexcept;
122 [[nodiscard]]
const expression& get_expression()
const noexcept;
131 time_sync& set_expression(expression_ptr) noexcept;
141 expression_ptr = expressions::make_expression_true());
142 iterator insert(const_iterator, std::shared_ptr<time_event>);
143 void remove(
const std::shared_ptr<time_event>&);
154 [[nodiscard]]
bool is_observing_expression() const noexcept;
155 [[nodiscard]]
bool is_evaluating() const noexcept;
159 void start_trigger_request() noexcept;
160 void end_trigger_request() noexcept;
169 [[nodiscard]]
bool is_autotrigger() const noexcept;
170 void set_autotrigger(
bool) noexcept;
172 [[nodiscard]]
bool is_start() const noexcept;
173 void set_start(
bool) noexcept;
176 void observe_expression(
bool);
177 void observe_expression(
bool,
ossia::expressions::expression_result_callback cb);
186 [[nodiscard]]
bool muted() const noexcept {
return m_muted; }
194 enum class status : uint8_t
200 [[nodiscard]] status get_status() const noexcept {
return m_status; }
202 void set_sync_rate(
double syncRatio) noexcept { m_sync_rate = syncRatio; }
203 [[nodiscard]]
double get_sync_rate() const noexcept {
return m_sync_rate; }
204 [[nodiscard]]
bool has_sync_rate() const noexcept {
return m_sync_rate > 0; }
206 void set_trigger_date(time_value v) noexcept
209 callbacks.trigger_date_fixed(v);
211 [[nodiscard]] time_value get_trigger_date() const noexcept {
return m_trigger_date; }
212 [[nodiscard]]
bool has_trigger_date() const noexcept
217 void set_is_being_triggered(
bool v) noexcept;
218 [[nodiscard]]
bool is_being_triggered() const noexcept {
return m_is_being_triggered; }
221 ossia::expression_ptr m_expression;
222 container m_timeEvents;
224 std::optional<expressions::expression_callback_iterator> m_callback;
226 double m_sync_rate = 0.;
228 std::atomic_bool trigger_request{};
229 time_value m_trigger_date = Infinite;
233 bool m_evaluating : 1;
235 bool m_autotrigger : 1;
236 bool m_is_being_triggered : 1;
std::function< void(status)> exec_callback
to get the event status back
Definition: time_event.hpp:63
#time_sync is use to describe temporal structure to synchronize each attached #time_event evaluation.
Definition: time_sync.hpp:103
auto & get_time_events() noexcept
get the #time_events of the #time_sync
Definition: time_sync.hpp:147
const auto & get_time_events() const noexcept
get the #time_events of the #time_sync
Definition: time_sync.hpp:151
time_sync_callbacks callbacks
Execution callbacks.
Definition: time_sync.hpp:192
expressions::expression_base expression
Definition: expression_fwd.hpp:222
The time_value class.
Definition: ossia/editor/scenario/time_value.hpp:28
constexpr bool infinite() const noexcept
is the time value infinite ?
Definition: ossia/editor/scenario/time_value.hpp:256