diff --git a/src/proc/mobject/placement-index.hpp b/src/proc/mobject/placement-index.hpp index 4fb15d428..1bc193cbe 100644 --- a/src/proc/mobject/placement-index.hpp +++ b/src/proc/mobject/placement-index.hpp @@ -96,10 +96,14 @@ namespace mobject { ///////////////////////////////////////////TODO: shouldn't t bool contains (PlacementMO const&) const; bool contains (ID) const; +////////////////////////////////////////////////////////////////TODO: refactor into explicit query resolving wrapper template typename session::Query >::iterator query (PlacementMO& scope) const; + operator string() const { return "PlacementIndex"; } +////////////////////////////////////////////////////////////////TODO: refactor into explicit query resolving wrapper + bool canHandleQuery(QID) const; diff --git a/src/proc/mobject/session/query-focus.hpp b/src/proc/mobject/session/query-focus.hpp index 522d6e896..0507eb31b 100644 --- a/src/proc/mobject/session/query-focus.hpp +++ b/src/proc/mobject/session/query-focus.hpp @@ -27,6 +27,7 @@ //#include "proc/mobject/mobject.hpp" //#include "proc/mobject/placement.hpp" #include "proc/mobject/session/scope-path.hpp" +#include "proc/mobject/session/scope-locator.hpp" //#include //#include @@ -59,19 +60,15 @@ namespace session { ScopePath currentPath() const { return scopes_; } template - void query() const; ////////////////////////////////////////////////////////////////TODO obviously needs to return an Iterator + typename ContentsQuery::iterator + query() const + { + ScopeLocator::instance().explore (*this); + } }; ///////////////////////////TODO currently just fleshing the API - template - void - QueryFocus::query() const - { - UNIMPLEMENTED ("how the hell do we issue typed queries?????"); ///////////////////////TICKET #352 - - ////////////yeah! we know now ---> ScopeLocator::explore(..) - } }} // namespace mobject::session diff --git a/src/proc/mobject/session/query-resolver.hpp b/src/proc/mobject/session/query-resolver.hpp index 4a77648ae..07808a3bf 100644 --- a/src/proc/mobject/session/query-resolver.hpp +++ b/src/proc/mobject/session/query-resolver.hpp @@ -246,7 +246,7 @@ namespace session { public: virtual ~QueryResolver() ; - operator string () =0; ///< short characterisation of the actual facility + virtual operator string () const =0; ///< short characterisation of the actual facility /** issue a query to retrieve contents diff --git a/src/proc/mobject/session/scope-locator.hpp b/src/proc/mobject/session/scope-locator.hpp index f91f64510..d75bdf980 100644 --- a/src/proc/mobject/session/scope-locator.hpp +++ b/src/proc/mobject/session/scope-locator.hpp @@ -53,19 +53,23 @@ namespace session { class ScopeLocator { - scoped_ptr focusStack_; - shared_ptr index_; + scoped_ptr focusStack_; + shared_ptr index_; public: - ScopeLocator(); + static lib::Singleton instance; void activate (shared_ptr resolvingFacility); template typename ContentsQuery::iterator - explore (Scope const&); + explore (Scope); + protected: + ScopeLocator(); + + friend class lib::singleton::StaticCreate; }; ///////////////////////////TODO currently just fleshing the API @@ -75,7 +79,7 @@ namespace session { * This is done by a link to a contents-query resolving facility, * typically the PlacementIndex within the current session. */ - void + inline void ScopeLocator::activate (shared_ptr resolvingFacility) { index_ = resolvingFacility; @@ -91,8 +95,8 @@ namespace session { * to enumerate the contents of the given scope */ template - typename ContentsQuery::iterator - ScopeLocator::explore (Scope const& scope) + inline typename ContentsQuery::iterator + ScopeLocator::explore (Scope scope) { REQUIRE (index_); return ContentsQuery (*index_, scope.getTop()); diff --git a/src/proc/mobject/session/scope.cpp b/src/proc/mobject/session/scope.cpp index b73096d36..04a99ea24 100644 --- a/src/proc/mobject/session/scope.cpp +++ b/src/proc/mobject/session/scope.cpp @@ -22,6 +22,7 @@ #include "proc/mobject/session/scope.hpp" +#include "proc/mobject/session/scope-locator.hpp" #include "proc/mobject/session/query-focus-stack.hpp" #include "proc/mobject/mobject.hpp" //#include "proc/mobject/session/track.hpp" @@ -69,6 +70,9 @@ namespace session { } + /** Storage holding the single ScopeLocator instance */ + lib::Singleton ScopeLocator::instance; + /** discover the enclosing scope of a given Placement */ diff --git a/tests/components/proc/mobject/session/query-resolver-test.cpp b/tests/components/proc/mobject/session/query-resolver-test.cpp index 7aeeab60e..d3a785b0f 100644 --- a/tests/components/proc/mobject/session/query-resolver-test.cpp +++ b/tests/components/proc/mobject/session/query-resolver-test.cpp @@ -152,6 +152,8 @@ namespace test { return new DummyResultSet(); } + operator string() const { return "Test-DummyQueryResolver"; } + public: DummyTypedSolutionProducer() : QueryResolver() diff --git a/wiki/renderengine.html b/wiki/renderengine.html index 5db23fab1..251817e61 100644 --- a/wiki/renderengine.html +++ b/wiki/renderengine.html @@ -3464,7 +3464,7 @@ For decoupling the query invocation from the facility actually processing the qu See also the notes on &rarr; QueryImplProlog -
+
When querying contents of the session or sub-containers within the session, the QueryFocus follows the current point-of-query. As such queries can be issued to explore the content of container-like objects holding other MObjects, the focus is always attached to a container, which also acts as [[scope|PlacementScope]] for the contained objects. QueryFocus is an implicit state (the current point of interrest). This sate especially remembers the path down from the root of the HighLevelModel, which was used to access the current scope. Because this path constitutes a hierarchy of scopes, it can be relevant for querying and resolving placement properties. (&rarr; SessionStructureQuery)
 
 !provided operations
@@ -3476,7 +3476,7 @@ See also the notes on &rarr; QueryImplProlog
 * (typed) content discovery query on the current scope
 [>img[Scope Locating|uml/fig136325.png]]
 !!!relation to Scope
-There is a tight integration with PlacementScope through the ScopeLocator, which establishes the //current scope.// But QueryFocus is more of a //binding// &mdash; it links or focusses the current state and into a specific scope with a ScopePath depending on the current state. Thus, while Scope is just a passive container allowing to locate and navigate, QueryFocus by virtue of this binding allows to [[Query]] at this current location.
+There is a tight integration with PlacementScope through the ScopeLocator, which establishes the //current scope.// But QueryFocus is more of a //binding// &mdash; it links or focusses the current state into a specific scope with a ScopePath in turn depending on this current state. Thus, while Scope is just a passive container allowing to locate and navigate, QueryFocus by virtue of this binding allows to [[Query]] at this current location.
 
 !implementation notes
 we provide a static access API, meaning that there is a singleton behind the scenes, which manages the mentioned scope stack. Moreover, there is an link to the current session. This link works by the current session contacting the query focus system (~ScopeLocator) and attaching to it. This attachment is shallow, i.e. the QueryFocus doesn't have knowledge about the session, which allows the focus to be unit tested.