Lumiera  0.pre.03
»edit your freedom«
Transformer< SRC, RES > Class Template Reference

#include "lib/iter-explorer.hpp"

Description

template<class SRC, class RES>
class lib::iter_explorer::Transformer< SRC, RES >

Decorator for IterExplorer to map a transformation function on all results. The transformation function is invoked on demand, and only once per item to be treated, storing the treated result into an universal value holder buffer. The given functor is adapted in a similar way as the "expand functor", so to detect and convert the expected input on invocation.

Note
the result-type of the #yield() function must be reference, even when the TransformFunctor produces a value; otherwise we can not provide a safe operator-> on any iterator downstream. This is also the reason why the ItemWrapper is necessary, precisely because we want to support functions producing a value; it provides a safe location for this value to persist.
Warning
handling a transformer function which exposes references can be dangerous. For this reason, Transformer attempts to »dis-engage« on each copy / assignment, in order to provoke a re-invocation of the transformer function, which hopefully picks up references to the copied / moved / swapped location. Be careful though!

Definition at line 782 of file iter-explorer.hpp.

Public Types

using pointer = typename meta::ValueTypeBinding< RES >::pointer
 
using reference = typename meta::ValueTypeBinding< RES >::reference
 
using value_type = typename meta::ValueTypeBinding< RES >::value_type
 

Public Member Functions

template<typename FUN >
 Transformer (SRC &&dataSrc, FUN &&transformFunctor)
 
 Transformer (Transformer const &o)
 
 Transformer (Transformer &&o)
 
bool checkPoint () const
 
void expandChildren ()
 refresh state when other layers manipulate the source sequence More...
 
void iterNext ()
 
Transformeroperator= (Transformer changed)
 
reference yield () const
 

Friends

void swap (Transformer &t1, Transformer &t2)
 

Private Types

using TransformedItem = wrapper::ItemWrapper< RES >
 
using TransformFunctor = function< RES(SRC &)>
 

Private Member Functions

reference invokeTransformation ()
 
SRC & srcIter () const
 

Private Attributes

TransformFunctor trafo_
 
TransformedItem treated_
 

Member Function Documentation

◆ expandChildren()

void expandChildren ( )
inline

refresh state when other layers manipulate the source sequence

Remarks
expansion replaces the current element by a sequence of "child" elements. Since we cache our transformation, we need to ensure possibly new source elements get processed

Definition at line 838 of file iter-explorer.hpp.

+ Inheritance diagram for Transformer< SRC, RES >:
+ Collaboration diagram for Transformer< SRC, RES >:

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