| 50 | }; |
| 51 | |
| 52 | class BufferAssembler { |
| 53 | public: |
| 54 | struct BeginParams { |
| 55 | std::string variable_name; |
| 56 | std::string display_name; |
| 57 | std::string pixel_layout; |
| 58 | bool transpose{}; |
| 59 | int width{}; |
| 60 | int height{}; |
| 61 | int channels{}; |
| 62 | int stride{}; |
| 63 | int type{}; |
| 64 | std::size_t total_byte_size; |
| 65 | }; |
| 66 | |
| 67 | // Start transfer for buffer `name`. |
| 68 | void begin(BeginParams params); |
| 69 | |
| 70 | // Append row-strip chunk. Returns false if name unknown, size mismatch, or |
| 71 | // out of bounds. |
| 72 | [[nodiscard]] bool chunk(const std::string& name, |
| 73 | std::size_t row_offset, |
| 74 | std::size_t row_count, |
| 75 | std::span<const std::byte> bytes); |
| 76 | |
| 77 | // Finish transfer, moving bytes out dropping entry. Returns |
| 78 | // nullopt if name unknown. |
| 79 | [[nodiscard]] std::optional<AssembledBuffer> end(const std::string& name); |
| 80 | |
| 81 | private: |
| 82 | struct InProgress { |
| 83 | BeginParams params; |
| 84 | std::vector<std::byte> bytes; |
| 85 | }; |
| 86 | std::map<std::string, InProgress, std::less<>> in_progress_{}; |
| 87 | }; |
| 88 | |
| 89 | } // namespace oid |
| 90 |
nothing calls this directly
no outgoing calls
no test coverage detected