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

◆ then() [1/2]

template<typename Executor , ComputeData DataType>
template<typename OpClass , ComputeData OutputType = DataType>
FluentExecutor< Executor, OutputType > MayaFlux::Yantra::FluentExecutor< Executor, DataType >::then ( )
inline

Chain operation execution by type.

Template Parameters
OpClassOperation class to execute
OutputTypeExpected output type (defaults to current DataType)
Returns
New FluentExecutor with transformed data
Exceptions
std::runtime_errorif operation fails

Definition at line 82 of file OperationChain.hpp.

83 {
84 if (!m_successful) {
85 throw std::runtime_error("Cannot continue chain after failed operation");
86 }
87
88 try {
89 auto result = m_executor->template execute<OpClass, DataType, OutputType>(m_data);
90 if (!result) {
91 m_successful = false;
92 record_error("Operation " + std::string(typeid(OpClass).name()) + " failed");
93 throw std::runtime_error("Operation failed in fluent chain: " + std::string(typeid(OpClass).name()));
94 }
95
96 auto next = FluentExecutor<Executor, OutputType>(m_executor, std::move(result->data));
97 next.m_operation_history = m_operation_history;
98 next.m_operation_history.push_back(typeid(OpClass).name());
99 return next;
100 } catch (const std::exception& e) {
101 m_successful = false;
102 record_error(e.what());
103 throw;
104 }
105 }
std::shared_ptr< Executor > m_executor
std::vector< std::string > m_operation_history
void record_error(const std::string &error)