73template<std::u
int8_t N>
76 static constexpr std::string_view
name()
78 if constexpr(N == 1) {
79 return "BinaryDataBuffer";
80 }
else if constexpr(N == 2) {
81 return "BinaryDataBuffer2D";
82 }
else if constexpr(N == 3) {
83 return "BinaryDataBuffer3D";
105template<std::u
int8_t NBytes, std::u
int8_t N>
115 static constexpr uint8_t
DIM = N;
126 std::vector<irsol::types::byte_t>&&
data,
127 const std::array<uint64_t, N>&
shape,
128 std::vector<BinaryDataAttribute>&&
attributes = {})
137 this->
data.size() == this->numBytes,
138 "Data size (%lu) does not match the number of elements (%lu) multiplied by bytes per element "
142 this->BYTES_PER_ELEMENT);
159 std::vector<irsol::types::byte_t>
data;
179 std::stringstream ss;
180 ss << BinaryDataBufferName<N>::name() <<
"u" << (
BYTES_PER_ELEMENT == 1 ?
"8" :
"16")
181 <<
"[shape=(" << std::to_string(
shape[0]);
182 for(uint8_t i = 1; i <
DIM; ++i) {
183 ss <<
"x" << std::to_string(
shape[i]);
185 ss <<
")](" << std::to_string(
numBytes) <<
" bytes)";
Assertion macros and utilities based on the PPK_ASSERT library.
#define IRSOL_ASSERT_ERROR
Error-level assertion macro.
#define IRSOL_LOG_TRACE(...)
Logs a trace-level message using the default logger.
Logging utilities and configuration for the irsol library.
Common portability and diagnostic macros for the irsol library.
#define IRSOL_STATIC_UNREACHABLE(messageLiteral)
Marks unreachable branches in constexpr functions.
std::variant< int, double, std::string > protocol_value_t
Variant type representing protocol values that can be one of several types.
Represents a single binary data attribute within the protocol.
std::string identifier
Identifier of the binary data attribute.
std::string toString() const
Returns a string representation of the binary data attribute.
irsol::types::protocol_value_t value
Value associated with the attribute.
Helper to get a descriptive name for binary data buffers by dimensionality.
static constexpr std::string_view name()
Represents a binary data object within the protocol.
std::vector< BinaryDataAttribute > attributes
Additional attributes related to the binary data.
std::vector< irsol::types::byte_t > data
Owned binary data bytes.
BinaryData & operator=(const BinaryData &)=delete
std::array< uint64_t, DIM > shape
Shape of the binary data.
static constexpr uint8_t BYTES_PER_ELEMENT
Number of bytes per element.
std::string toString() const
Returns a string summary of the binary data buffer.
BinaryData(std::vector< irsol::types::byte_t > &&data, const std::array< uint64_t, N > &shape, std::vector< BinaryDataAttribute > &&attributes={})
Constructs a BinaryData object.
uint64_t numElements
Total number of elements in the data.
BinaryData & operator=(BinaryData &&other) noexcept=delete
BinaryData(BinaryData &&other)=default
Move constructs a BinaryData object.
IRSOL_STATIC_ASSERT(N >=1, "Binary data dimensionality must be at least 1")
static constexpr uint8_t DIM
Dimensionality of the binary data.
BinaryData(const BinaryData &)=delete
IRSOL_STATIC_ASSERT((NBytes==1||NBytes==2), "Binary data element byte size must be 1 or 2")
uint64_t numBytes
Total number of bytes (numElements * bytes per element).
Core type definitions for networking, time handling, and protocol values used throughout the irsol li...