diff --git a/src/proc/mobject/session/query-focus.hpp b/src/proc/mobject/session/query-focus.hpp index e8e407b9e..29249ba58 100644 --- a/src/proc/mobject/session/query-focus.hpp +++ b/src/proc/mobject/session/query-focus.hpp @@ -114,13 +114,13 @@ namespace session { * Implemented by copying the scope at * leaf position of the current focus path */ - QueryFocus::operator Scope() const + inline QueryFocus::operator Scope() const { return currPath().getLeaf(); } /**@note returning a copy */ - ScopePath + inline ScopePath QueryFocus::currentPath() const { return currPath(); @@ -131,7 +131,7 @@ namespace session { * within \em current focus. Resolution is * delegated to the \em current session */ template - typename ScopeQuery::iterator + inline typename ScopeQuery::iterator QueryFocus::query() const { ScopeLocator::instance().query (*this); @@ -142,7 +142,7 @@ namespace session { * as immediate Child within \em current focus. * Resolution through \em current session */ template - typename ScopeQuery::iterator + inline typename ScopeQuery::iterator QueryFocus::explore() const { ScopeLocator::instance().explore (*this); diff --git a/src/proc/mobject/session/specific-contents-query.hpp b/src/proc/mobject/session/specific-contents-query.hpp index 31066b94c..4b9d218d0 100644 --- a/src/proc/mobject/session/specific-contents-query.hpp +++ b/src/proc/mobject/session/specific-contents-query.hpp @@ -107,5 +107,68 @@ namespace session { }; + + namespace { // type matching helper + + template + struct _PickResult; + + template + struct _PickResult const&)> > + { + typedef MO Type; + typedef SpecificContentsQuery FilterQuery; + typedef typename ScopeQuery::Iterator Iterator; + }; + + template + struct _PickResult const&)> + { + typedef MO Type; + typedef SpecificContentsQuery FilterQuery; + typedef typename ScopeQuery::Iterator Iterator; + }; + + template + struct _PickResult const&)> + { + typedef MO Type; + typedef SpecificContentsQuery FilterQuery; + typedef typename ScopeQuery::iterator Iterator; + }; + } + + + + + /** convenience shortcut to issue a SpecialContentsQuery, + * figuring out the actual return/filter type automatically, + * based on the predicate given as parameter + */ + template + inline typename _PickResult::FilterQuery + pickAllSuitable(PlacementMO const& scope, FUNC predicate) + { + typedef typename _PickResult::FilterQuery Query; + + return Query(scope, predicate); + } + + /** convenience shortcut (variant), automatically to build + * and execute a suitable SpecialContentsQuery + * @return iterator yielding placements of the type as + * defined through the parameter of the predicate + */ + template + inline typename _PickResult::Iterator + pickAllSuitable(PlacementMO const& scope, FUNC predicate, QueryResolver const& resolver) + { + typedef typename _PickResult::FilterQuery Query; + + return Query(scope, predicate ).resolveBy(resolver); + } + + + }} // namespace mobject::session #endif diff --git a/tests/components/proc/mobject/session/scope-query-test.cpp b/tests/components/proc/mobject/session/scope-query-test.cpp index 4f7a08474..994adb8dd 100644 --- a/tests/components/proc/mobject/session/scope-query-test.cpp +++ b/tests/components/proc/mobject/session/scope-query-test.cpp @@ -107,8 +107,8 @@ namespace test { discover (ScopeQuery (scope, CONTENTS) , "contents depth-first, filtered to TestSubMO1"); discover (ScopeQuery (scope, CONTENTS) , "contents depth-first, filtered to TestSubMO2"); - discover (SpecificContentsQuery (scope, filter) , "contents depth-first, custom filtered DummyMO"); - // note the filter is typed to accept DummyMO + discover (pickAllSuitable(scope, filter) , "contents depth-first, custom filtered DummyMO"); + // note filter is typed to accept DummyMO ScopeQuery allM021(scope, CONTENTS); ScopeQuery::iterator specialEl (issue(allM021)); ++specialEl; // step in to second solution found...