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

◆ merge_chain()

void MayaFlux::Buffers::BufferProcessingChain::merge_chain ( const std::shared_ptr< BufferProcessingChain > &  other)

Combines another processing pipeline into this one with optimization.

Parameters
otherChain to merge into this one

Adds all processors from the other chain to this one, preserving their buffer associations and order while performing intelligent optimization. This enables the composition of complex transformation pipelines from simpler, reusable components:

  • Compatibility Analysis: Validates that merged processors are compatible
  • Optimization Opportunities: Identifies potential performance improvements in the combined pipeline
  • Resource Consolidation: Optimizes resource usage across the merged processors
  • Backend Harmonization: Resolves any backend conflicts between the chains

Definition at line 253 of file BufferProcessingChain.cpp.

254{
255 for (const auto& [buffer, processors] : other->get_chain()) {
256 if (!m_buffer_processors.count(buffer)) {
257 m_buffer_processors.try_emplace(buffer, processors);
258 } else {
259 auto& target_processors = m_buffer_processors[buffer];
260 target_processors.reserve(target_processors.size() + processors.size());
261
262 for (const auto& processor : processors) {
263 if (std::ranges::find(target_processors, processor) == target_processors.end()) {
264 target_processors.push_back(processor);
265 }
266 }
267 }
268 }
269}
std::unordered_map< std::shared_ptr< Buffer >, std::vector< std::shared_ptr< BufferProcessor > > > m_buffer_processors
Map of buffers to their processor sequences.
std::unordered_map< std::shared_ptr< Buffer >, std::vector< std::shared_ptr< BufferProcessor > > > get_chain() const
Gets the entire transformation pipeline structure.

References m_buffer_processors.