![]() |
Lumiera 0.pre.04
»edit your freedom«
|
#include "lib/iter-explorer.hpp"
Decorator for IterExplorer adding the ability to "expand children". The expandChildren() operation is the key element of a depth-first evaluation: it consumes one element and performs a preconfigured expansion functor on that element to yield its "children". These are given in the form of another iterator, which needs to be compatible to the source iterator ("compatibility" boils down to both iterators yielding a compatible value type). Now, this sequence of children effectively replaces the expanded source element in the overall resulting sequence; which means, the nested sequence was flattened into the results. Since this expand() operation can again be invoked on the results, the implementation of such an evaluation requires a stack datastructure, so the nested iterator from each expand() invocation can be pushed to become the new active source for iteration. Thus the primary purpose of this Expander (decorator) is to integrate those "nested child iterators" seamlessly into the overall iteration process; once a child iterator is exhausted, it will be popped and iteration continues with the previous child iterator or finally with the source iterator wrapped by this decorator. The source pipeline is only pulled once the expanded children are exhausted.
| SRC | the wrapped source iterator, typically a IterExplorer or nested decorator. |
| FUN | the concrete type of the functor passed. Will be dissected to find the signature |
Definition at line 554 of file iter-explorer.hpp.
Public Types | |
| using | YieldRes = _Trait::YieldRes |
| using | value_type = _Trait::value_type |
| using | reference = _Trait::reference |
| using | pointer = _Trait::pointer |
Public Member Functions | |
| Expander ()=default | |
| template<typename FUN > | |
| Expander (SRC &&parentExplorer, FUN &&expandFunctor) | |
| void | expandChildren () |
| core operation: expand current head element | |
| size_t | depth () const |
| diagnostics: current level of nested child expansion | |
| void | rootCurrent () |
| lock into the current child sequence. | |
| bool | checkPoint () const |
| YieldRes | yield () const |
| void | iterNext () |
Protected Member Functions | |
| bool | hasChildren () const |
| ResIter & | accessCurrentChildIter () |
| void | dropExhaustedChildren () |
Private Types | |
| using | _Trait = _ExpanderTraits< SRC, RES > |
| using | ResIter = _Trait::ResIter |
| using | RootExpandFunctor = function< RES(SRC &)> |
| using | ChldExpandFunctor = function< RES(ResIter &)> |
Private Member Functions | |
| bool | invariant () const |
| void | incrementCurrent () |
Private Attributes | |
| RootExpandFunctor | expandRoot_ |
| ChldExpandFunctor | expandChild_ |
| IterStack< ResIter > | expansions_ |
|
default |
|
inline |
Definition at line 574 of file iter-explorer.hpp.
|
private |
Definition at line 559 of file iter-explorer.hpp.
|
private |
Definition at line 560 of file iter-explorer.hpp.
|
private |
Definition at line 561 of file iter-explorer.hpp.
|
private |
Definition at line 562 of file iter-explorer.hpp.
| using YieldRes = _Trait::YieldRes |
Definition at line 624 of file iter-explorer.hpp.
| using value_type = _Trait::value_type |
Definition at line 625 of file iter-explorer.hpp.
| using reference = _Trait::reference |
Definition at line 626 of file iter-explorer.hpp.
| using pointer = _Trait::pointer |
Definition at line 627 of file iter-explorer.hpp.
|
inline |
core operation: expand current head element
Definition at line 585 of file iter-explorer.hpp.
References Expander< SRC, RES >::checkPoint(), Expander< SRC, RES >::expandChild_, Expander< SRC, RES >::expandRoot_, Expander< SRC, RES >::expansions_, Expander< SRC, RES >::hasChildren(), Expander< SRC, RES >::invariant(), Expander< SRC, RES >::iterNext(), and IterStack< TY >::push().
Here is the call graph for this function:
|
inline |
diagnostics: current level of nested child expansion
Definition at line 602 of file iter-explorer.hpp.
References Expander< SRC, RES >::expansions_, and IterStack< TY >::size().
Referenced by Expander< SRC, RES >::hasChildren().
Here is the call graph for this function:
Here is the caller graph for this function:
|
inline |
lock into the current child sequence.
This special feature turns the current child sequence into the new root, thereby discarding everything else in the expansions stack, including the original root sequence.
Definition at line 613 of file iter-explorer.hpp.
References IterStack< TY >::clear(), Expander< SRC, RES >::expansions_, and Expander< SRC, RES >::hasChildren().
Here is the call graph for this function:
|
inline |
Definition at line 631 of file iter-explorer.hpp.
References Expander< SRC, RES >::hasChildren(), and Expander< SRC, RES >::invariant().
Referenced by Expander< SRC, RES >::expandChildren().
Here is the call graph for this function:
Here is the caller graph for this function:
|
inline |
Definition at line 640 of file iter-explorer.hpp.
References Expander< SRC, RES >::expansions_, and Expander< SRC, RES >::hasChildren().
Here is the call graph for this function:
|
inline |
Definition at line 647 of file iter-explorer.hpp.
References Expander< SRC, RES >::dropExhaustedChildren(), Expander< SRC, RES >::incrementCurrent(), and Expander< SRC, RES >::invariant().
Referenced by Expander< SRC, RES >::expandChildren().
Here is the call graph for this function:
Here is the caller graph for this function:
|
inlineprivate |
Definition at line 656 of file iter-explorer.hpp.
References Expander< SRC, RES >::expansions_, Expander< SRC, RES >::hasChildren(), and IterStateWrapper< ST, T >::isValid().
Referenced by Expander< SRC, RES >::checkPoint(), Expander< SRC, RES >::dropExhaustedChildren(), Expander< SRC, RES >::expandChildren(), and Expander< SRC, RES >::iterNext().
Here is the call graph for this function:
Here is the caller graph for this function:
|
inlineprivate |
Definition at line 663 of file iter-explorer.hpp.
References Expander< SRC, RES >::hasChildren().
Referenced by Expander< SRC, RES >::dropExhaustedChildren(), and Expander< SRC, RES >::iterNext().
Here is the call graph for this function:
Here is the caller graph for this function:
|
inlineprotected |
Definition at line 674 of file iter-explorer.hpp.
References Expander< SRC, RES >::depth().
Referenced by Expander< SRC, RES >::accessCurrentChildIter(), Expander< SRC, RES >::checkPoint(), Expander< SRC, RES >::expandChildren(), Expander< SRC, RES >::incrementCurrent(), Expander< SRC, RES >::invariant(), Expander< SRC, RES >::rootCurrent(), and Expander< SRC, RES >::yield().
Here is the call graph for this function:
Here is the caller graph for this function:
|
inlineprotected |
accessor for downstream layers to allow close collaboration
Definition at line 681 of file iter-explorer.hpp.
References Expander< SRC, RES >::expansions_, and Expander< SRC, RES >::hasChildren().
Here is the call graph for this function:
|
inlineprotected |
Definition at line 688 of file iter-explorer.hpp.
References Expander< SRC, RES >::expansions_, Expander< SRC, RES >::incrementCurrent(), and Expander< SRC, RES >::invariant().
Referenced by Expander< SRC, RES >::iterNext().
Here is the call graph for this function:
Here is the caller graph for this function:
|
private |
Definition at line 564 of file iter-explorer.hpp.
Referenced by Expander< SRC, RES >::expandChildren().
|
private |
Definition at line 565 of file iter-explorer.hpp.
Referenced by Expander< SRC, RES >::expandChildren().
Definition at line 567 of file iter-explorer.hpp.
Referenced by Expander< SRC, RES >::accessCurrentChildIter(), Expander< SRC, RES >::depth(), Expander< SRC, RES >::dropExhaustedChildren(), Expander< SRC, RES >::expandChildren(), Expander< SRC, RES >::invariant(), Expander< SRC, RES >::rootCurrent(), and Expander< SRC, RES >::yield().
Inheritance diagram for Expander< SRC, RES >:
Collaboration diagram for Expander< SRC, RES >: