|
Click
|
Router configuration visitor that collects close-by elements. More...
#include <routervisitor.hh>
Public Member Functions | |
| ElementNeighborhoodTracker (Router *router, int diameter=1) | |
| Construct an ElementNeighborhoodTracker. | |
| bool | visit (Element *e, bool isoutput, int port, Element *from_e, int from_port, int distance) |
| Visit an element. | |
Public Member Functions inherited from ElementTracker | |
| ElementTracker (Router *router) | |
| Construct an ElementTracker. | |
| const Vector< Element * > & | elements () const |
| Return the elements that matched. | |
| int | size () const |
| Return the number of matching elements. | |
| Element * | operator[] (int i) const |
| Return the i'th matching element. | |
| const_iterator | begin () const |
| Return an iterator for the first matching element. | |
| const_iterator | end () const |
| Return an iterator for the end of the container. | |
| bool | contains (const Element *e) const |
| Return true iff element e is a matching element. | |
| void | insert (Element *e) |
| Add element e to the set of matching elements. | |
| void | clear () |
| Clear the set of matching elements. | |
Public Member Functions inherited from RouterVisitor | |
| RouterVisitor () | |
| Construct an RouterVisitor. | |
| virtual | ~RouterVisitor () |
| Destroy an RouterVisitor. | |
| virtual int | distance (Element *e, Element *from_e) |
| return the distance between two neighbour elements | |
Additional Inherited Members | |
Public Types inherited from ElementTracker | |
| typedef Vector< Element * >::const_iterator | const_iterator |
| Iterator type. | |
Router configuration visitor that collects close-by elements.
When passed to Router::visit_upstream() or Router::visit_downstream(), ElementNeighborhoodTracker collects the elements that are within a certain number of connections of the source element. For instance, this code will find all the elements connected to [0]e:
Supply the constructor's diameter argument to find a larger neighborhood than just the directly-connected elements.
|
inline |
Construct an ElementNeighborhoodTracker.
| router | the router to be traversed |
| diameter | neighborhood diameter (maximum number of connections to traverse) |
|
virtual |
Visit an element.
| e | element being visited |
| isoutput | true for output ports, false for input ports |
| port | port number being visited |
| from_e | element by which e was reached |
| from_port | port by which e/port was reached |
| distance | connection distance in breadth-first search |
A Router configuration traversal calls this function once on each reached port. Configuration traversal is breadth-first; distance is the minimum connection distance from the traversal's start point to e/port. A traversal will call a port's visit() function at most once. from_e and from_port specify one port that is connected to e and port (there may be more than one). If isoutput is true, then e/port is an output port and from_e/from_port is an input port; if isoutput is false, the opposite holds.
The return value specifies whether traversal should continue through the e element. If it is true, then the traversal will continue based on e's packet flow specifier, via ports that connect to e/port (see Element::flow_code() for more).
The default implementation always returns true.
Reimplemented from RouterVisitor.