14 const auto view =
access();
15 return view ? view->slice(start,
count) : std::nullopt;
20 const auto view =
access();
21 return view ? view->slice(region) : std::nullopt;
28 const auto*
element_bytes = std::get_if<std::vector<uint8_t>>(&elements);
29 const auto* text_bytes = std::get_if<std::vector<uint8_t>>(&text);
30 const auto* blob_bytes = std::get_if<std::vector<uint8_t>>(&blob);
32 if (!
element_bytes || !text_bytes || !blob_bytes || stride == 0
35 "as_composite_access: invalid storage or element stride");
39 for (
const auto& field : layout.
fields()) {
40 if (field.offset_bytes > stride || field.size_bytes > stride - field.offset_bytes
41 || ((field.type ==
typeid(std::string)
42 || field.type ==
typeid(std::vector<uint8_t>))
43 && field.size_bytes != 2 *
sizeof(uint64_t))
45 && field.size_bytes != 3 *
sizeof(uint64_t))) {
47 "as_composite_access: invalid layout for field '{}'", field.name);
64 const auto& elements = std::get<std::vector<uint8_t>>(*m_elements);
65 return { elements.data(), elements.size() };
91 if (start > end || end >=
size())
95 static_cast<size_t>(end - start + 1), region);
100 if (
index >= m_count)
102 return m_access.at(m_start +
index);
#define MF_WARN(comp, ctx,...)
std::optional< Composite > at(size_t index) const noexcept
Borrow an element by index.
std::span< const uint8_t > element_bytes() const noexcept
Borrow all packed element bytes without conversion.
std::optional< CompositeSlice > slice(size_t start, size_t count) const noexcept
Borrow count consecutive elements starting at start.
std::vector< DataDimension > byte_dimensions() const
Describe packed bytes as [elements, bytes-per-element].
size_t size() const noexcept
Number of packed elements in the current element store.
const CompositeLayout * m_layout
Validated, non-owning access to packed Composite NDData storage.
std::optional< CompositeAccess > access() const
Validate and borrow the packed NDData stores and layout.
std::optional< CompositeSlice > slice(size_t start, size_t count) const
Borrow consecutive elements without copying.
size_t stride_bytes() const noexcept
Bytes per packed element after finalization.
const std::vector< CompositeField > & fields() const noexcept
Declared fields in element order, with finalized byte offsets.
Shared field description and byte layout for a CompositeArray.
std::span< const uint8_t > element_bytes() const noexcept
Borrow the selected contiguous packed bytes.
std::optional< Composite > at(size_t index) const noexcept
Borrow a selected element by slice-relative index.
const CompositeLayout & layout() const noexcept
Shared layout of all selected elements.
Borrowed consecutive elements, optionally selected by a Region.
Read view of one value in a CompositeArray.
@ Runtime
General runtime operations (default fallback)
@ Kakshya
Containers[Signalsource, Stream, File], Regions, DataProcessors.
std::variant< std::vector< double >, std::vector< float >, std::vector< uint8_t >, std::vector< uint16_t >, std::vector< uint32_t >, std::vector< std::complex< float > >, std::vector< std::complex< double > >, std::vector< glm::vec2 >, std::vector< glm::vec3 >, std::vector< glm::vec4 >, std::vector< glm::mat4 > > DataVariant
Multi-type data storage for different precision needs.
std::optional< CompositeAccess > as_composite_access(const DataVariant &elements, const DataVariant &text, const DataVariant &blob, const CompositeLayout &layout)
Validate and borrow packed Composite-compatible NDData.
@ CUSTOM
User-defined or application-specific.
Minimal dimension descriptor focusing on structure only.
std::vector< uint64_t > end_coordinates
Ending frame index (inclusive)
std::vector< uint64_t > start_coordinates
Starting frame index (inclusive)
Represents a point or span in N-dimensional space.