MayaFlux 1.0.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ set()

template<typename T >
requires ArithmeticData<T>
bool MayaFlux::Kakshya::CompositeArray::set ( size_t  index,
std::string_view  field_name,
T  value 
)
inline

Write an arithmetic field of an existing element.

Template Parameters
TDeclared arithmetic type, or int64_t/double for a dynamic field.
Parameters
indexElement index.
field_nameField to write.
valueValue to store.
Returns
True on success; false for an invalid index, name, or type.

Definition at line 280 of file Composite.hpp.

281 {
282 if constexpr (std::same_as<T, int64_t> || std::same_as<T, double>) {
283 const auto field_index = m_layout.find_field(field_name);
284 if (field_index && m_layout.fields()[*field_index].type == typeid(detail::CompositeDynamic)) {
285 if constexpr (std::same_as<T, int64_t>)
286 return set_integer(index, field_name, value);
287 else
288 return set_real(index, field_name, value);
289 }
290 }
291 const auto field_index = validate_write(index, field_name, typeid(T));
292 if (!field_index)
293 return false;
294
295 const auto& field = m_layout.fields()[*field_index];
296 auto& rows = std::get<std::vector<uint8_t>>(m_rows);
297 std::memcpy(rows.data() + index * m_layout.stride_bytes() + field.offset_bytes,
298 &value, sizeof(T));
299 set_present(index, *field_index, true);
300 return true;
301 }
uint32_t rows
glm::vec3 value
uint32_t index
Definition VKDevice.cpp:122
bool set_integer(size_t index, std::string_view field_name, int64_t value)
void set_present(size_t index, size_t field_index, bool present) noexcept
std::optional< size_t > validate_write(size_t index, std::string_view field_name, std::type_index type) const
bool set_real(size_t index, std::string_view field_name, double value)
size_t stride_bytes() const noexcept
Bytes per packed element after finalization.
Definition Composite.hpp:86
const std::vector< CompositeField > & fields() const noexcept
Declared fields in element order, with finalized byte offsets.
Definition Composite.hpp:82
std::optional< size_t > find_field(std::string_view name) const noexcept
Find a field index by name, or std::nullopt if absent.
Definition Composite.cpp:54

References index, rows, and value.

Referenced by MayaFlux::Yantra::OperationHelper::reconstruct_projected_composite().

+ Here is the caller graph for this function: