Provide python-esque iterables for packet children
Software for 3-manifold topology and normal surface theory
Brought to you by:
bab
To iterate over a tree in the GUI, you usually have the following code
child = root.getFirstTreeChild()
while child:
doThings(child)
child = child.getNextTreeSibling()
A nicer approach would be to use the python for-each construct:
for child in root.children():
doThings(child)
Couple of questions. I've currently implemented this in the Python bindings. It basically involves creating an STL iterator for NPacket, then wrapping the iterator. This way we avoid pulling in any STL iterator things into NPacket/the C++ engine.
Is that the best way forward? An alternate approach is to implement begin(), end() and operator++() in NPacket itself. This could work fairly easily, but I don't know if we want to avoid pulling in any extra STL things into NPacket?
Also, I don't know how to document this. I think this is the first time I've got a function I want to document but only for python, which I think means I can't just make a function prototype. I guess that's one advantage to adding the STL iterator into the engine.
Code is in the "python-iterable" fork.