Execute the pipeline with grammar rule application.
The pipeline provides comprehensive error handling with operation-specific error messages that include the operation name for debugging.
155 {})
156 {
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
166 }
167 }
168 }
169
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 {
183 return result;
184 }
185 }
IO< OutputType > output_type
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.
IO< InputType > input_type