MayaFlux 0.4.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 auto cast_result = safe_any_cast<input_type>(*rule_result);
163
164 if (cast_result) {
165 current_data = *cast_result.value;
166 } else {
167 MF_ERROR(
170 "Grammar rule '{}' returned incompatible type: {}",
171 best_rule->name,
172 cast_result.error);
173 }
174 }
175 }
176
177 for (const auto& [operation, name] : m_operations) {
178 try {
179 auto result = operation->apply_operation(current_data);
180 current_data = result;
181 } catch (const std::exception& e) {
183 Journal::Component::Yantra, Journal::Context::Runtime, std::source_location::current(),
184 "Pipeline operation '{}' failed: {}", name, e.what());
185 }
186 }
187
188 if constexpr (std::is_same_v<InputType, OutputType>) {
189 return current_data;
190 } else {
191 output_type result;
192 return result;
193 }
194 }
#define MF_ERROR(comp, ctx,...)
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.
@ Runtime
General runtime operations (default fallback)
void error_rethrow(Component component, Context context, std::source_location location=std::source_location::current(), std::string_view additional_context="")
Catch and log an exception, then rethrow it.
@ Yantra
DSP algorithms, computational units, matrix operations, Grammar.