MayaFlux 0.1.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches
MayaFlux::Yantra::ComputationPipeline< InputType, OutputType > Class Template Reference

Pipeline that uses grammar rules for operation composition. More...

#include <ComputePipeline.hpp>

+ Collaboration diagram for MayaFlux::Yantra::ComputationPipeline< InputType, OutputType >:

Public Types

using input_type = IO< InputType >
 
using output_type = IO< OutputType >
 

Public Member Functions

 ComputationPipeline (std::shared_ptr< ComputationGrammar > grammar=nullptr)
 Constructor with optional grammar.
 
template<typename ConcreteOpType >
ComputationPipelineadd_operation (std::shared_ptr< ConcreteOpType > operation, const std::string &name="")
 Add a concrete operation instance to the pipeline.
 
template<typename ConcreteOpType , typename... Args>
ComputationPipelinecreate_operation (const std::string &name="", Args &&... args)
 Create and add operation by type.
 
output_type process (const input_type &input, const ExecutionContext &context={})
 Execute the pipeline with grammar rule application.
 
std::shared_ptr< ComputationGrammarget_grammar () const
 Get the grammar instance.
 
void set_grammar (std::shared_ptr< ComputationGrammar > grammar)
 Set grammar instance.
 
template<typename ConcreteOpType >
std::shared_ptr< ConcreteOpType > get_operation (const std::string &name) const
 Get operation by name.
 
template<typename ConcreteOpType >
bool configure_operation (const std::string &name, const std::function< void(std::shared_ptr< ConcreteOpType >)> &configurator)
 Configure operation by name.
 
size_t operation_count () const
 Get number of operations in pipeline.
 
void clear_operations ()
 Clear all operations.
 
std::vector< std::string > get_operation_names () const
 Get all operation names in the pipeline.
 
bool remove_operation (const std::string &name)
 Remove operation by name.
 

Private Attributes

std::shared_ptr< ComputationGrammarm_grammar
 Grammar instance for rule-based operation selection.
 
std::vector< std::pair< std::shared_ptr< ComputeOperation< InputType, OutputType > >, std::string > > m_operations
 Operations and their names in execution order.
 

Detailed Description

template<ComputeData InputType = std::vector<Kakshya::DataVariant>, ComputeData OutputType = InputType>
class MayaFlux::Yantra::ComputationPipeline< InputType, OutputType >

Pipeline that uses grammar rules for operation composition.

Template Parameters
InputTypeInput data type (defaults to std::vector<Kakshya::DataVariant>)
OutputTypeOutput data type (defaults to InputType)

The ComputationPipeline provides a flexible, grammar-aware system for chaining computational operations in sequence. Unlike traditional pipelines that execute operations in a fixed order, this pipeline can dynamically select and apply operations based on grammar rules that match input data characteristics and execution context.

Key Features

Grammar Integration: Uses ComputationGrammar to intelligently select and configure operations based on input data properties and context.

Type Safety: Template-based design ensures type compatibility between pipeline stages while supporting different input/output types.

Dynamic Configuration: Operations can be added, configured, and removed at runtime, enabling adaptive processing workflows.

Error Handling: Comprehensive error handling with operation-specific error reporting and graceful degradation.

Usage Patterns

Basic Pipeline Construction

auto pipeline = std::make_shared<ComputationPipeline<std::vector<Kakshya::DataVariant>>>();
// Add operations with names for later reference
pipeline->create_operation<MathematicalTransformer<>>("gain_stage")
->create_operation<SpectralTransformer<>>("frequency_processing")
->create_operation<TemporalTransformer<>>("time_effects");
ComputationPipeline & create_operation(const std::string &name="", Args &&... args)
Create and add operation by type.
Concrete transformer for mathematical operations.
Concrete transformer for frequency-domain operations.
Concrete transformer for time-domain operations.

Grammar-Driven Processing

// Pipeline automatically applies grammar rules before operation chain
context.execution_metadata["processing_mode"] = std::string("high_quality");
auto result = pipeline->process(input_data, context);
// Grammar rules are evaluated first, then operation chain executes
std::unordered_map< std::string, std::any > execution_metadata
Context information for operation execution.

Dynamic Operation Configuration

// Configure specific operations by name
pipeline->configure_operation<MathematicalTransformer<>>("gain_stage",
[](auto op) {
op->set_parameter("operation", "gain");
op->set_parameter("gain_factor", 2.0);
});

Definition at line 67 of file ComputePipeline.hpp.


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