Monopoly — Portage moderne 0.1.0
Portage moderne C/C++23 du Monopoly de 1999
Loading...
Searching...
No Matches
SequenceChildSchedule.hpp
Go to the documentation of this file.
1#pragma once
2
3#include "LegacySequence.hpp"
4
5#include <vector>
6#include <memory>
7
8namespace monopoly::sequence
9{
10 using ChildScheduleError = std::variant<
12
13 // Owned, ordered child definitions and their scan cursor. This extracts
14 // AddNewlyBornChildren's selection rule, NOT recursive tree execution.
15 // Attribute chunks are skipped only for scheduling: their original bytes
16 // remain accessible through the owning reader for the future transform,
17 // label and renderer consumers. Unsupported sequence kinds fail explicitly.
19 {
20 public:
21 // Reads a whole owning CNK sibling list. Use the DATA source adapter
22 // below for direct or indirect children of a particular parent.
23 [[nodiscard]] static std::expected<SequenceChildSchedule, ChildScheduleError>
25 std::size_t maximumRecords = 65'536);
26
27 [[nodiscard]] std::span<const data::LegacySequenceRecord> records() const noexcept;
28 [[nodiscard]] data::DataId containingDataId() const noexcept;
29 [[nodiscard]] std::size_t nextIndex() const noexcept;
30
31 // Source interval is (previous, current]. nullopt means minus infinity.
32 // Never sorts disk order: the first future child stops the scan. Stop
33 // children already past end are skipped; infinite/held/loop children
34 // are not. Returns indices into records(), never borrowed pointers.
35 [[nodiscard]] std::expected<std::vector<std::size_t>, data::SequenceError>
36 select(std::optional<std::int32_t> previous, std::int32_t current);
37 void rewind() noexcept;
38
39 // Copy of the owning reader positioned BEFORE this child's header.
40 // Can decode the record and its attributes after a DAT bank is closed.
41 [[nodiscard]] std::expected<data::LegacyChunkReader, data::ChunkError>
42 readerForChild(std::size_t index) const;
43
44 private:
45 friend std::expected<SequenceChildSchedule, ChildScheduleError>
47 data::DataId, std::size_t, std::size_t);
48 [[nodiscard]] static std::expected<SequenceChildSchedule, ChildScheduleError>
50 std::size_t maximumRecords);
51 struct Description
52 {
54 data::DataId containingDataId;
55 std::vector<data::LegacySequenceRecord> records;
56 };
57 explicit SequenceChildSchedule(std::shared_ptr<const Description> description);
58 // Copies share immutable definitions/bytes; only the scan cursor is
59 // mutable. A runtime birth must not duplicate whole sibling payloads.
60 std::shared_ptr<const Description> description_;
61 std::size_t nextIndex_{};
62 };
63
64 // Decodes the parent at its DAT-relative offset. Direct children remain
65 // inside that parent; indirect children come from the resolved CNK item,
66 // at offset zero, overriding any inline children (L_Seqncr.cpp:4293-4303).
67 // Same-item indirect targets retain the source's parent-boundary failure.
68 // Only one level is loaded: cross-item cycles are NOT expanded recursively.
69 [[nodiscard]] std::expected<SequenceChildSchedule, ChildScheduleError>
72 std::size_t maximumRecords = 65'536);
73}
std::vector< std::byte > bytes
std::shared_ptr< const data::HmdTextureImage > source
unsigned index
std::expected< data::LegacyChunkReader, data::ChunkError > readerForChild(std::size_t index) const
static std::expected< SequenceChildSchedule, ChildScheduleError > read(data::SharedDataBytes bytes, data::DataId containingDataId, std::size_t maximumRecords=65 '536)
std::expected< std::vector< std::size_t >, data::SequenceError > select(std::optional< std::int32_t > previous, std::int32_t current)
friend std::expected< SequenceChildSchedule, ChildScheduleError > openSequenceChildSchedule(const data::DataSource &, data::DataId, std::size_t, std::size_t)
std::span< const data::LegacySequenceRecord > records() const noexcept
std::uint32_t DataId
Definition DataBanks.hpp:10
std::shared_ptr< const DataBytes > SharedDataBytes
std::expected< SequenceChildSchedule, ChildScheduleError > openSequenceChildSchedule(const data::DataSource &source, data::DataId parentDataId, std::size_t parentOffset, std::size_t maximumRecords)
std::variant< data::DataError, data::ChunkError, data::SequenceError > ChildScheduleError