From 2ea2d38cb21a8cf07ea4dd7a70a9f57e35ebf5cd Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Sun, 24 Dec 2017 04:48:07 +0100 Subject: [PATCH] Navigator: build iterator front-end based on the new TreeExploer capabilities ...but not yet switched into the main LocationQuery interface, because that would also break the existing implementation; recasting this implementation is the next step to do.... --- src/gui/interact/ui-coord-resolver.hpp | 23 +++++++++--- src/lib/iter-tree-explorer.hpp | 20 +++++++---- tests/library/iter-tree-explorer-test.cpp | 6 +++- wiki/thinkPad.ichthyo.mm | 43 +++++++++++++++-------- 4 files changed, 66 insertions(+), 26 deletions(-) diff --git a/src/gui/interact/ui-coord-resolver.hpp b/src/gui/interact/ui-coord-resolver.hpp index 751f24f33..78a0c1527 100644 --- a/src/gui/interact/ui-coord-resolver.hpp +++ b/src/gui/interact/ui-coord-resolver.hpp @@ -101,13 +101,28 @@ namespace interact { virtual TreeStructureNavigator* expandChildren() const =0; + /** build a Lumiera Forward Iterator as front-end for `*this`. + * @return copyable iterator front-end handle, which allows to retrieve once all values + * yielded by this IterSource. The front-end does _not take ownership_ of this object. + * @note the generated iterator is preconfigured to allow for _"child expansion"_, thereby + * calling through the virtual API function expandChildren() + */ + auto + buildIterator () + { + return lib::treeExplore (*this) + .expand([](TreeStructureNavigator& parent){ return parent.expandChildren(); }); + } + + /** build a Lumiera Forward Iterator as front-end and managing Handle for a heap allocated + * TreeStructureNavigator or subclass. The provided pointer is assumed to point to heap allocated + * storage, which will be owned by the generated iterator. + */ static auto buildIterator (TreeStructureNavigator* source) { - return lib::treeExplore( - lib::IterSource::build (source)) - .expand([](Literal id){ return lib::IterSource::build ( - ((TreeStructureNavigator*)nullptr)->expandChildren() ); }); + return lib::treeExplore (source) + .expand([](TreeStructureNavigator& parent){ return parent.expandChildren(); }); } }; diff --git a/src/lib/iter-tree-explorer.hpp b/src/lib/iter-tree-explorer.hpp index c26e859d5..e79ebc928 100644 --- a/src/lib/iter-tree-explorer.hpp +++ b/src/lib/iter-tree-explorer.hpp @@ -290,18 +290,21 @@ namespace lib { class IterSourceIter : public ISO::iterator { + using Iterator = typename ISO::iterator; + public: IterSourceIter() =default; // standard copy operations /** link to existing IterSource (without memory management) */ IterSourceIter (ISO& externalSource) - : ISO::iterator{ISO::build (externalSource)} + : Iterator{ISO::build (externalSource)} { } /** own and manage a heap allocated IterSource */ - IterSourceIter (ISO* heap_allocated_IterSource) - : ISO::iterator{ISO::build (heap_allocated_IterSource)} + IterSourceIter (ISO* heapObject) + : Iterator{heapObject? ISO::build (heapObject) + : Iterator()} { } using Source = ISO; @@ -417,12 +420,15 @@ namespace lib { using SrcVal = typename ISO::value_type; }; + template + struct _DecoratorTraits, ISO>>> + : _DecoratorTraits + { }; + template struct _DecoratorTraits, ISO>>> - { - using SrcIter = iter_explorer::IterSourceIter; - using SrcVal = typename ISO::value_type; - }; + : _DecoratorTraits + { }; }//(End) TreeExplorer traits diff --git a/tests/library/iter-tree-explorer-test.cpp b/tests/library/iter-tree-explorer-test.cpp index 205cd73e7..8875adc31 100644 --- a/tests/library/iter-tree-explorer-test.cpp +++ b/tests/library/iter-tree-explorer-test.cpp @@ -900,6 +900,10 @@ namespace test{ treeExplore(new VerySpecivicIter{7}))); + // missing source detected + PrivateSource* niente = nullptr; + CHECK (isnil (treeExplore(niente))); + // attach to an IterSource living here in local scope... VerySpecivicIter vsit{5}; @@ -918,7 +922,7 @@ namespace test{ CHECK (4 == vsit.currentVal()); CHECK (0 == ii.depth()); - ii.expandChildren(); // note: calls through source's VTable to invoke VerySpecificIter::expandChildren() + ii.expandChildren(); // note: calls through source's VTable to invoke VerySpecificIter::expandChildren() CHECK (1 == ii.depth()); CHECK (2 == *ii); diff --git a/wiki/thinkPad.ichthyo.mm b/wiki/thinkPad.ichthyo.mm index 1bd5d100d..07e410c16 100644 --- a/wiki/thinkPad.ichthyo.mm +++ b/wiki/thinkPad.ichthyo.mm @@ -977,7 +977,7 @@ - + @@ -7603,7 +7603,7 @@ - + @@ -7612,7 +7612,8 @@ - + + @@ -7940,6 +7941,20 @@ + + + + + + +

+ ...mal sehen, ob wir jemals daran anstoßen... +

+ + +
+ +
@@ -7999,9 +8014,9 @@ - + - + @@ -8009,7 +8024,7 @@ - + @@ -8021,7 +8036,7 @@ - + @@ -8062,7 +8077,7 @@ - + @@ -8084,7 +8099,7 @@ - + @@ -8093,8 +8108,8 @@ - - + + @@ -8121,9 +8136,9 @@ - + - + @@ -17000,7 +17015,7 @@ - +