From 75a7ecb6b35df09efcac35b25b873cbe3ae3e32c Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Mon, 23 Oct 2017 03:17:18 +0200 Subject: [PATCH] LocationQuery: draft simple coverage check ugly while loop.... maybe recursive? --- src/gui/interact/gen-node-location-query.hpp | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/gui/interact/gen-node-location-query.hpp b/src/gui/interact/gen-node-location-query.hpp index d0d3830a1..6336f4505 100644 --- a/src/gui/interact/gen-node-location-query.hpp +++ b/src/gui/interact/gen-node-location-query.hpp @@ -124,16 +124,23 @@ namespace interact { } - /** evaluate to what extent a UIcoord spec matches the structure given as GenNode tree - */ + /** evaluate to what extent a UIcoord spec matches the structure given as GenNode tree */ virtual size_t determineCoverage (UICoord const& path) { - UNIMPLEMENTED ("resolve explicitly given coordinates against GenNode tree"); + size_t depth = 0; + const Rec* pos = &tree_; + const char* pathElm; + while (path.isPresent(depth) and + pos->hasAttribute(pathElm = path[depth])) + { + ++depth; + pos = &pos->get(pathElm).data.get(); + } + return depth; } - /** get the sequence child IDs at a designated position in the backing GenNode tree - */ + /** get the sequence of child IDs at a designated position in the backing GenNode tree */ virtual ChildIter getChildren (UICoord const& path, size_t pos) {