MayaFlux 0.1.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches
MayaFlux::Buffers::BufferProcessingChain Class Reference

Advanced pipeline manager for multi-stage buffer transformations with backend optimization. More...

#include <BufferProcessingChain.hpp>

+ Inheritance diagram for MayaFlux::Buffers::BufferProcessingChain:
+ Collaboration diagram for MayaFlux::Buffers::BufferProcessingChain:

Classes

struct  PendingProcessorOp
 

Public Member Functions

bool add_processor (const std::shared_ptr< BufferProcessor > &processor, const std::shared_ptr< Buffer > &buffer, std::string *rejection_reason=nullptr)
 Adds a processor to the transformation pipeline for a specific buffer.
 
void remove_processor (const std::shared_ptr< BufferProcessor > &processor, const std::shared_ptr< Buffer > &buffer)
 Removes a processor from the pipeline for a specific buffer.
 
void process (const std::shared_ptr< Buffer > &buffer)
 Applies the transformation pipeline to a buffer with intelligent execution.
 
void add_final_processor (const std::shared_ptr< BufferProcessor > &processor, const std::shared_ptr< Buffer > &buffer)
 Sets a special processor to be applied after the main pipeline.
 
bool has_processors (const std::shared_ptr< Buffer > &buffer) const
 Checks if a buffer has any processors in its pipeline.
 
const std::vector< std::shared_ptr< BufferProcessor > > & get_processors (const std::shared_ptr< Buffer > &buffer) const
 Gets all processors in a buffer's transformation pipeline.
 
std::unordered_map< std::shared_ptr< Buffer >, std::vector< std::shared_ptr< BufferProcessor > > > get_chain () const
 Gets the entire transformation pipeline structure.
 
void merge_chain (const std::shared_ptr< BufferProcessingChain > &other)
 Combines another processing pipeline into this one with optimization.
 
void process_final (const std::shared_ptr< Buffer > &buffer)
 Applies the final processor to a buffer with guaranteed execution.
 
void set_preferred_token (ProcessingToken token)
 Sets the preferred processing token for this chain.
 
ProcessingToken get_preferred_token () const
 Gets the preferred processing token for this chain.
 
void set_enforcement_strategy (TokenEnforcementStrategy strategy)
 Sets the token enforcement strategy for this chain.
 
TokenEnforcementStrategy get_enforcement_strategy () const
 Gets the current token enforcement strategy for this chain.
 
void optimize_for_tokens (const std::shared_ptr< Buffer > &buffer)
 Optimizes the processing pipeline for improved performance.
 
std::vector< TokenCompatibilityReportanalyze_token_compatibility () const
 Analyzes token compatibility across all processors in the chain.
 
bool validate_all_processors (std::vector< std::string > *incompatibility_reasons=nullptr) const
 Validates all processors in the chain against the preferred processing token.
 
void enforce_chain_token_on_processors ()
 Enforces the chain's preferred processing token on all processors.
 
bool has_pending_operations () const
 
template<typename T >
std::shared_ptr< T > get_processor (const std::shared_ptr< Buffer > &buffer) const
 Gets a processor of a specific type from the buffer's processing pipeline.
 

Protected Member Functions

bool add_processor_direct (const std::shared_ptr< BufferProcessor > &processor, const std::shared_ptr< Buffer > &buffer, std::string *rejection_reason=nullptr)
 
void remove_processor_direct (const std::shared_ptr< BufferProcessor > &processor, const std::shared_ptr< Buffer > &buffer)
 

Private Member Functions

void process_non_owning (const std::shared_ptr< Buffer > &buffer)
 Internal processing method for non-owning buffer contexts.
 
void cleanup_rejected_processors (const std::shared_ptr< Buffer > &buffer)
 Validates the processing token against the chain's preferred token.
 
void process_pending_processor_operations ()
 Process pending processor operations.
 
bool queue_pending_processor_op (const std::shared_ptr< BufferProcessor > &processor, const std::shared_ptr< Buffer > &buffer, bool is_addition, std::string *rejection_reason=nullptr)
 

Private Attributes

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::unordered_set< std::shared_ptr< BufferProcessor > > > m_conditional_processors
 Map of buffers to processors that are conditionally applied.
 
std::unordered_map< std::shared_ptr< Buffer >, std::unordered_set< std::shared_ptr< BufferProcessor > > > m_pending_removal
 Map of buffers to processors pending removal.
 
std::unordered_map< std::shared_ptr< Buffer >, std::shared_ptr< BufferProcessor > > m_final_processors
 Map of buffers to their final processors.
 
ProcessingToken m_token_filter_mask { ProcessingToken::AUDIO_BACKEND }
 Preferred processing token for this chain.
 
TokenEnforcementStrategy m_enforcement_strategy { TokenEnforcementStrategy::FILTERED }
 Token enforcement strategy for this chain.
 
std::atomic< bool > m_is_processing
 
PendingProcessorOp m_pending_ops [MAX_PENDING_PROCESSORS]
 
std::atomic< uint32_t > m_pending_count { 0 }
 

Static Private Attributes

static constexpr size_t MAX_PENDING_PROCESSORS = 32
 

Friends

class BufferProcessor
 
class FileBridgeProcessor
 

Detailed Description

Advanced pipeline manager for multi-stage buffer transformations with backend optimization.

BufferProcessingChain organizes multiple BufferProcessor objects into sophisticated transformation pipelines for one or more buffers. This system enables complex multi-stage computational processes to be applied to data in a controlled, deterministic order while leveraging the expanded capabilities of modern BufferProcessors for optimal performance and backend utilization.

The chain implements an intelligent directed acyclic graph (DAG) of transformations, maintaining separate processor sequences for each buffer while enabling advanced features:

Backend-Aware Processing:

  • Automatic backend optimization based on processor recommendations
  • Intelligent batching of compatible processors for parallel execution
  • Dynamic backend switching to optimize processing pipelines
  • Resource-aware scheduling to prevent backend conflicts

Multi-Modal Data Support:

  • Seamless processing of different data types (audio, video, texture) within unified chains
  • Type-safe processor assignment and validation
  • Cross-domain transformations between different buffer types
  • Unified interface for heterogeneous data processing

Performance Optimization:

  • Processor compatibility validation and automatic optimization
  • Complexity-based scheduling for optimal resource utilization
  • Parallel execution of independent processing stages
  • Memory layout optimization for improved cache performance

Key features:

  • Enables construction of complex computational pipelines with backend optimization
  • Supports both parallel and sequential transformation patterns with automatic selection
  • Preserves transformation order while optimizing execution strategy
  • Provides special "final" processors for guaranteed post-processing operations
  • Allows dynamic reconfiguration of transformation pipelines at runtime
  • Leverages processor agency for optimal backend selection and resource utilization

Definition at line 45 of file BufferProcessingChain.hpp.


The documentation for this class was generated from the following files: