diff --git a/src/lib/iter-adapter.hpp b/src/lib/iter-adapter.hpp index fb0e98de4..cbbe7ac57 100644 --- a/src/lib/iter-adapter.hpp +++ b/src/lib/iter-adapter.hpp @@ -81,14 +81,21 @@ #include - +namespace mobject { +namespace session { + class Scope; +}} +#include +using std::vector; namespace lib { - namespace { + namespace iter { /** * Helper for creating nested typedefs * within the iterator adaptor, similar to what the STL does. + * @note client code might define specialisations + * to handle tricky situations (like const_reverse_iter) */ template struct IterTraits @@ -113,8 +120,20 @@ namespace lib { typedef const TY& reference; typedef const TY* pointer; }; - - + + using mobject::session::Scope; + + template<> + struct IterTraits::const_reverse_iterator> + { + typedef const Scope value_type; + typedef Scope const& reference; + typedef const Scope* pointer; + }; + + } + + namespace { // internal helpers void _throwIterExhausted() { @@ -164,9 +183,9 @@ namespace lib { mutable POS pos_; public: - typedef typename IterTraits::pointer pointer; - typedef typename IterTraits::reference reference; - typedef typename IterTraits::value_type value_type; + typedef typename iter::IterTraits::pointer pointer; + typedef typename iter::IterTraits::reference reference; + typedef typename iter::IterTraits::value_type value_type; IterAdapter (CON src, POS const& startpos) : source_(src) @@ -299,9 +318,9 @@ namespace lib { IT e_; public: - typedef typename IterTraits::pointer pointer; - typedef typename IterTraits::reference reference; - typedef typename IterTraits::value_type value_type; + typedef typename iter::IterTraits::pointer pointer; + typedef typename iter::IterTraits::reference reference; + typedef typename iter::IterTraits::value_type value_type; RangeIter (IT const& start, IT const& end) : p_(start) diff --git a/src/proc/mobject/session/scope-locator.hpp b/src/proc/mobject/session/scope-locator.hpp index a1520ffca..56a0b8606 100644 --- a/src/proc/mobject/session/scope-locator.hpp +++ b/src/proc/mobject/session/scope-locator.hpp @@ -27,6 +27,7 @@ #include "proc/mobject/session/scope.hpp" #include "proc/mobject/session/scope-query.hpp" #include "proc/mobject/placement.hpp" +#include "lib/iter-source.hpp" ////////////////////TICKET #493 : the bare interface would be sufficient here #include "lib/singleton.hpp" #include @@ -74,12 +75,16 @@ namespace session { typename ScopeQuery::iterator query (Scope); - ScopeQuery::iterator - locate (Scope scope); - + template + typename ScopeQuery::iterator + getRawPath (Scope); + ScopeQuery::iterator getRawPath (Scope); + lib::IterSource::iterator + locate (Scope scope); + ~ScopeLocator(); @@ -126,6 +131,13 @@ namespace session { * child of the root node and timelines (BindingMO) just appear * to be "dead ends" */ + template + inline typename ScopeQuery::iterator + ScopeLocator::getRawPath (Scope scope) + { + return ScopeQuery (scope.getTop(), PATH).resolveBy (theResolver()); + } + inline ScopeQuery::iterator ScopeLocator::getRawPath (Scope scope) { diff --git a/src/proc/mobject/session/scope.cpp b/src/proc/mobject/session/scope.cpp index be3e05790..b10df0982 100644 --- a/src/proc/mobject/session/scope.cpp +++ b/src/proc/mobject/session/scope.cpp @@ -26,9 +26,31 @@ #include "proc/mobject/session/query-focus-stack.hpp" #include "proc/mobject/session/session-service-explore-scope.hpp" #include "proc/mobject/mobject.hpp" +#include "lib/iter-source.hpp" ////////////////////TICKET #493 : using the IterSource adapters here //#include "proc/mobject/session/track.hpp" + //#include "proc/mobject/placement.hpp" //#include "proc/mobject/session/mobjectfactory.hpp" +#include + +using std::vector; +using lib::IterSource; +using lib::WrappedLumieraIterator; +using lib::iter_source::wrapIter; + +namespace lib { +namespace iter{ + +// using mobject::session::Scope; +// +// template<> +// struct IterTraits::const_reverse_iterator> +// { +// typedef const Scope value_type; +// typedef Scope const& reference; +// typedef const Scope* pointer; +// }; +}} namespace mobject { namespace session { @@ -135,13 +157,12 @@ namespace session { * @return an iterator yielding the nested scopes from the new location * up to root, in a way likely to be similar to the original location */ - ScopeQuery::iterator + IterSource::iterator ScopeLocator::locate (Scope scope) { - UNIMPLEMENTED ("virtual navigation"); - ///////////////////////////////////////////TODO: see scope-query.hpp - ///////////////////////////////////////////TODO: its hard to come up with a generic implementation which yields a compatible iterator - ///////////////////////////////////////////TODO: *alternatively* just expose an Iterator of Scopes? + ScopePath& currentPath = focusStack_->top(); + currentPath.navigate (scope); + return wrapIter (currentPath.begin()); }