Hardware tree iterator tools
Summary
Add iteration tools to conveniently loop over nodes in the hardware tree.
Iterator
There will be one iterator, recursive_iterator
, accessed as a boost::range
from the parent
class. Its intended usage is as follows (types expanded for demonstration purposes only, real-world example would use auto
):
for (const std::shared_ptr<node> &child: oh.recursive_children()) {
This will be symmetric with the parent
class accessor for children:
for (const std::shared_ptr<node> &child: oh.children()) {
Filter
There will be a range filter (using boost::range
since std::range
is C++ 20):
for (const vfat &vfat: oh.children() | filtered_children<vfat>) {
Note that:
- The filter dereferences the pointer
- According to the current naming convention,
filtered_children
should be spelled asFILTERED_CHILDREN
because it's a static variable (templated, and of an empty class). However the above syntax works much better in lowercase.