From e0e9b7c2c0442ec7c5daa146bc969b9fdd2662ad Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Wed, 4 Nov 2009 04:56:25 +0100 Subject: [PATCH] WIP about how to link the QueryFocus system to the session/PlacementIndex --- src/proc/mobject/session/query-focus.hpp | 2 + src/proc/mobject/session/query-resolver.hpp | 5 +- src/proc/mobject/session/scope-locator.hpp | 103 ++++++++++++++++++++ src/proc/mobject/session/scope.hpp | 18 +--- wiki/renderengine.html | 4 +- 5 files changed, 115 insertions(+), 17 deletions(-) create mode 100644 src/proc/mobject/session/scope-locator.hpp diff --git a/src/proc/mobject/session/query-focus.hpp b/src/proc/mobject/session/query-focus.hpp index fa8d6343e..522d6e896 100644 --- a/src/proc/mobject/session/query-focus.hpp +++ b/src/proc/mobject/session/query-focus.hpp @@ -69,6 +69,8 @@ namespace session { QueryFocus::query() const { UNIMPLEMENTED ("how the hell do we issue typed queries?????"); ///////////////////////TICKET #352 + + ////////////yeah! we know now ---> ScopeLocator::explore(..) } diff --git a/src/proc/mobject/session/query-resolver.hpp b/src/proc/mobject/session/query-resolver.hpp index e389b5c27..4a77648ae 100644 --- a/src/proc/mobject/session/query-resolver.hpp +++ b/src/proc/mobject/session/query-resolver.hpp @@ -36,7 +36,7 @@ #include #include //#include -//#include +#include //using std::vector; //using std::string; @@ -48,6 +48,7 @@ namespace session { using boost::noncopyable; using boost::scoped_ptr; using std::tr1::function; + using std::string; class Goal; @@ -245,6 +246,8 @@ namespace session { public: virtual ~QueryResolver() ; + operator string () =0; ///< short characterisation of the actual facility + /** issue a query to retrieve contents * The query is handed over internally to a suitable resolver implementation. diff --git a/src/proc/mobject/session/scope-locator.hpp b/src/proc/mobject/session/scope-locator.hpp new file mode 100644 index 000000000..f91f64510 --- /dev/null +++ b/src/proc/mobject/session/scope-locator.hpp @@ -0,0 +1,103 @@ +/* + SCOPE-LOCATOR.hpp - management and registration point for the QueryFocus-system + + Copyright (C) Lumiera.org + 2009, Hermann Vosseler + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +*/ + + +#ifndef MOBJECT_SESSION_SCOPE_LOCATOR_H +#define MOBJECT_SESSION_SCOPE_LOCATOR_H + +//#include "proc/mobject/mobject.hpp" +#include "proc/mobject/session/scope.hpp" +#include "proc/mobject/placement.hpp" +#include "proc/mobject/session/contents-query.hpp" +#include "lib/singleton.hpp" +#include "lib/util.hpp" + +#include +#include +//#include +//#include + +//using std::vector; +//using std::string; + +namespace mobject { +namespace session { + + using std::tr1::shared_ptr; + using boost::scoped_ptr; + using util::cStr; + + + class QueryFocusStack; //////TODO better include? + + + + class ScopeLocator + { + scoped_ptr focusStack_; + shared_ptr index_; + + public: + ScopeLocator(); + + void + activate (shared_ptr resolvingFacility); + + template + typename ContentsQuery::iterator + explore (Scope const&); + + }; +///////////////////////////TODO currently just fleshing the API + + + + /** activate or de-activate the QueryFocus system. + * This is done by a link to a contents-query resolving facility, + * typically the PlacementIndex within the current session. + */ + void + ScopeLocator::activate (shared_ptr resolvingFacility) + { + index_ = resolvingFacility; + + if (index_) + INFO (config, "Enabling Scope resolution by %s.", cStr(*index_)); + else + INFO (config, "Disabling Scope resolution."); + } + + + /** use the currently installed contents-resolving facility + * to enumerate the contents of the given scope + */ + template + typename ContentsQuery::iterator + ScopeLocator::explore (Scope const& scope) + { + REQUIRE (index_); + return ContentsQuery (*index_, scope.getTop()); + } + + +}} // namespace mobject::session +#endif diff --git a/src/proc/mobject/session/scope.hpp b/src/proc/mobject/session/scope.hpp index 88d6300d2..e12eae402 100644 --- a/src/proc/mobject/session/scope.hpp +++ b/src/proc/mobject/session/scope.hpp @@ -1,6 +1,5 @@ /* SCOPE.hpp - nested search scope for properties of placement - Copyright (C) Lumiera.org 2009, Hermann Vosseler @@ -28,10 +27,12 @@ //#include "proc/mobject/mobject.hpp" #include "proc/mobject/placement.hpp" #include "proc/mobject/placement-ref.hpp" +//#include "proc/mobject/session/query-resolver.hpp" ///////////TODO: really? #include "lib/iter-adapter.hpp" -#include "lib/singleton.hpp" +//#include "lib/singleton.hpp" -#include +//#include +//#include //#include //#include @@ -41,11 +42,8 @@ namespace mobject { namespace session { - using boost::scoped_ptr; using lib::IterAdapter; - class ScopeLocator; - class QueryFocusStack; /** @@ -80,14 +78,6 @@ namespace session { }; - class ScopeLocator - { - scoped_ptr focusStack_; - - public: - ScopeLocator(); - - }; ///////////////////////////TODO currently just fleshing the API diff --git a/wiki/renderengine.html b/wiki/renderengine.html index f17e1f552..5db23fab1 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
@@ -3479,7 +3479,7 @@ See also the notes on &rarr; QueryImplProlog
 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.
 
 !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 grabbing the query focus 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.
+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.
 
 The stack of scopes must not be confused with the ScopePath. Each single frame on the stack is a QueryFocus and as such contains a current ScopePath. The purpose of the stack is to make the scope handling mostly transparent; especially this stack allows to write dedicated query functions directed at a given object: they work by pushing and then navigating to the object to use as new starting point. Not every placement is a scope, but every placement has an immediately enclosing scope, which is used as //current scope.//