MayaFlux 0.4.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 data_type = DataType
 
using executor_type = Executor
 
using io_type = Datum< DataType >
 

Public Member Functions

template<typename Func >
requires std::invocable<Func, const DataType&>
auto apply (Func &&func)
 Apply a custom transformation function within the chain.
 
DataType consume () &&
 Move the final raw result out of the chain.
 
Datum< DataType > consume_datum () &&
 Move the full result Datum out of the chain.
 
 FluentExecutor (std::shared_ptr< Executor > executor, const DataType &input)
 Construct with executor and raw data (convenience entry point)
 
 FluentExecutor (std::shared_ptr< Executor > executor, const Datum< DataType > &input)
 Construct with executor and Datum input.
 
 FluentExecutor (std::shared_ptr< Executor > executor, DataType &&input)
 Construct with executor and raw data (move, convenience entry point)
 
 FluentExecutor (std::shared_ptr< Executor > executor, Datum< DataType > &&input)
 Construct with executor and Datum input (move)
 
template<typename... OpClasses>
auto fork ()
 Fork execution into multiple independent parallel paths.
 
const DataType & get () const
 Get the final raw result by const reference.
 
const Datum< DataType > & get_datum () const
 Get the full result Datum by const reference.
 
const std::vector< std::string > & get_errors () const
 Get all errors accumulated during the chain.
 
std::shared_ptr< Executor > get_executor () const
 Get the underlying executor.
 
const std::vector< std::string > & get_history () const
 Get the ordered list of operation names executed so far.
 
DataType & get_mutable ()
 Get a mutable reference to the final raw result.
 
DataType get_or (const DataType &default_value) const
 Return the raw result or a fallback value if the chain failed.
 
template<typename Generator >
requires std::invocable<Generator>
DataType get_or_else (Generator &&generator) const
 Return the raw result or invoke a generator if the chain failed.
 
bool is_successful () const
 Check whether all operations in the chain have succeeded.
 
FluentExecutorreset (const DataType &new_data)
 Reset the chain with raw data (convenience overload)
 
FluentExecutorreset (const Datum< DataType > &new_datum)
 Reset the chain with a new Datum, clearing history and errors.
 
template<typename Func >
requires std::invocable<Func, DataType&>
FluentExecutortap (Func &&func)
 Apply a side-effect function without changing data or type.
 
template<typename OpClass , ComputeData OutputType = DataType>
FluentExecutor< Executor, OutputType > then ()
 Chain an anonymous operation instance by type.
 
template<typename OpClass , ComputeData OutputType = DataType>
FluentExecutor< Executor, OutputType > then (const std::string &name)
 Chain a named operation fetched from the executor's pool.
 
Datum< DataType > to_io () const
 Return the result Datum with execution history appended to metadata.
 
template<typename OpClass >
FluentExecutorwhen (bool condition)
 Execute an operation conditionally on a boolean flag.
 
template<typename OpClass , typename Pred >
requires std::predicate<Pred, const DataType&>
FluentExecutorwhen (Pred &&predicate)
 Execute an operation conditionally on a predicate over the raw data.
 

Private Member Functions

void record_error (const std::string &err)
 

Private Attributes

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

Friends

template<typename E , ComputeData U>
class FluentExecutor
 

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 executor that exposes execute<OpClass, InputType, OutputType>(Datum<InputType>) and execute_named<OpClass, InputType, OutputType>(name, Datum<InputType>).

Internal storage is always Datum<DataType>, preserving container references and structural metadata across every link in the chain. Entry points (constructors, make_fluent) accept raw DataType as a convenience and wrap it immediately.

Key Features:

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

Usage:

auto result = matrix->with(input_datum)
.then<SegmentOp>("segment")
.then<AttributeOp>("attribute")
.then<SortOp>("sort")
.get();
const DataType & get() const
Get the final raw result by const reference.

Definition at line 39 of file OperationChain.hpp.


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