|
Click
|
Router configuration visitor that collects elements that match a certain cast. More...
#include <routervisitor.hh>
Public Member Functions | |
| ElementCastTracker (Router *router, const String &name, bool stopAtFirst=true) | |
| Construct an ElementCastTracker. | |
| 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 elements that match a certain cast.
When passed to Router::visit_upstream() or Router::visit_downstream(), ElementCastTracker collects the closest elements that successfully cast to name. For instance, this code will find the closest Storage elements upstream of [0]e:
Graph traversal stops at each matching element, so in the above example, a Storage element that is "behind" another Storage element won't be returned.
|
inline |
Construct an ElementCastTracker.
| router | the router to be traversed |
| name | the cast of interest |
|
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.