(draft) maybe solved the problem defining a scope iterator

actually that would require to extract the IterTraits
from iter-adapter.hpp to allow for such dedicate specialisations
This commit is contained in:
Fischlurch 2010-10-05 04:12:17 +02:00
parent 2c58e595c0
commit e5de12fc7a
3 changed files with 70 additions and 18 deletions

View file

@ -81,14 +81,21 @@
#include <boost/type_traits/remove_const.hpp>
namespace mobject {
namespace session {
class Scope;
}}
#include <vector>
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<typename TY>
struct IterTraits
@ -113,8 +120,20 @@ namespace lib {
typedef const TY& reference;
typedef const TY* pointer;
};
using mobject::session::Scope;
template<>
struct IterTraits<vector<Scope>::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<POS>::pointer pointer;
typedef typename IterTraits<POS>::reference reference;
typedef typename IterTraits<POS>::value_type value_type;
typedef typename iter::IterTraits<POS>::pointer pointer;
typedef typename iter::IterTraits<POS>::reference reference;
typedef typename iter::IterTraits<POS>::value_type value_type;
IterAdapter (CON src, POS const& startpos)
: source_(src)
@ -299,9 +318,9 @@ namespace lib {
IT e_;
public:
typedef typename IterTraits<IT>::pointer pointer;
typedef typename IterTraits<IT>::reference reference;
typedef typename IterTraits<IT>::value_type value_type;
typedef typename iter::IterTraits<IT>::pointer pointer;
typedef typename iter::IterTraits<IT>::reference reference;
typedef typename iter::IterTraits<IT>::value_type value_type;
RangeIter (IT const& start, IT const& end)
: p_(start)

View file

@ -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 <boost/scoped_ptr.hpp>
@ -74,12 +75,16 @@ namespace session {
typename ScopeQuery<MO>::iterator
query (Scope);
ScopeQuery<MObject>::iterator
locate (Scope scope);
template<typename MO>
typename ScopeQuery<MO>::iterator
getRawPath (Scope);
ScopeQuery<MObject>::iterator
getRawPath (Scope);
lib::IterSource<const Scope>::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<typename MO>
inline typename ScopeQuery<MO>::iterator
ScopeLocator::getRawPath (Scope scope)
{
return ScopeQuery<MO> (scope.getTop(), PATH).resolveBy (theResolver());
}
inline ScopeQuery<MObject>::iterator
ScopeLocator::getRawPath (Scope scope)
{

View file

@ -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 <vector>
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<vector<Scope>::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<MObject>::iterator
IterSource<const Scope>::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());
}