From 4de2ea2abecff17092fa554e74358ea8ce1e4b0c Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Wed, 4 Apr 2018 03:48:53 +0200 Subject: [PATCH] ViewSpec: get rid of all the lambdas and global vars. LocationQuery is a service now Harvesting the fruits of the DependencyFactory rework.... --- src/gui/interact/interaction-director.cpp | 2 +- src/gui/interact/ui-coord-resolver.cpp | 3 ++ src/gui/interact/ui-coord-resolver.hpp | 6 ++++ src/gui/interact/ui-location-solver.hpp | 2 -- src/gui/interact/view-locator.cpp | 34 ++++------------------- src/gui/interact/view-locator.hpp | 2 +- 6 files changed, 16 insertions(+), 33 deletions(-) diff --git a/src/gui/interact/interaction-director.cpp b/src/gui/interact/interaction-director.cpp index bba865b8b..9e7dfff1b 100644 --- a/src/gui/interact/interaction-director.cpp +++ b/src/gui/interact/interaction-director.cpp @@ -84,7 +84,7 @@ namespace interact { InteractionDirector::InteractionDirector (GlobalCtx& globals) : model::Controller(session::Root::getID(), globals.uiBus_.getAccessPoint()) , globalCtx_(globals) - , viewLocator_{new ViewLocator{globals, [this]() -> LocationQuery& { return *navigator_; }}} + , viewLocator_{new ViewLocator{globals}} , spotLocator_{new SpotLocator} , navigator_{*spotLocator_, *viewLocator_} // Service exposed as Depend , tracker_{new FocusTracker{*navigator_}} diff --git a/src/gui/interact/ui-coord-resolver.cpp b/src/gui/interact/ui-coord-resolver.cpp index 3f5540725..9ce33e6ff 100644 --- a/src/gui/interact/ui-coord-resolver.cpp +++ b/src/gui/interact/ui-coord-resolver.cpp @@ -44,6 +44,9 @@ namespace interact { LocationQuery::~LocationQuery() { } + /** storage for the global LocationQuery service access point */ + lib::Depend LocationQuery::service; + diff --git a/src/gui/interact/ui-coord-resolver.hpp b/src/gui/interact/ui-coord-resolver.hpp index 687f0c180..36686f954 100644 --- a/src/gui/interact/ui-coord-resolver.hpp +++ b/src/gui/interact/ui-coord-resolver.hpp @@ -121,6 +121,7 @@ #include "gui/interact/ui-coord.hpp" #include "lib/iter-tree-explorer.hpp" #include "lib/iter-source.hpp" +#include "lib/depend.hpp" #include "lib/util.hpp" #include @@ -191,6 +192,7 @@ namespace interact { * they may be resolved against any tree-like topological structure, which can be queried through * this interface. * @see Navigator the implementation used in the Lumiera UI, as backed by actual GUI components + * @see InteractionDirector manages the Navigator and exposes it via lib::Depend * @see GenNodeLocationQuery a dummy/test implementation, where the "UI topology" is hard wired * as a tree of GenNode elements. This serves the purpose of unit testing, without having * to rely on an actual UI. @@ -200,6 +202,10 @@ namespace interact { public: virtual ~LocationQuery(); ///< this is an interface + /** access point to global LocationQuery service implementation */ + static lib::Depend service; + + using ChildIter = decltype (TreeStructureNavigator::buildIterator(0)); diff --git a/src/gui/interact/ui-location-solver.hpp b/src/gui/interact/ui-location-solver.hpp index 98f9e41bf..e1f2887d3 100644 --- a/src/gui/interact/ui-location-solver.hpp +++ b/src/gui/interact/ui-location-solver.hpp @@ -91,8 +91,6 @@ namespace interact { class LocationQuery; using LocationQueryAccess = std::function; - /** @internal access UI service to query and discover locations within UI topology */ - extern LocationQueryAccess loactionQuery; ///////////////////////////////////////////////////////////////TODO this global variable seems to be dispensable diff --git a/src/gui/interact/view-locator.cpp b/src/gui/interact/view-locator.cpp index 414a183ae..a02672c2d 100644 --- a/src/gui/interact/view-locator.cpp +++ b/src/gui/interact/view-locator.cpp @@ -45,6 +45,7 @@ #include "gui/ctrl/window-locator.hpp" #include "gui/interact/ui-coord-resolver.hpp" #include "gui/ctrl/global-ctx.hpp" +#include "lib/depend.hpp" #include "lib/symbol.hpp" //#include "lib/util.hpp" @@ -69,39 +70,14 @@ namespace interact { - namespace { - const LocationQueryAccess LOCATION_QUERY_SERIVCE_NOT_AVAILABLE - = []() -> LocationQuery& - { - throw error::State (error::LUMIERA_ERROR_LIFECYCLE - ,"No LocationQuery service available. Is the GUI running?"); - }; - } - /** @internal global access point to some implementation of the LocationQuery API. - * Typically, this is provided by the Navigator service in conjunction with the ViewLocator; - * both are components managed by the InteractionDirector. Thus, when the UI starts, a suitable - * access functor will be installed here, and likewise removed/disabled on shutdown. - * ///////////////////////////////////////////////////////////////////////////////////////TICKET #1127 looks like we could get rid of that global state - */ - LocationQueryAccess locationQuery = LOCATION_QUERY_SERIVCE_NOT_AVAILABLE; - - - - - - ViewLocator::ViewLocator (ctrl::GlobalCtx& uiTopLevel, LocationQueryAccess getLocQuery) + ViewLocator::ViewLocator (ctrl::GlobalCtx& uiTopLevel) : globals_{uiTopLevel} - , locResolver_{new UILocationSolver{getLocQuery}} - { - locationQuery = getLocQuery; - } + , locResolver_{new UILocationSolver{LocationQuery::service}} + { } // dtors via smart-ptr invoked from here... - ViewLocator::~ViewLocator() - { - locationQuery = LOCATION_QUERY_SERIVCE_NOT_AVAILABLE; - } + ViewLocator::~ViewLocator() { } diff --git a/src/gui/interact/view-locator.hpp b/src/gui/interact/view-locator.hpp index 7ce49285b..a7b7f4a2e 100644 --- a/src/gui/interact/view-locator.hpp +++ b/src/gui/interact/view-locator.hpp @@ -93,7 +93,7 @@ namespace interact { unique_ptr locResolver_; public: - ViewLocator (ctrl::GlobalCtx&, LocationQueryAccess); + ViewLocator (ctrl::GlobalCtx&); ~ViewLocator();