MayaFlux 0.1.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches
MayaFlux::Yantra::FluentExecutor< Executor, DataType > Class Template Reference

Fluent interface for chaining operations on any executor. More...

#include <OperationChain.hpp>

+ Collaboration diagram for MayaFlux::Yantra::FluentExecutor< Executor, DataType >:

Public Types

using executor_type = Executor
 
using data_type = DataType
 

Public Member Functions

 FluentExecutor (std::shared_ptr< Executor > executor, const DataType &input)
 Construct with executor and initial data.
 
 FluentExecutor (std::shared_ptr< Executor > executor, DataType &&input)
 Move constructor for efficiency.
 
template<typename OpClass , ComputeData OutputType = DataType>
FluentExecutor< Executor, OutputType > then ()
 Chain operation execution by type.
 
template<typename OpClass , ComputeData OutputType = DataType>
FluentExecutor< Executor, OutputType > then (const std::string &name)
 Chain named operation.
 
template<typename Func >
requires std::invocable<Func, const DataType&>
auto apply (Func &&func)
 Apply custom transformation function.
 
template<typename Func >
requires std::invocable<Func, DataType&>
FluentExecutortap (Func &&func)
 Apply function with side effects (doesn't change data type)
 
template<typename OpClass >
FluentExecutorwhen (bool condition)
 Conditional execution.
 
template<typename OpClass , typename Pred >
requires std::predicate<Pred, const DataType&>
FluentExecutorwhen (Pred &&predicate)
 Conditional execution with predicate.
 
template<typename... OpClasses>
auto fork ()
 Fork execution into multiple paths.
 
const DataType & get () const
 Get the final result.
 
DataType & get_mutable ()
 Get mutable reference to the result.
 
DataType consume () &&
 Move the result out.
 
IO< DataType > to_io () const
 Extract to IO wrapper with metadata.
 
DataType get_or (const DataType &default_value) const
 Get or provide default value.
 
template<typename Generator >
requires std::invocable<Generator>
DataType get_or_else (Generator &&generator) const
 Get or compute default value.
 
bool is_successful () const
 Check if all operations succeeded.
 
const std::vector< std::string > & get_history () const
 Get operation history.
 
const std::vector< std::string > & get_errors () const
 Get accumulated errors.
 
std::shared_ptr< Executor > get_executor () const
 Get the executor.
 
FluentExecutorreset (const DataType &new_data)
 Reset with new data.
 

Private Member Functions

void record_error (const std::string &error)
 

Private Attributes

std::shared_ptr< Executor > m_executor
 
DataType m_data
 
bool m_successful
 
std::vector< std::string > m_operation_history
 
std::vector< std::string > m_errors
 

Detailed Description

template<typename Executor, ComputeData DataType>
class MayaFlux::Yantra::FluentExecutor< Executor, DataType >

Fluent interface for chaining operations on any executor.

Provides a composable, type-safe way to chain operations together. This class is executor-agnostic and can work with any type that satisfies the ExecutorConcept.

Key Features:

  • Type-safe operation chaining with compile-time verification
  • Support for both type-based and named operations
  • Custom function application within the chain
  • Multiple terminal operations for different use cases
  • Error accumulation and reporting

Usage:

auto result = executor.with(input_data)
.then<Transformer>()
.apply([](auto& data) { return preprocess(data); })
.then<Analyzer>("my_analyzer")
.get();
auto apply(Func &&func)
Apply custom transformation function.

Definition at line 41 of file OperationChain.hpp.


The documentation for this class was generated from the following file: