From c007fbda43bd6fb88015d4687a3cc8474a857ae6 Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Tue, 26 Dec 2017 03:51:02 +0100 Subject: [PATCH] Navigator: res-structure inheritance chain to allow passing current position we need to layer our Navigator implementation on top, since this object needs to capture a reference to the "current position". This is necessary to be able to derive the child position by extending and then to form a child navigator -- which is the essence of implementing expandChildren() --- src/gui/interact/gen-node-location-query.hpp | 35 ++++++++++++++------ 1 file changed, 25 insertions(+), 10 deletions(-) diff --git a/src/gui/interact/gen-node-location-query.hpp b/src/gui/interact/gen-node-location-query.hpp index e42b2cc26..33f5bc4d0 100644 --- a/src/gui/interact/gen-node-location-query.hpp +++ b/src/gui/interact/gen-node-location-query.hpp @@ -156,7 +156,8 @@ namespace interact { % depth % path ); - return childSequence(node, depth); + return TreeStructureNavigator::buildIterator( + childNavigator (node, depth)); } private: @@ -217,34 +218,48 @@ namespace interact { } + template class GenNodeNavigator - : public TreeStructureNavigator + : public PAR { + Rec const& pos_; + size_t depth_; + virtual TreeStructureNavigator* expandChildren() const override { UNIMPLEMENTED ("build an iterator to yield the children. This requires to remember who we are ourselves."); } + + + public: + template + GenNodeNavigator(Rec const& node, size_t depth, IT&& rawChildIter) + : PAR{forward (rawChildIter)} + , pos_{node} + , depth_{depth} + { } }; template - static auto - expandableIterSource(IT && rawIterator) + static TreeStructureNavigator* + buildNavigator (Rec const& node, size_t depth, IT && rawIterator) { - return TreeStructureNavigator::buildIterator( - new lib::WrappedLumieraIter {forward (rawIterator)}); + return new GenNodeNavigator< + lib::WrappedLumieraIter> {node, depth, forward (rawIterator)}; } - static ChildIter - childSequence (Rec const& node, size_t& depth) + static TreeStructureNavigator* + childNavigator (Rec const& node, size_t depth) { //////////////////////////////////////////////////////////////////////////TICKET #1113 : capturing the string into the global Symbol table becomes obsolete, once GenNode exposes Literal as ID auto internedString = [](string const& id) -> Literal { return Symbol{id}; }; - return depth==UIC_PERSP? expandableIterSource(singleValIterator (internedString (node.getType()))) - : expandableIterSource(transformIterator (node.keys(), internedString)); + return depth==UIC_PERSP? buildNavigator (node, depth, singleValIterator (internedString (node.getType()))) + : buildNavigator (node, depth, transformIterator (node.keys(), internedString)); } };