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

◆ process()

template<ComputeData InputType = std::vector<Kakshya::DataVariant>, ComputeData OutputType = InputType>
output_type MayaFlux::Yantra::ComputationPipeline< InputType, OutputType >::process ( const input_type input,
const ExecutionContext context = {} 
)
inline

Execute the pipeline with grammar rule application.

Parameters
inputInput data to process through the pipeline
contextExecution context containing parameters and metadata
Returns
Processed output data

Executes the complete pipeline processing workflow:

  1. Grammar Rule Application: Searches for grammar rules that match the input data and execution context. If a matching rule is found, applies it first.
  2. Operation Chain Execution: Executes all operations in the pipeline in the order they were added, passing output from each stage as input to the next.
  3. Type Conversion: Handles type conversion between InputType and OutputType when they differ.

The pipeline provides comprehensive error handling with operation-specific error messages that include the operation name for debugging.

Exceptions
std::runtime_errorIf any operation in the pipeline fails

Definition at line 155 of file ComputePipeline.hpp.

155 {})
156 {
157 input_type current_data = input;
158 ExecutionContext current_context = context;
159
160 if (auto best_rule = m_grammar->find_best_match(current_data, current_context)) {
161 if (auto rule_result = m_grammar->execute_rule(best_rule->name, current_data, current_context)) {
162 try {
163 current_data = std::any_cast<input_type>(*rule_result);
164 } catch (const std::bad_any_cast&) {
165 // Continue with original data if conversion fails
166 }
167 }
168 }
169
170 for (const auto& [operation, name] : m_operations) {
171 try {
172 auto result = operation->apply_operation(current_data);
173 current_data = result;
174 } catch (const std::exception& e) {
175 throw std::runtime_error("Pipeline operation failed: " + name + " - " + e.what());
176 }
177 }
178
179 if constexpr (std::is_same_v<InputType, OutputType>) {
180 return current_data;
181 } else {
182 output_type result;
183 return result;
184 }
185 }
std::vector< std::pair< std::shared_ptr< ComputeOperation< InputType, OutputType > >, std::string > > m_operations
Operations and their names in execution order.
std::shared_ptr< ComputationGrammar > m_grammar
Grammar instance for rule-based operation selection.