ChainSearch: now actually build the processing pipeline in the ctor

..this resolves the most challenging part of the construction work;
we use the static helper functions to infer a type and construct a suitable
processing pipeline and we invoke the same helper to initialise the base class
in the ctor.

Incidentally... we can now drop all the placeholder stubs,
since we now inherit the full iterator and child explorer API.
The test now starts actually to work... we get spam and sausage!

TODO: now actually fill in the expand functor such as to pick the
concrete filter step in the chain from a sequence of preconfigured
filter bindings
This commit is contained in:
Fischlurch 2018-09-07 03:02:41 +02:00
parent 9b0937bc63
commit d398177a71
3 changed files with 39 additions and 56 deletions

View file

@ -77,16 +77,21 @@ namespace iter {
}
/**
* @internal implementation for....
* @internal helper to rebind on inferred types.
* @remark we use the TreeExplorer framework to assemble the processing pipeline
* from suitable building blocks configured with some lambdas. However, we
* also want to _inherit_ from this filter pipeline, so to expose the typical
* iterator operations without much ado. Thus we use some (static) helper function
* templates, instantiate them with the actual source data iterator and pick up
* the inferred type.
*/
template<class SRC>
class _IterChainSetup
struct _IterChainSetup
{
using Filter = decltype( buildSearchFilter (std::declval<SRC>()) );
using StepFunctor = typename iter_explorer::_BoundFunctor<Filter(Filter const&), Filter>::Functor;
public:
using Pipeline = decltype( buildExplorer (std::declval<SRC>(), std::declval<StepFunctor>()) );
};
@ -108,40 +113,25 @@ namespace iter {
class IterChainSearch
: public _IterChainSetup<SRC>::Pipeline
{
using _Base = typename _IterChainSetup<SRC>::Pipeline;
// using _Parent = IterStateWrapper<typename _Core::value_type, _Core>;
using _Trait = _IterChainSetup<SRC>;
using _Base = typename _Trait::Pipeline;
using Filter = typename _Trait::Filter;
using Step = typename _Trait::StepFunctor;
public:
using DebugPipeline = _Base;
// IterChainSearch() =default;
// IterChainSearch (IterChainSearch&&) =default;
// IterChainSearch (IterChainSearch const&) =default;
// IterChainSearch& operator= (IterChainSearch&&) =default;
// IterChainSearch& operator= (IterChainSearch const&) =default;
using _Base::_Base;
// template<class CON>
// explicit
// IterChainSearch (CON& container)
//// : _Parent(_Core(container.begin(), container.end()))
// { }
//
// IterChainSearch (IT&& begin, IT&& end)
//// : _Parent(_Core(std::forward<IT>(begin), std::forward<IT>(end)))
// { }
template<class SEQ>
explicit
IterChainSearch (SEQ&& srcData)
: _Base{move (buildExplorer (forward<SEQ> (srcData)
,Step{[this](Filter const& curr){ return configureFilterChain(curr); }}))}
{ }
operator bool() const
{
UNIMPLEMENTED ("solution test");
}
bool
empty() const
{
return not(*this);
}
/** */
IterChainSearch&&
@ -158,21 +148,13 @@ namespace iter {
return move(*this);
}
/////////////////////////TODO dummy placeholder code. Replace by real iterator access
string&
operator*() const
private:
Filter
configureFilterChain (Filter const& currentFilterState)
{
static string boo{"bääääh"};
return boo;
uint depth = this->depth();
return Filter{}; /////TODO empty filter means recursion end
}
IterChainSearch&
operator++()
{
return *this;
}
/////////////////////////TODO dummy placeholder code. Replace by real iterator access
};
@ -192,11 +174,7 @@ namespace iter {
inline auto
chainSearch (SRC&& srcData)
{
// using SrcIter = typename _DecoratorTraits<IT>::SrcIter;
// using Base = iter_explorer::BaseAdapter<SrcIter>;
return IterChainSearch<SRC>();
// return TreeExplorer<Base> (std::forward<IT> (srcSeq));
return IterChainSearch<SRC>{forward<SRC> (srcData)};
}

View file

@ -116,6 +116,9 @@ namespace test{
SHOW_TYPE (Searcher::pointer);
// TypeDebugger<Searcher::reference> guggi; // --> std::__cxx11::basic_string<char> const&
cout << "search[0]=" <<*search<<endl;
++search;
cout << "search[1]=" <<*search<<endl;
///////////////////////////////////////////////////TODO WIP
CHECK (search);
CHECK (not isnil(search));

View file

@ -31215,7 +31215,8 @@
<icon BUILTIN="flag-yellow"/>
</node>
</node>
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1536018862802" ID="ID_1044555993" MODIFIED="1536018873126" TEXT="abgeleiteten Frame konstruieren">
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1536018862802" ID="ID_1044555993" MODIFIED="1536281910775" TEXT="abgeleiteten Frame konstruieren">
<linktarget COLOR="#65a7b1" DESTINATION="ID_1044555993" ENDARROW="Default" ENDINCLINATION="200;225;" ID="Arrow_ID_575633930" SOURCE="ID_1532889609" STARTARROW="None" STARTINCLINATION="158;0;"/>
<icon BUILTIN="flag-yellow"/>
</node>
</node>
@ -31288,7 +31289,7 @@
</node>
<node CREATED="1536185340920" ID="ID_1706168706" MODIFIED="1536185362297" TEXT="also: konstruiere Pipeline mit Filter"/>
<node CREATED="1536185364045" ID="ID_301562283" MODIFIED="1536185381295" TEXT="dann: Filter -&gt; Filter als Funktor vorgeben"/>
<node COLOR="#338800" CREATED="1536194368432" ID="ID_665607293" MODIFIED="1536273432151" TEXT="kniffelig in der Praxis">
<node COLOR="#338800" CREATED="1536194368432" FOLDED="true" ID="ID_665607293" MODIFIED="1536274950954" TEXT="kniffelig in der Praxis">
<icon BUILTIN="smiley-angry"/>
<node CREATED="1536194407802" ID="ID_752443094" MODIFIED="1536194421332" TEXT="der &quot;Filter&quot;-Typ ist in einen TreeExplorer gewrappt"/>
<node CREATED="1536194422544" ID="ID_1594827200" MODIFIED="1536194440618" TEXT="konkret ist der Quell-Typ aber nur ein IterableDecorator"/>
@ -31429,19 +31430,20 @@
</node>
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1536018923378" ID="ID_1163666446" MODIFIED="1536018929138" TEXT="Pipeline konstruieren">
<icon BUILTIN="flag-yellow"/>
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1536018931433" ID="ID_1532889609" MODIFIED="1536018943472" TEXT="treeExplorer-Konfiguration">
<icon BUILTIN="flag-yellow"/>
</node>
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1536115788134" ID="ID_1444917457" MODIFIED="1536121333262" TEXT="Problem: Basis-Typ inferieren">
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1536018931433" ID="ID_1532889609" MODIFIED="1536281924138" TEXT="treeExplorer-Konfiguration">
<arrowlink COLOR="#65a7b1" DESTINATION="ID_1044555993" ENDARROW="Default" ENDINCLINATION="200;225;" ID="Arrow_ID_575633930" STARTARROW="None" STARTINCLINATION="158;0;"/>
<icon BUILTIN="pencil"/>
</node>
<node COLOR="#338800" CREATED="1536115788134" ID="ID_1444917457" MODIFIED="1536281847097" TEXT="Problem: Basis-Typ inferieren">
<icon BUILTIN="button_ok"/>
<node COLOR="#338800" CREATED="1536115842002" ID="ID_1601482334" MODIFIED="1536121336222" TEXT="resultiert aus treeExplorer-Aufruf">
<icon BUILTIN="button_ok"/>
</node>
<node COLOR="#338800" CREATED="1536121365113" ID="ID_1114285918" MODIFIED="1536121373905" TEXT="const STL container unterst&#xfc;tzen">
<icon BUILTIN="button_ok"/>
</node>
<node BACKGROUND_COLOR="#eee5c3" COLOR="#990000" CREATED="1536115852336" ID="ID_1044191557" MODIFIED="1536115863616" TEXT="mu&#xdf; aber geeignete Funktoren binden">
<icon BUILTIN="flag-yellow"/>
<node COLOR="#338800" CREATED="1536115852336" ID="ID_1044191557" MODIFIED="1536281849860" TEXT="mu&#xdf; aber geeignete Funktoren binden">
<icon BUILTIN="button_ok"/>
</node>
</node>
</node>