From 001a45f64a90ca7baeacf37f3098f93243e16ed1 Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Mon, 4 Oct 2010 02:30:44 +0200 Subject: [PATCH] WIP implementation idea how to get both iterations unified --- src/proc/mobject/session/scope-query.hpp | 49 ++++++++++++++++++++++-- 1 file changed, 45 insertions(+), 4 deletions(-) diff --git a/src/proc/mobject/session/scope-query.hpp b/src/proc/mobject/session/scope-query.hpp index 8046bc289..d167e6554 100644 --- a/src/proc/mobject/session/scope-query.hpp +++ b/src/proc/mobject/session/scope-query.hpp @@ -216,21 +216,62 @@ namespace session { * kind of MObject */ template - class WrappedResults + class CachedQuery + : Query > { + typedef Placement PMO; + typedef Query _Query; + typedef typename _Query::Result Result; + typedef typename _Query::Cursor Cursor; - class Wrapper + + public: + typedef typename _Query::iterator iterator; + + class Snapshot + : public Resolution { //////////////TODO: it would be *nice* if we could build something similar to the scope-query Resolution //////////////TODO: *requirement* is that it must not pull in anything beyond and iter-adapters.hpp //////////////TODO: but if that's too expensive to implement, just ditch the ability of subclassing and just yield MObjects, or even just Scopes + + vector results_; + + Result + prepareResolution() + { + UNIMPLEMENTED ("hook up first result"); + } + + void + nextResult(Result& pos) + { + UNIMPLEMENTED ("how to advance embedded pointer"); + } + + public: + template + Snapshot(IT const& iter) + { + for(IT ii(iter); ii; ++ii) + results_.push_back(*ii); + } }; + Snapshot resultset_; template - WrappedResults (IT const& results) + CachedQuery (IT const& results) + : resultset_(results) + { } + + iterator + resolve () const { - UNIMPLEMENTED ("build a suitable wrapper"); + PReso resultSet(new Snapshot(resultset_)); + Result first = resultSet->prepareResolution(); + Cursor& start = static_cast (first); // note: type RES must be compatible! + return iterator (resultSet, start); } };