diff --git a/src/proc/mobject/session/placement-index-query-resolver.cpp b/src/proc/mobject/session/placement-index-query-resolver.cpp index eb7e9686b..5b06caf73 100644 --- a/src/proc/mobject/session/placement-index-query-resolver.cpp +++ b/src/proc/mobject/session/placement-index-query-resolver.cpp @@ -275,26 +275,49 @@ namespace session { return qID; } + struct + UseThisIndex + { + UseThisIndex (PlacementIndex& idx) : refIndex_(idx) {} + + PlacementIndex& refIndex_; + PlacementIndex& operator() (void) { return refIndex_; } + }; } //(END) Helpers - PlacementIndexQueryResolver::PlacementIndexQueryResolver (PIdx theIndex) - : index_(theIndex) + PlacementIndexQueryResolver::PlacementIndexQueryResolver (PlacementIndex& theIndex) + : _getIndex(UseThisIndex (theIndex)) { - defineHandling(); - defineHandling(); - defineHandling(); - /////////////////////////////////////////////////////////////////TICKET #414 - - defineHandling(); - defineHandling(); - defineHandling(); - defineHandling(); - /////////////////////////////////////////////////////////////////TICKET #532 + preGenerateInvocationContext(); } + + PlacementIndexQueryResolver::PlacementIndexQueryResolver (function const& accessIndex) + : _getIndex(accessIndex) + { + preGenerateInvocationContext(); + } + + + void + PlacementIndexQueryResolver::preGenerateInvocationContext() + { + defineHandling(); + defineHandling(); + defineHandling(); + /////////////////////////////////////////////////////////////////TICKET #414 + + defineHandling(); + defineHandling(); + defineHandling(); + defineHandling(); + /////////////////////////////////////////////////////////////////TICKET #532 + } + + bool PlacementIndexQueryResolver::canHandleQuery(QID qID) const { @@ -359,12 +382,13 @@ namespace session { Explorer* PlacementIndexQueryResolver::setupExploration (PID startID, ScopeQueryKind direction) { + PIdx index = _getIndex(); // access the currently configured PlacementIndex (Session) switch (direction) { - case CONTENTS: return new DeepExplorer(index_.getReferrers(startID), index_); - case CHILDREN: return new ChildExplorer(index_.getReferrers(startID)); - case PARENTS: return new UpExplorer(index_.getScope(startID),index_); - case PATH: return new UpExplorer(index_.find(startID),index_); + case CONTENTS: return new DeepExplorer(index.getReferrers(startID), index); + case CHILDREN: return new ChildExplorer(index.getReferrers(startID)); + case PARENTS: return new UpExplorer(index.getScope(startID),index); + case PATH: return new UpExplorer(index.find(startID),index); default: throw lumiera::error::Invalid("unknown query direction"); //////TICKET #197 diff --git a/src/proc/mobject/session/placement-index-query-resolver.hpp b/src/proc/mobject/session/placement-index-query-resolver.hpp index e4846ec78..7ae60a7b9 100644 --- a/src/proc/mobject/session/placement-index-query-resolver.hpp +++ b/src/proc/mobject/session/placement-index-query-resolver.hpp @@ -61,11 +61,15 @@ #include "proc/mobject/session/query-resolver.hpp" #include "proc/mobject/session/scope-query.hpp" +#include namespace mobject { namespace session { + + using std::tr1::function; + typedef PlacementIndex& IndexLink(void); class Explorer; @@ -84,9 +88,8 @@ namespace session { class PlacementIndexQueryResolver : public session::QueryResolver { - typedef PlacementIndex& PIdx; - PIdx index_; + function _getIndex; virtual bool canHandleQuery(Goal::QueryID const&) const; @@ -96,6 +99,8 @@ namespace session { Explorer* setupExploration (PlacementIndex::ID startID, ScopeQueryKind direction); + void preGenerateInvocationContext(); + template void defineHandling(); @@ -104,7 +109,8 @@ namespace session { public: - PlacementIndexQueryResolver (PIdx theIndex); + PlacementIndexQueryResolver (PlacementIndex& theIndex); + PlacementIndexQueryResolver (function const& accessIndex); }; diff --git a/src/proc/mobject/session/session-impl.hpp b/src/proc/mobject/session/session-impl.hpp index 2c9bb572a..1c1a255aa 100644 --- a/src/proc/mobject/session/session-impl.hpp +++ b/src/proc/mobject/session/session-impl.hpp @@ -136,6 +136,7 @@ namespace session { + template struct ServiceAccessPoint : IMPL @@ -152,17 +153,30 @@ namespace session { return IMPL::getPlacementIndex().getRoot(); } - protected: - ServiceAccessPoint() - : resolvingWrapper_(IMPL::getPlacementIndex()) - { } - private: PlacementIndexQueryResolver resolvingWrapper_; + + /** indirection to use the \em currently defined + * index access point (might be a test mock) */ + struct + AccessCurrentIndex + { + IMPL& accessPoint_; + PlacementIndex& operator() (void) { return accessPoint_.getPlacementIndex(); } + + AccessCurrentIndex (IMPL& impl) : accessPoint_(impl) { } + }; + + protected: + ServiceAccessPoint() + : resolvingWrapper_(AccessCurrentIndex (*this)) + { } }; + + template struct ServiceAccessPoint : IMPL diff --git a/tests/43session.tests b/tests/43session.tests index 77dc68817..dcc9dc1ae 100644 --- a/tests/43session.tests +++ b/tests/43session.tests @@ -6,10 +6,6 @@ PLANNED "AddClip_test" AddClip_test < .......... use-cnt=2 +out: specialAPI() +END + + +TEST "Placement Index" PlacementIndex_test < .......... use-cnt=2 -out: specialAPI() +TEST "Querying the index" PlacementIndexQuery_test < .......... use-cnt=1 +out: Placement<.+TestSubMO2.> ........... use-cnt=1 +out: Placement<.+TestSubMO1.> ........... use-cnt=1 +out: Placement<.+DummyMO.> ............... use-cnt=1 +out: path to root starting at Placement<.+TestSubMO1 +out: Placement<.+TestSubMO2.> ........... use-cnt=1 +out: Placement<.+session.Label.> .............. use-cnt=1 +END + + +PLANNED "discovering scopes" ScopeQuery_test <getRoot(); PlacementIndexQueryResolver resolver(*index); + cout << "explore contents depth-first..." << endl; discover (ContentsQuery (resolver,root)); PlacementMO& elm = *ContentsQuery(resolver,root); ////////////////////// TICKET #532 + cout << "path to root starting at " << string(elm) << endl; discover (PathQuery (resolver,elm)); }