WIP outline of the index query resolution

This commit is contained in:
Fischlurch 2009-11-13 16:32:22 +01:00
parent 981ea94708
commit 017c668d7a
4 changed files with 72 additions and 6 deletions

View file

@ -230,7 +230,7 @@ namespace mobject {
format_PlacementID (Placement<MObject> const&) ;
/** @todo cleanup uses of ref-to-placement. See Trac #115 */
/** @todo cleanup uses of ref-to-placement. See Ticket #115 */
typedef Placement<MObject> PlacementMO;
typedef Placement<MObject> PMO;

View file

@ -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 <tr1/memory>
//#include <boost/noncopyable.hpp>
@ -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<typename TY>
struct ResultSet
: Resolution
{
DummySolutions<TY> solutions_;
typedef typename Query<TY>::Cursor Cursor;
Result
prepareResolution()
{
Cursor cursor;
cursor.point_at (solutions_.next());
return cursor;
}
void
nextResult(Result& pos)
{
Cursor& cursor = static_cast<Cursor&> (pos);
if (solutions_.exhausted())
cursor.point_at (0);
else
cursor.point_at (solutions_.next());
}
};
template<typename MO>
static Resolution*
resolutionFunction (Goal const& goal)
{
QID qID = goal.getQID();
REQUIRE (qID.kind == Goal::DISCOVERY
&& qID.type == getResultTypeID<Placement<MO> >()); /////////////////////////////TODO
REQUIRE (INSTANCEOF(ScopeQuery<MO>, &goal));
ScopeQuery<MO> const& query = static_cast<ScopeQuery<MO> 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<MO>();
}
public:
PlacementIndexQueryResolver (PPIdx theIndex)
: index_(theIndex)
{
Goal::QueryID case1 = {Goal::DISCOVERY, getResultTypeID<int>()}; /////////////////TODO
Goal::QueryID case2 = {Goal::DISCOVERY, getResultTypeID<string>()};
installResolutionCase(case1, &resolutionFunction<int> );
installResolutionCase(case2, &resolutionFunction<string> );
}
};

View file

@ -98,7 +98,7 @@ namespace session {
class Result
: public lib::BoolCheckable<Result>
{
void *cur_;
void* cur_;
protected:
void point_at(void* p) { cur_ = p; }

View file

@ -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<TestSubMO1>(resolver,root);
discover (PathQuery(resolver,elm));
#endif ////////////////////////////////////////////////////////////////////////////////////////TODO lots of things unimplemented.....!!!!!
}