Navigator: res-structure inheritance chain to allow passing current position
we need to layer our Navigator implementation on top, since this object needs to capture a reference to the "current position". This is necessary to be able to derive the child position by extending and then to form a child navigator -- which is the essence of implementing expandChildren()
This commit is contained in:
parent
30a90166fb
commit
c007fbda43
1 changed files with 25 additions and 10 deletions
|
|
@ -156,7 +156,8 @@ namespace interact {
|
||||||
% depth
|
% depth
|
||||||
% path
|
% path
|
||||||
);
|
);
|
||||||
return childSequence(node, depth);
|
return TreeStructureNavigator::buildIterator(
|
||||||
|
childNavigator (node, depth));
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
@ -217,34 +218,48 @@ namespace interact {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class PAR>
|
||||||
class GenNodeNavigator
|
class GenNodeNavigator
|
||||||
: public TreeStructureNavigator
|
: public PAR
|
||||||
{
|
{
|
||||||
|
Rec const& pos_;
|
||||||
|
size_t depth_;
|
||||||
|
|
||||||
virtual TreeStructureNavigator*
|
virtual TreeStructureNavigator*
|
||||||
expandChildren() const override
|
expandChildren() const override
|
||||||
{
|
{
|
||||||
UNIMPLEMENTED ("build an iterator to yield the children. This requires to remember who we are ourselves.");
|
UNIMPLEMENTED ("build an iterator to yield the children. This requires to remember who we are ourselves.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
template<class IT>
|
||||||
|
GenNodeNavigator(Rec const& node, size_t depth, IT&& rawChildIter)
|
||||||
|
: PAR{forward<IT> (rawChildIter)}
|
||||||
|
, pos_{node}
|
||||||
|
, depth_{depth}
|
||||||
|
{ }
|
||||||
};
|
};
|
||||||
|
|
||||||
template<class IT>
|
template<class IT>
|
||||||
static auto
|
static TreeStructureNavigator*
|
||||||
expandableIterSource(IT && rawIterator)
|
buildNavigator (Rec const& node, size_t depth, IT && rawIterator)
|
||||||
{
|
{
|
||||||
return TreeStructureNavigator::buildIterator(
|
return new GenNodeNavigator<
|
||||||
new lib::WrappedLumieraIter<IT, GenNodeNavigator> {forward<IT> (rawIterator)});
|
lib::WrappedLumieraIter<IT,
|
||||||
|
TreeStructureNavigator>> {node, depth, forward<IT> (rawIterator)};
|
||||||
}
|
}
|
||||||
|
|
||||||
static ChildIter
|
static TreeStructureNavigator*
|
||||||
childSequence (Rec const& node, size_t& depth)
|
childNavigator (Rec const& node, size_t depth)
|
||||||
{
|
{
|
||||||
//////////////////////////////////////////////////////////////////////////TICKET #1113 : capturing the string into the global Symbol table becomes obsolete, once GenNode exposes Literal as ID
|
//////////////////////////////////////////////////////////////////////////TICKET #1113 : capturing the string into the global Symbol table becomes obsolete, once GenNode exposes Literal as ID
|
||||||
auto internedString = [](string const& id) -> Literal
|
auto internedString = [](string const& id) -> Literal
|
||||||
{
|
{
|
||||||
return Symbol{id};
|
return Symbol{id};
|
||||||
};
|
};
|
||||||
return depth==UIC_PERSP? expandableIterSource(singleValIterator (internedString (node.getType())))
|
return depth==UIC_PERSP? buildNavigator (node, depth, singleValIterator (internedString (node.getType())))
|
||||||
: expandableIterSource(transformIterator (node.keys(), internedString));
|
: buildNavigator (node, depth, transformIterator (node.keys(), internedString));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue