MayaFlux 0.4.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 an anonymous operation instance by type.

Constructs a new instance of OpClass and executes it on the current Datum. The full Datum (data + container + metadata) is passed through.

Template Parameters
OpClassOperation class to instantiate and execute
OutputTypeExpected output type (defaults to current DataType)
Returns
New FluentExecutor carrying the result Datum

Definition at line 128 of file OperationChain.hpp.

129 {
130 if (!m_successful) {
131 error<std::runtime_error>(
133 std::source_location::current(),
134 "Cannot continue chain after failed operation");
135 }
136
137 try {
138 auto result = m_executor->template execute<OpClass, DataType, OutputType>(m_data);
139 if (!result) {
140 m_successful = false;
141 record_error("Operation " + std::string(typeid(OpClass).name()) + " failed");
142 error<std::runtime_error>(
144 std::source_location::current(),
145 "Operation failed in fluent chain: {}", std::string(typeid(OpClass).name()));
146 }
147
148 auto next = FluentExecutor<Executor, OutputType>(m_executor, std::move(*result));
149 next.m_operation_history = m_operation_history;
150 next.m_operation_history.push_back(typeid(OpClass).name());
151 return next;
152 } catch (const std::exception& e) {
153 m_successful = false;
154 record_error(e.what());
157 std::source_location::current(),
158 "Exception in fluent chain: " + std::string(e.what()));
159 }
160 }
void record_error(const std::string &err)
std::shared_ptr< Executor > m_executor
std::vector< std::string > m_operation_history
@ ComputeMatrix
Compute operations (Yantra - algorithms, matrices, DSP)
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.