TreeExplorer: refactor Transformer to employ the improved wrapping style
...step by step switch over to the new usage pattern. Transformer should be the blueprint for all other functor usages. The reworked solutions behaves as expected; we see two functor invocations; the outer functor, which does the argument adaptation, is allocated in heap memory
This commit is contained in:
parent
a91025bfe0
commit
1e657acbff
4 changed files with 43 additions and 14 deletions
|
|
@ -793,32 +793,31 @@ namespace lib {
|
|||
* is adapted in a similar way as the "expand functor", so to detect and convert the
|
||||
* expected input on invocation.
|
||||
*/
|
||||
template<class SRC, class FUN>
|
||||
template<class SRC, class RES>
|
||||
class Transformer
|
||||
: public SRC
|
||||
{
|
||||
static_assert(can_IterForEach<SRC>::value, "Lumiera Iterator required as source");
|
||||
using _Traits = _FunTraits<FUN,SRC>;
|
||||
using Res = typename _Traits::Res;
|
||||
|
||||
using TransformFunctor = typename _Traits::Functor;
|
||||
using TransformedItem = wrapper::ItemWrapper<Res>;
|
||||
using TransformFunctor = function<RES(SRC&)>;
|
||||
using TransformedItem = wrapper::ItemWrapper<RES>;
|
||||
|
||||
TransformFunctor trafo_;
|
||||
TransformedItem treated_;
|
||||
|
||||
public:
|
||||
using value_type = typename meta::TypeBinding<Res>::value_type;
|
||||
using reference = typename meta::TypeBinding<Res>::reference;
|
||||
using pointer = typename meta::TypeBinding<Res>::pointer;
|
||||
using value_type = typename meta::TypeBinding<RES>::value_type;
|
||||
using reference = typename meta::TypeBinding<RES>::reference;
|
||||
using pointer = typename meta::TypeBinding<RES>::pointer;
|
||||
|
||||
|
||||
Transformer() =default;
|
||||
// inherited default copy operations
|
||||
|
||||
template<typename FUN>
|
||||
Transformer (SRC&& dataSrc, FUN&& transformFunctor)
|
||||
: SRC{move (dataSrc)}
|
||||
, trafo_{forward<FUN> (transformFunctor)}
|
||||
, trafo_{_FunTraits<FUN,SRC>::template adaptFunctor<SRC> (forward<FUN> (transformFunctor))}
|
||||
{ }
|
||||
|
||||
|
||||
|
|
@ -1437,7 +1436,9 @@ namespace lib {
|
|||
auto
|
||||
transform (FUN&& transformFunctor)
|
||||
{
|
||||
using ResCore = iter_explorer::Transformer<SRC, FUN>;
|
||||
using Product = typename iter_explorer::_FunTraits<FUN,SRC>::Res;
|
||||
|
||||
using ResCore = iter_explorer::Transformer<SRC, Product>;
|
||||
using ResIter = typename _DecoratorTraits<ResCore>::SrcIter;
|
||||
|
||||
return TreeExplorer<ResIter> (ResCore {move(*this), forward<FUN>(transformFunctor)});
|
||||
|
|
|
|||
|
|
@ -185,11 +185,13 @@ namespace wrapper {
|
|||
|
||||
explicit
|
||||
ItemWrapper(TY const& o)
|
||||
: created_(false)
|
||||
{
|
||||
build (o);
|
||||
}
|
||||
explicit
|
||||
ItemWrapper(TY && ro)
|
||||
: created_(false)
|
||||
{
|
||||
build (std::move(ro));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -517,6 +517,7 @@ namespace test{
|
|||
.transform(multiply)
|
||||
;
|
||||
|
||||
CHECK (14 == *ii);
|
||||
CHECK (14 == *ii);
|
||||
++ii;
|
||||
CHECK (12 == *ii);
|
||||
|
|
|
|||
|
|
@ -31200,8 +31200,8 @@
|
|||
</node>
|
||||
</node>
|
||||
</node>
|
||||
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1536409302285" ID="ID_913930564" MODIFIED="1536409311669" TEXT="extrem komplexe Typen">
|
||||
<icon BUILTIN="flag-yellow"/>
|
||||
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1536409302285" ID="ID_913930564" MODIFIED="1536455982782" TEXT="extrem komplexe Typen">
|
||||
<icon BUILTIN="pencil"/>
|
||||
<node CREATED="1536409316172" ID="ID_1468538186" MODIFIED="1536409340127" TEXT="Call-Traces sind nahezu unlesbar">
|
||||
<richcontent TYPE="NOTE"><html>
|
||||
<head>
|
||||
|
|
@ -31318,8 +31318,8 @@
|
|||
<node CREATED="1536451303308" ID="ID_1343290323" MODIFIED="1536451313142" TEXT="man kann sie mit dem Funktor aufrufen -> Sig"/>
|
||||
<node CREATED="1536451313778" ID="ID_439029617" MODIFIED="1536451336475" TEXT="man kann sie mit Sig aufrufen -> Arg, Ret"/>
|
||||
</node>
|
||||
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1536451345998" ID="ID_1853688774" MODIFIED="1536451360667" TEXT="Funktor-Konstruktor-Funktion">
|
||||
<icon BUILTIN="pencil"/>
|
||||
<node COLOR="#338800" CREATED="1536451345998" ID="ID_1853688774" MODIFIED="1536453357128" TEXT="Funktor-Konstruktor-Funktion">
|
||||
<icon BUILTIN="button_ok"/>
|
||||
<node CREATED="1536451365731" ID="ID_552359289" MODIFIED="1536451394878" TEXT="für Aufruf aus dem Konstruktor-Kontext">
|
||||
<richcontent TYPE="NOTE"><html>
|
||||
<head>
|
||||
|
|
@ -31358,6 +31358,31 @@
|
|||
</richcontent>
|
||||
</node>
|
||||
</node>
|
||||
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1536453317787" ID="ID_975974776" MODIFIED="1536453363634" TEXT="integrieren in...">
|
||||
<icon BUILTIN="pencil"/>
|
||||
<node COLOR="#338800" CREATED="1536453326978" ID="ID_1071395763" MODIFIED="1536453367022" TEXT="Transformer">
|
||||
<icon BUILTIN="button_ok"/>
|
||||
<node COLOR="#338800" CREATED="1536455906647" ID="ID_603515158" MODIFIED="1536455919470" TEXT="im Debugger beobachtet">
|
||||
<icon BUILTIN="button_ok"/>
|
||||
</node>
|
||||
<node CREATED="1536455920701" ID="ID_1992285034" MODIFIED="1536455938637" TEXT="äußerer Funktor liegt im Heap">
|
||||
<icon BUILTIN="smily_bad"/>
|
||||
</node>
|
||||
<node CREATED="1536455947209" ID="ID_1054869208" MODIFIED="1536455959131" TEXT="innerer Funktor ist aber direkt dort eingebettet"/>
|
||||
</node>
|
||||
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1536453368676" ID="ID_1560078731" MODIFIED="1536453372397" TEXT="Filter">
|
||||
<icon BUILTIN="flag-yellow"/>
|
||||
</node>
|
||||
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1536453373605" ID="ID_1544724438" MODIFIED="1536453376828" TEXT="MutableFilter">
|
||||
<icon BUILTIN="flag-yellow"/>
|
||||
</node>
|
||||
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1536453408359" ID="ID_63715215" MODIFIED="1536453414663" TEXT="Anpassen an Expander">
|
||||
<icon BUILTIN="flag-yellow"/>
|
||||
</node>
|
||||
</node>
|
||||
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1536453419141" ID="ID_564310637" MODIFIED="1536453427198" TEXT="vereinfachen">
|
||||
<icon BUILTIN="flag-yellow"/>
|
||||
</node>
|
||||
</node>
|
||||
</node>
|
||||
</node>
|
||||
|
|
|
|||
Loading…
Reference in a new issue