From 017c668d7aeb8656e98096742d1cbb0165c09757 Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Fri, 13 Nov 2009 16:32:22 +0100 Subject: [PATCH] WIP outline of the index query resolution --- src/proc/mobject/placement.hpp | 2 +- .../placement-index-query-resolver.hpp | 72 ++++++++++++++++++- src/proc/mobject/session/query-resolver.hpp | 2 +- .../session/placement-index-query-test.cpp | 2 - 4 files changed, 72 insertions(+), 6 deletions(-) diff --git a/src/proc/mobject/placement.hpp b/src/proc/mobject/placement.hpp index 4f2ff9d95..d9622841c 100644 --- a/src/proc/mobject/placement.hpp +++ b/src/proc/mobject/placement.hpp @@ -230,7 +230,7 @@ namespace mobject { format_PlacementID (Placement const&) ; - /** @todo cleanup uses of ref-to-placement. See Trac #115 */ + /** @todo cleanup uses of ref-to-placement. See Ticket #115 */ typedef Placement PlacementMO; typedef Placement PMO; diff --git a/src/proc/mobject/session/placement-index-query-resolver.hpp b/src/proc/mobject/session/placement-index-query-resolver.hpp index 66bb2be47..2b5c5c203 100644 --- a/src/proc/mobject/session/placement-index-query-resolver.hpp +++ b/src/proc/mobject/session/placement-index-query-resolver.hpp @@ -42,6 +42,7 @@ //#include "proc/mobject/placement.hpp" #include "proc/mobject/session/placement-index.hpp" #include "proc/mobject/session/query-resolver.hpp" +#include "proc/mobject/session/scope-query.hpp" //#include //#include @@ -68,7 +69,9 @@ namespace session { class PlacementIndexQueryResolver : public session::QueryResolver { - + PPIdx index_; + + typedef PlacementIndex::ID PID; ////////////////////////////////////////////////////////////////TODO: moved in from PlacementIndex typedef session::Goal::QueryID const& QID; @@ -79,7 +82,72 @@ namespace session { operator string() const { return "PlacementIndex"; } bool canHandleQuery(QID) const; -////////////////////////////////////////////////////////////////TODO: +////////////////////////////////////////////////////////////////TODO: + + /** + * on query, an individual result set is prepared + * to be explored by the invoking client code. + * It is built wrapping the low-level scope iterator + * obtained from the index, controlled by an + * exploration strategy. + */ + template + struct ResultSet + : Resolution + { + DummySolutions solutions_; + + typedef typename Query::Cursor Cursor; + + Result + prepareResolution() + { + Cursor cursor; + cursor.point_at (solutions_.next()); + return cursor; + } + + void + nextResult(Result& pos) + { + Cursor& cursor = static_cast (pos); + + if (solutions_.exhausted()) + cursor.point_at (0); + else + cursor.point_at (solutions_.next()); + } + }; + + template + static Resolution* + resolutionFunction (Goal const& goal) + { + QID qID = goal.getQID(); + REQUIRE (qID.kind == Goal::DISCOVERY + && qID.type == getResultTypeID >()); /////////////////////////////TODO + REQUIRE (INSTANCEOF(ScopeQuery, &goal)); + ScopeQuery const& query = static_cast const&> (goal); + + Literal direction = query.searchDirection(); + PID scopeID = query.searchScope().getID(); //////////TICKET #411 + + ///////////////////////////TODO: where to put the exploration strategy? statically, dynamically? + //////////////////////////////// note: direction == "parents" works completely different, based on index_->getScope(..) + + return new ResultSet(); + } + + public: + PlacementIndexQueryResolver (PPIdx theIndex) + : index_(theIndex) + { + Goal::QueryID case1 = {Goal::DISCOVERY, getResultTypeID()}; /////////////////TODO + Goal::QueryID case2 = {Goal::DISCOVERY, getResultTypeID()}; + + installResolutionCase(case1, &resolutionFunction ); + installResolutionCase(case2, &resolutionFunction ); + } }; diff --git a/src/proc/mobject/session/query-resolver.hpp b/src/proc/mobject/session/query-resolver.hpp index 344f31a28..4328d899d 100644 --- a/src/proc/mobject/session/query-resolver.hpp +++ b/src/proc/mobject/session/query-resolver.hpp @@ -98,7 +98,7 @@ namespace session { class Result : public lib::BoolCheckable { - void *cur_; + void* cur_; protected: void point_at(void* p) { cur_ = p; } diff --git a/tests/components/proc/mobject/session/placement-index-query-test.cpp b/tests/components/proc/mobject/session/placement-index-query-test.cpp index b4b8cbb14..03d773eee 100644 --- a/tests/components/proc/mobject/session/placement-index-query-test.cpp +++ b/tests/components/proc/mobject/session/placement-index-query-test.cpp @@ -85,7 +85,6 @@ namespace test { void checkQueryOperations() { -#if false //////////////////////////////////////////////////////////////////////////////////////////////////////////TICKET #384 !!!!!!!!! // Prepare an (test)Index (dummy "session") PPIdx index = build_testScopes(); PlacementMO& root = index->getRoot(); @@ -96,7 +95,6 @@ namespace test { PlacementMO& elm = *ContentsQuery(resolver,root); discover (PathQuery(resolver,elm)); -#endif ////////////////////////////////////////////////////////////////////////////////////////TODO lots of things unimplemented.....!!!!! }