From d398177a714d098e364335c1d4759077a6e84cd4 Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Fri, 7 Sep 2018 03:02:41 +0200 Subject: [PATCH] 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 --- src/lib/iter-chain-search.hpp | 74 +++++++++--------------- tests/library/iter-chain-search-test.cpp | 3 + wiki/thinkPad.ichthyo.mm | 18 +++--- 3 files changed, 39 insertions(+), 56 deletions(-) diff --git a/src/lib/iter-chain-search.hpp b/src/lib/iter-chain-search.hpp index 353f73c86..e40b8e3a8 100644 --- a/src/lib/iter-chain-search.hpp +++ b/src/lib/iter-chain-search.hpp @@ -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 _IterChainSetup + struct _IterChainSetup { using Filter = decltype( buildSearchFilter (std::declval()) ); using StepFunctor = typename iter_explorer::_BoundFunctor::Functor; - public: using Pipeline = decltype( buildExplorer (std::declval(), std::declval()) ); }; @@ -108,40 +113,25 @@ namespace iter { class IterChainSearch : public _IterChainSetup::Pipeline { - using _Base = typename _IterChainSetup::Pipeline; -// using _Parent = IterStateWrapper; + using _Trait = _IterChainSetup; + 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 -// explicit -// IterChainSearch (CON& container) -//// : _Parent(_Core(container.begin(), container.end())) -// { } -// -// IterChainSearch (IT&& begin, IT&& end) -//// : _Parent(_Core(std::forward(begin), std::forward(end))) -// { } + template + explicit + IterChainSearch (SEQ&& srcData) + : _Base{move (buildExplorer (forward (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::SrcIter; -// using Base = iter_explorer::BaseAdapter; - - return IterChainSearch(); -// return TreeExplorer (std::forward (srcSeq)); + return IterChainSearch{forward (srcData)}; } diff --git a/tests/library/iter-chain-search-test.cpp b/tests/library/iter-chain-search-test.cpp index eb6f82f11..d7ff544a3 100644 --- a/tests/library/iter-chain-search-test.cpp +++ b/tests/library/iter-chain-search-test.cpp @@ -116,6 +116,9 @@ namespace test{ SHOW_TYPE (Searcher::pointer); // TypeDebugger guggi; // --> std::__cxx11::basic_string const& + cout << "search[0]=" <<*search< - + + @@ -31288,7 +31289,7 @@ - + @@ -31429,19 +31430,20 @@ - - - - + + + + + - - + +