integrate QueryFocus with the new ContentsQuery facility

This commit is contained in:
Fischlurch 2009-11-06 18:42:15 +01:00
parent e0e9b7c2c0
commit bb8c018214
7 changed files with 30 additions and 19 deletions

View file

@ -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<class MO>
typename session::Query<Placement<MO> >::iterator
query (PlacementMO& scope) const;
operator string() const { return "PlacementIndex"; }
////////////////////////////////////////////////////////////////TODO: refactor into explicit query resolving wrapper
bool canHandleQuery(QID) const;

View file

@ -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 <vector>
//#include <string>
@ -59,19 +60,15 @@ namespace session {
ScopePath currentPath() const { return scopes_; }
template<class MO>
void query() const; ////////////////////////////////////////////////////////////////TODO obviously needs to return an Iterator
typename ContentsQuery<MO>::iterator
query() const
{
ScopeLocator::instance().explore<MO> (*this);
}
};
///////////////////////////TODO currently just fleshing the API
template<class MO>
void
QueryFocus::query() const
{
UNIMPLEMENTED ("how the hell do we issue typed queries?????"); ///////////////////////TICKET #352
////////////yeah! we know now ---> ScopeLocator::explore(..)
}
}} // namespace mobject::session

View file

@ -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

View file

@ -53,19 +53,23 @@ namespace session {
class ScopeLocator
{
scoped_ptr<QueryFocusStack> focusStack_;
shared_ptr<QueryResolver> index_;
scoped_ptr<QueryFocusStack> focusStack_;
shared_ptr<QueryResolver> index_;
public:
ScopeLocator();
static lib::Singleton<ScopeLocator> instance;
void
activate (shared_ptr<QueryResolver> resolvingFacility);
template<typename MO>
typename ContentsQuery<MO>::iterator
explore (Scope const&);
explore (Scope);
protected:
ScopeLocator();
friend class lib::singleton::StaticCreate<ScopeLocator>;
};
///////////////////////////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<QueryResolver> resolvingFacility)
{
index_ = resolvingFacility;
@ -91,8 +95,8 @@ namespace session {
* to enumerate the contents of the given scope
*/
template<typename MO>
typename ContentsQuery<MO>::iterator
ScopeLocator::explore (Scope const& scope)
inline typename ContentsQuery<MO>::iterator
ScopeLocator::explore (Scope scope)
{
REQUIRE (index_);
return ContentsQuery<MO> (*index_, scope.getTop());

View file

@ -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> ScopeLocator::instance;
/** discover the enclosing scope of a given Placement */

View file

@ -152,6 +152,8 @@ namespace test {
return new DummyResultSet<TY>();
}
operator string() const { return "Test-DummyQueryResolver"; }
public:
DummyTypedSolutionProducer()
: QueryResolver()

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="200911040256" created="200910140244" tags="def spec img" changecount="18">
<div title="QueryFocus" modifier="Ichthyostega" modified="200911050236" created="200910140244" tags="def spec img" changecount="19">
<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
@ -3476,7 +3476,7 @@ See also the notes on &amp;rarr; QueryImplProlog
* (typed) content discovery query on the current scope
[&gt;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// &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.
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 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.