PlacementIndexQueryResolver passes unit test
This commit is contained in:
parent
a9a6bb3951
commit
82967191b3
5 changed files with 90 additions and 32 deletions
|
|
@ -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<MObject>();
|
||||
defineHandling<Clip>();
|
||||
defineHandling<Effect>();
|
||||
/////////////////////////////////////////////////////////////////TICKET #414
|
||||
|
||||
defineHandling<mobject::test::DummyMO >();
|
||||
defineHandling<mobject::test::TestSubMO1 >();
|
||||
defineHandling<mobject::test::TestSubMO2 >();
|
||||
defineHandling<mobject::test::TestSubMO21>();
|
||||
/////////////////////////////////////////////////////////////////TICKET #532
|
||||
preGenerateInvocationContext();
|
||||
}
|
||||
|
||||
|
||||
PlacementIndexQueryResolver::PlacementIndexQueryResolver (function<IndexLink> const& accessIndex)
|
||||
: _getIndex(accessIndex)
|
||||
{
|
||||
preGenerateInvocationContext();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
PlacementIndexQueryResolver::preGenerateInvocationContext()
|
||||
{
|
||||
defineHandling<MObject>();
|
||||
defineHandling<Clip>();
|
||||
defineHandling<Effect>();
|
||||
/////////////////////////////////////////////////////////////////TICKET #414
|
||||
|
||||
defineHandling<mobject::test::DummyMO >();
|
||||
defineHandling<mobject::test::TestSubMO1 >();
|
||||
defineHandling<mobject::test::TestSubMO2 >();
|
||||
defineHandling<mobject::test::TestSubMO21>();
|
||||
/////////////////////////////////////////////////////////////////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
|
||||
|
|
|
|||
|
|
@ -61,11 +61,15 @@
|
|||
#include "proc/mobject/session/query-resolver.hpp"
|
||||
#include "proc/mobject/session/scope-query.hpp"
|
||||
|
||||
#include <tr1/functional>
|
||||
|
||||
|
||||
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<IndexLink> _getIndex;
|
||||
|
||||
|
||||
virtual bool canHandleQuery(Goal::QueryID const&) const;
|
||||
|
|
@ -96,6 +99,8 @@ namespace session {
|
|||
|
||||
Explorer* setupExploration (PlacementIndex::ID startID, ScopeQueryKind direction);
|
||||
|
||||
void preGenerateInvocationContext();
|
||||
|
||||
template<typename MO>
|
||||
void defineHandling();
|
||||
|
||||
|
|
@ -104,7 +109,8 @@ namespace session {
|
|||
|
||||
|
||||
public:
|
||||
PlacementIndexQueryResolver (PIdx theIndex);
|
||||
PlacementIndexQueryResolver (PlacementIndex& theIndex);
|
||||
PlacementIndexQueryResolver (function<IndexLink> const& accessIndex);
|
||||
};
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -136,6 +136,7 @@ namespace session {
|
|||
|
||||
|
||||
|
||||
|
||||
template<class IMPL>
|
||||
struct ServiceAccessPoint<SessionServiceExploreScope, IMPL>
|
||||
: IMPL
|
||||
|
|
@ -152,17 +153,30 @@ namespace session {
|
|||
return IMPL::getPlacementIndex().getRoot();
|
||||
}
|
||||
|
||||
protected:
|
||||
ServiceAccessPoint<SessionServiceExploreScope, IMPL>()
|
||||
: 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<SessionServiceExploreScope, IMPL>()
|
||||
: resolvingWrapper_(AccessCurrentIndex (*this))
|
||||
{ }
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
template<class IMPL>
|
||||
struct ServiceAccessPoint<SessionServiceMockIndex, IMPL>
|
||||
: IMPL
|
||||
|
|
|
|||
|
|
@ -6,10 +6,6 @@ PLANNED "AddClip_test" AddClip_test <<END
|
|||
END
|
||||
|
||||
|
||||
PLANNED "discovering scopes" ScopeQuery_test <<END
|
||||
END
|
||||
|
||||
|
||||
TEST "DefsManager_test" DefsManager_test <<END
|
||||
return: 0
|
||||
END
|
||||
|
|
@ -92,7 +88,13 @@ out: pID\(\w{8,16}\)
|
|||
END
|
||||
|
||||
|
||||
TEST "PlacementIndex_test" PlacementIndex_test <<END
|
||||
TEST "PlacementRef_test" PlacementRef_test <<END
|
||||
out: Placement<.+TestSubMO21.> .......... use-cnt=2
|
||||
out: specialAPI()
|
||||
END
|
||||
|
||||
|
||||
TEST "Placement Index" PlacementIndex_test <<END
|
||||
out: ^::Placement<.+session.test.TestClip.+ use-cnt=2
|
||||
out: ^ ::Placement<.+session.test.TestClip.+ use-cnt=1
|
||||
out: ^ ...1 elements at Level 1
|
||||
|
|
@ -107,9 +109,19 @@ out: ^...3 elements at Level 0
|
|||
END
|
||||
|
||||
|
||||
TEST "PlacementRef_test" PlacementRef_test <<END
|
||||
out: Placement<.+TestSubMO21.> .......... use-cnt=2
|
||||
out: specialAPI()
|
||||
TEST "Querying the index" PlacementIndexQuery_test <<END
|
||||
out: explore contents depth-first...
|
||||
out: Placement<.+TestSubMO21.> .......... 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 <<END
|
||||
END
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -92,10 +92,12 @@ namespace test {
|
|||
PlacementMO& root = index->getRoot();
|
||||
PlacementIndexQueryResolver resolver(*index);
|
||||
|
||||
cout << "explore contents depth-first..." << endl;
|
||||
discover (ContentsQuery<MObject> (resolver,root));
|
||||
|
||||
PlacementMO& elm = *ContentsQuery<TestSubMO1>(resolver,root); ////////////////////// TICKET #532
|
||||
|
||||
cout << "path to root starting at " << string(elm) << endl;
|
||||
discover (PathQuery<MObject> (resolver,elm));
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue