WIP about how to link the QueryFocus system to the session/PlacementIndex

This commit is contained in:
Fischlurch 2009-11-04 04:56:25 +01:00
parent 8c7727704c
commit e0e9b7c2c0
5 changed files with 115 additions and 17 deletions

View file

@ -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(..)
}

View file

@ -36,7 +36,7 @@
#include <tr1/functional>
#include <tr1/memory>
//#include <vector>
//#include <string>
#include <string>
//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.

View file

@ -0,0 +1,103 @@
/*
SCOPE-LOCATOR.hpp - management and registration point for the QueryFocus-system
Copyright (C) Lumiera.org
2009, Hermann Vosseler <Ichthyostega@web.de>
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 <boost/scoped_ptr.hpp>
#include <tr1/memory>
//#include <vector>
//#include <string>
//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<QueryFocusStack> focusStack_;
shared_ptr<QueryResolver> index_;
public:
ScopeLocator();
void
activate (shared_ptr<QueryResolver> resolvingFacility);
template<typename MO>
typename ContentsQuery<MO>::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<QueryResolver> 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 MO>
typename ContentsQuery<MO>::iterator
ScopeLocator::explore (Scope const& scope)
{
REQUIRE (index_);
return ContentsQuery<MO> (*index_, scope.getTop());
}
}} // namespace mobject::session
#endif

View file

@ -1,6 +1,5 @@
/*
SCOPE.hpp - nested search scope for properties of placement
Copyright (C) Lumiera.org
2009, Hermann Vosseler <Ichthyostega@web.de>
@ -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 <boost/scoped_ptr.hpp>
//#include <boost/scoped_ptr.hpp>
//#include <tr1/memory>
//#include <vector>
//#include <string>
@ -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<QueryFocusStack> focusStack_;
public:
ScopeLocator();
};
///////////////////////////TODO currently just fleshing the API

View file

@ -3464,7 +3464,7 @@ For decoupling the query invocation from the facility actually processing the qu
See also the notes on &amp;rarr; QueryImplProlog
</pre>
</div>
<div title="QueryFocus" modifier="Ichthyostega" modified="200910200138" created="200910140244" tags="def spec img" changecount="16">
<div title="QueryFocus" modifier="Ichthyostega" modified="200911040256" created="200910140244" tags="def spec img" changecount="18">
<pre>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. (&amp;rarr; SessionStructureQuery)
!provided operations
@ -3479,7 +3479,7 @@ See also the notes on &amp;rarr; QueryImplProlog
There is a tight integration with PlacementScope through the ScopeLocator, which establishes the //current scope.// But QueryFocus is more of a //binding// &amp;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.//