Click
Loading...
Searching...
No Matches
Public Member Functions | List of all members
ElementCastTracker Class Reference

Router configuration visitor that collects elements that match a certain cast. More...

#include <routervisitor.hh>

Inheritance diagram for ElementCastTracker:
ElementTracker RouterVisitor

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.
 

Detailed Description

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:

ElementCastTracker tracker(e->router(), "Storage");
e->router()->visit_upstream(e, 0, &tracker);
tracker.elements(); // a Vector<Element *> containing the Storage elements
Router configuration visitor that collects elements that match a certain cast.
Definition routervisitor.hh:157

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.

Constructor & Destructor Documentation

◆ ElementCastTracker()

ElementCastTracker::ElementCastTracker ( Router *  router,
const String &  name,
bool  stopAtFirst = true 
)
inline

Construct an ElementCastTracker.

Parameters
routerthe router to be traversed
namethe cast of interest

Member Function Documentation

◆ visit()

bool ElementCastTracker::visit ( Element *  e,
bool  isoutput,
int  port,
Element *  from_e,
int  from_port,
int  distance 
)
virtual

Visit an element.

Parameters
eelement being visited
isoutputtrue for output ports, false for input ports
portport number being visited
from_eelement by which e was reached
from_portport by which e/port was reached
distanceconnection distance in breadth-first search
Returns
true to continue traversing, false to stop

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.


The documentation for this class was generated from the following files: