11#include <initializer_list>
46 return grid.value <= 0;
69 const std::int64_t ticks_per_bar =
108 std::array<FollowAction, kMaxChoices>
choices{};
116 constexpr std::span<const FollowAction>
active() const noexcept {
118 return {
choices.data(), count};
131 std::uint32_t repetitions = 1) noexcept {
134 set.choice_count = 1;
135 set.repetitions = repetitions;
152 constexpr bool empty() const noexcept {
177 const
Slot* operator->() const noexcept;
179 Iterator& operator++() noexcept;
181 Iterator operator++(
int) noexcept {
191 Iterator(std::shared_ptr<
const std::vector<Slot>> raw,
192 std::shared_ptr<const detail::SlotListStore> store, std::size_t raw_index,
194 : raw_(std::move(raw)), store_(std::move(store)), raw_index_(raw_index),
196 std::shared_ptr<const std::vector<Slot>> raw_;
197 std::shared_ptr<const detail::SlotListStore> store_;
198 std::size_t raw_index_ = 0;
210 std::size_t
size() const noexcept;
223 return (*
this)[
size() - 1];
234 bool operator==(const
SlotList& other) const noexcept;
239 : store_(
std::move(store)) {}
240 std::shared_ptr<const std::vector<Slot>> raw_;
241 std::shared_ptr<const detail::SlotListStore> store_;
266 value += 0x9E3779B97F4A7C15ULL;
267 value ^= value >> 30;
268 value *= 0xBF58476D1CE4E5B9ULL;
269 value ^= value >> 27;
270 value *= 0x94D049BB133111EBULL;
271 value ^= value >> 31;
285 constexpr std::uint64_t
value() const noexcept {
296 const auto candidates = set.active();
297 std::uint64_t total = 0;
298 for (
const auto& candidate : candidates)
299 total += candidate.weight;
302 std::uint64_t pick = draw.value() % total;
303 for (std::size_t index = 0; index < candidates.size(); ++index) {
304 const std::uint64_t weight = candidates[index].weight;
321 static constexpr std::size_t
kNoSlot =
static_cast<std::size_t
>(-1);
333 std::size_t count = 0;
334 for (
const auto& slot : lane)
335 count += slot.empty() ? 0u : 1u;
340constexpr std::size_t
nth_non_empty(std::span<const Slot> lane, std::size_t n)
noexcept {
341 for (std::size_t index = 0; index < lane.size(); ++index) {
342 if (lane[index].empty())
354constexpr std::size_t
step_non_empty(std::span<const Slot> lane, std::size_t from,
355 bool forward)
noexcept {
356 const std::size_t size = lane.size();
359 std::size_t index = from;
360 for (std::size_t taken = 0; taken < size; ++taken) {
361 index = forward ? (index + 1) % size : (index + size - 1) % size;
362 if (!lane[index].empty())
384 if (self_index >= lane.size())
389 const auto candidates = set.active();
391 if (choice >= candidates.size())
395 switch (action.kind) {
424 const bool self_counts = !lane[self_index].empty();
426 const std::size_t others = count - (self_counts ? 1u : 0u);
432 std::size_t pick =
static_cast<std::size_t
>(roll % others);
433 for (std::size_t index = 0; index < lane.size(); ++index) {
434 if (index == self_index || lane[index].empty())
443 if (!action.target.valid())
445 for (std::size_t index = 0; index < lane.size(); ++index) {
446 if (lane[index].
id == action.target)
Forward iterator that retains raw or persistent slot storage.
Definition clip_launch.hpp:166
std::forward_iterator_tag iterator_category
Definition clip_launch.hpp:172
bool operator==(const Iterator &) const noexcept=default
Compares iterator position and retained storage identity.
std::ptrdiff_t difference_type
Definition clip_launch.hpp:169
const Slot * pointer
Definition clip_launch.hpp:170
friend class SlotList
Definition clip_launch.hpp:190
const Slot & reference
Definition clip_launch.hpp:171
Slot value_type
Definition clip_launch.hpp:168
const Slot & operator*() const noexcept
Borrows the current slot; the iterator's retained storage keeps it alive.
Immutable authored slot order with persistent structural sharing.
Definition clip_launch.hpp:163
const Slot & operator[](std::size_t index) const noexcept
Borrows the slot at index; index must be less than size().
SlotList(std::initializer_list< Slot > slots)
Copies slots in authored order.
SlotList(std::vector< Slot > slots)
Takes ownership of slots in authored order.
const Slot & back() const noexcept
Borrows the last slot; the list must be nonempty.
Definition clip_launch.hpp:222
bool empty() const noexcept
Returns whether the list contains no slots.
Definition clip_launch.hpp:212
std::size_t size() const noexcept
Returns the number of authored slots.
Iterator begin() const noexcept
Returns the first iterator in authored order.
bool shares_storage_with(const SlotList &other) const noexcept
Reports whether both snapshots share their complete backing store.
friend class detail::SlotListAccess
Definition clip_launch.hpp:237
const Slot & front() const noexcept
Borrows the first slot; the list must be nonempty.
Definition clip_launch.hpp:218
SlotList()
Constructs an empty list.
const Slot * find(ItemId id) const noexcept
Finds a slot by identity, or returns null.
Iterator end() const noexcept
Returns the end sentinel.
constexpr LaunchQuantize launch_every_quarters(std::int64_t count) noexcept
Returns a phase-zero grid spanning count quarter notes.
Definition clip_launch.hpp:59
constexpr std::size_t select_follow_action(const FollowActionSet &set, FollowDraw draw) noexcept
Selects one active candidate by relative weight.
Definition clip_launch.hpp:295
constexpr LaunchQuantize launch_every_bars(std::int64_t count, timebase::MeterSignature meter) noexcept
Returns a phase-zero grid spanning count bars under meter.
Definition clip_launch.hpp:67
constexpr FollowResolution resolve_follow_action(std::span< const Slot > lane, std::size_t self_index, FollowDraw draw) noexcept
Resolves the successor of self_index under that slot's follow-action set.
Definition clip_launch.hpp:382
FollowOutcome
Runtime request produced by resolving an authored follow action.
Definition clip_launch.hpp:313
constexpr FollowActionSet follow_action(FollowActionKind kind, timebase::TickDuration grid, std::uint32_t repetitions=1) noexcept
Builds a one-candidate follow set with unit weight.
Definition clip_launch.hpp:130
constexpr std::uint64_t follow_action_mix(std::uint64_t value) noexcept
Applies the deterministic SplitMix64 finalizer used by follow draws.
Definition clip_launch.hpp:265
FollowActionKind
Action applied when a slot's follow timer elapses.
Definition clip_launch.hpp:75
constexpr LaunchQuantize launch_immediate() noexcept
Returns an immediate, phase-zero launch policy.
Definition clip_launch.hpp:52
@ None
Definition clip.hpp:176
@ Stop
Definition clip_launch.hpp:315
@ None
Definition clip_launch.hpp:314
@ Play
Definition clip_launch.hpp:316
@ Jump
Definition clip_launch.hpp:85
@ Next
Definition clip_launch.hpp:80
@ Stop
Definition clip_launch.hpp:77
@ Again
Definition clip_launch.hpp:78
@ Other
Definition clip_launch.hpp:84
@ None
Definition clip_launch.hpp:76
@ First
Definition clip_launch.hpp:81
@ Last
Definition clip_launch.hpp:82
@ Previous
Definition clip_launch.hpp:79
@ Any
Definition clip_launch.hpp:83
constexpr std::int64_t kTicksPerQuarter
Definition tick.hpp:54
Definition clip_launch.hpp:30
Definition clip_launch.hpp:330
constexpr std::size_t count_non_empty(std::span< const Slot > lane) noexcept
Definition clip_launch.hpp:332
constexpr std::size_t step_non_empty(std::span< const Slot > lane, std::size_t from, bool forward) noexcept
Definition clip_launch.hpp:354
constexpr FollowResolution play(std::span< const Slot > lane, std::size_t index) noexcept
Definition clip_launch.hpp:369
constexpr std::size_t nth_non_empty(std::span< const Slot > lane, std::size_t n) noexcept
Definition clip_launch.hpp:340
Definition program_compiler.hpp:18
Definition compiled_meter_map.hpp:14
Bounded weighted follow behavior attached to a slot.
Definition clip_launch.hpp:105
constexpr bool enabled() const noexcept
Returns whether this set has candidates, a positive period, and repetitions.
Definition clip_launch.hpp:122
constexpr bool operator==(const FollowActionSet &) const =default
constexpr std::span< const FollowAction > active() const noexcept
Returns the populated prefix of choices.
Definition clip_launch.hpp:116
timebase::TickDuration grid
Definition clip_launch.hpp:111
std::uint32_t repetitions
Definition clip_launch.hpp:110
static constexpr std::size_t kMaxChoices
Definition clip_launch.hpp:106
std::uint8_t choice_count
Definition clip_launch.hpp:109
std::array< FollowAction, kMaxChoices > choices
Definition clip_launch.hpp:108
One weighted follow-action candidate.
Definition clip_launch.hpp:92
constexpr auto operator<=>(const FollowAction &) const =default
ItemId target
Definition clip_launch.hpp:94
FollowActionKind kind
Definition clip_launch.hpp:93
std::uint16_t weight
Definition clip_launch.hpp:95
Stable identity of one reproducible follow-action decision.
Definition clip_launch.hpp:279
constexpr std::uint64_t value() const noexcept
Returns the deterministic 64-bit draw for this decision identity.
Definition clip_launch.hpp:285
std::uint64_t seed
Definition clip_launch.hpp:280
std::uint64_t draw_index
Definition clip_launch.hpp:282
ItemId slot
Definition clip_launch.hpp:281
Deterministic outcome and optional target slot of follow resolution.
Definition clip_launch.hpp:320
std::size_t slot_index
Definition clip_launch.hpp:324
static constexpr std::size_t kNoSlot
Definition clip_launch.hpp:321
FollowOutcome outcome
Definition clip_launch.hpp:323
ItemId slot_id
Definition clip_launch.hpp:325
constexpr auto operator<=>(const FollowResolution &) const =default
Nonzero monotonic identity for a Timeline-owned object.
Definition item_id.hpp:19
Musical-boundary quantization for one launch.
Definition clip_launch.hpp:40
constexpr auto operator<=>(const LaunchQuantize &) const =default
constexpr bool immediate() const noexcept
Returns whether launch occurs without boundary quantization.
Definition clip_launch.hpp:45
timebase::TickDuration grid
Definition clip_launch.hpp:41
timebase::TickPosition phase
Definition clip_launch.hpp:42
Authored grouping of slots presented as one launchable column.
Definition clip_launch.hpp:247
SlotList slots
Definition clip_launch.hpp:250
ItemId id
Definition clip_launch.hpp:248
std::string name
Definition clip_launch.hpp:249
bool operator==(const Scene &) const =default
One authored launch slot.
Definition clip_launch.hpp:145
constexpr bool empty() const noexcept
Returns whether this slot references no launchable clip.
Definition clip_launch.hpp:152
LaunchQuantize launch_quantize
Definition clip_launch.hpp:148
FollowActionSet follow
Definition clip_launch.hpp:149
ItemId id
Definition clip_launch.hpp:146
ItemId clip_id
Definition clip_launch.hpp:147
constexpr bool operator==(const Slot &) const =default