2#include <ossia/dataflow/graph_node.hpp>
4#include <ossia/detail/timed_vec.hpp>
6#include <tuplet/tuple.hpp>
10namespace ossia::safe_nodes
12template <
typename T,
typename U>
13auto timestamp(
const std::pair<T, U>& p)
18auto timestamp(
const T& p)
25 template <
typename TickFun,
typename... Args>
27 TickFun&& f,
const ossia::token_request& req,
const ossia::timed_vec<Args>&... arg)
29 using namespace tuplet;
30 auto iterators = tuplet::make_tuple(arg.begin()...);
31 const auto last_iterators = tuplet::make_tuple(--arg.end()...);
37 auto reached_end = [&] {
39 ossia::for_each_in_range<
sizeof...(arg)>(
40 [&b, &iterators, &last_iterators](
auto i) {
41 b &= (tuplet::get<i.value>(iterators) == tuplet::get<i.value>(last_iterators));
48 ossia::token_request r = req;
51 [&](
const auto&... it) { std::forward<TickFun>(f)(r, it->second...); },
61 std::bitset<
sizeof...(Args)> to_increment;
63 auto min = ossia::Infinite;
65 ossia::for_each_in_range<
sizeof...(arg)>([&](
auto idx_t) {
66 constexpr auto idx = idx_t.value;
67 auto& it = tuplet::get<idx>(iterators);
68 if(it != tuplet::get<idx>(last_iterators))
72 const auto next_ts = time_value{timestamp(*next)};
73 const auto diff = next_ts - current_time;
85 to_increment.set(idx);
89 to_increment.set(idx);
95 ossia::for_each_in_range<
sizeof...(arg)>([&](
auto idx_t) {
96 constexpr auto idx = idx_t.value;
97 if(to_increment.test(idx))
99 ++tuplet::get<idx>(iterators);
104 call_f(current_time);
108struct default_tick_controls
110 template <
typename TickFun,
typename... Args>
112 TickFun&& f,
const ossia::token_request& req,
const ossia::timed_vec<Args>&... arg)
119 template <
typename TickFun,
typename... Args>
120 void operator()(TickFun&& f,
const ossia::token_request& req)
128 template <
typename TickFun,
typename... Args>
130 TickFun&& f,
const ossia::token_request& req,
const ossia::timed_vec<Args>&... arg)
134 [&](
const auto&... it) { std::forward<TickFun>(f)(req, it->second...); },
135 tuplet::make_tuple(--arg.end()...));
139struct last_tick_values
141 template <
typename TickFun,
typename... Args>
142 void operator()(TickFun&& f,
const ossia::token_request& req,
const Args&... arg)
144 std::forward<TickFun>(f)(req, arg...);
150struct first_last_tick
152 template <
typename TickFun,
typename... Args>
154 TickFun&& f,
const ossia::token_request& req,
const ossia::timed_vec<Args>&... arg)
158 [&](
const auto&... it) { std::forward<TickFun>(f)(req, it->second...); },
159 tuplet::make_tuple({arg.begin(), --arg.end()}...));
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
The time_value class.
Definition ossia/editor/scenario/time_value.hpp:30