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

◆ write() [9/16]

template<typename T , typename Processor , typename Assemble >
void MayaFlux::Portal::Forma::Bridge::write ( Layer &  layer,
const std::vector< std::shared_ptr< MappedState< T > > > &  states,
Assemble  assemble,
std::shared_ptr< Processor >  target 
)
inline

Assemble a typed state range into DataVariant for a write processor.

Each tick copies the current values of states, in order, into a contiguous span of their native T type. assemble authors the conversion from that span to DataVariant. Bridge owns the repeated sampling, layer lifetime, and delivery through Processor::set_data(DataVariant).

Template Parameters
TMapped state value type.
ProcessorDestination exposing set_data(DataVariant).
AssembleCallable returning DataVariant from span<const T>.
Parameters
layerLayer whose lifetime owns the aggregate route.
statesNon-null states to sample in range order.
assembleAuthor-supplied conversion into DataVariant.
targetProcessor receiving each assembled result.

Definition at line 277 of file Bridge.hpp.

282 {
283 static_assert(std::is_same_v<
284 std::remove_cvref_t<std::invoke_result_t<Assemble&, std::span<const T>>>,
286 "Bridge aggregate assembly must return Kakshya::DataVariant");
287
288 auto sources = states;
289 auto assembler = std::make_shared<Assemble>(std::move(assemble));
290 auto values = std::make_shared<std::vector<T>>();
291
292 write_assembled_data(layer, [sources = std::move(sources), assembler, values]() mutable {
293 values->resize(sources.size());
294 for (size_t i = 0; i < sources.size(); ++i)
295 (*values)[i] = sources[i]->value;
296 return (*assembler)(std::span<const T>(*values)); }, [target = std::move(target)](Kakshya::DataVariant data) { target->set_data(std::move(data)); });
297 }
std::vector< std::byte > values
Definition VDBWriter.cpp:26
void write_assembled_data(Layer &layer, std::function< Kakshya::DataVariant()> assemble, std::function< void(Kakshya::DataVariant)> write)
Definition Bridge.cpp:501
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.
Definition NDData.hpp:70

References values.