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

Router configuration visitor that collects close-by elements. More...

#include <routervisitor.hh>

Inheritance diagram for ElementNeighborhoodTracker:
ElementTracker RouterVisitor

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.
 

Detailed Description

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:

ElementNeighborhoodTracker tracker(e->router());
e->router()->visit_upstream(e, 0, &tracker);
tracker.elements(); // Vector<Element *> containing neighboring elements
Router configuration visitor that collects close-by elements.
Definition routervisitor.hh:192

Supply the constructor's diameter argument to find a larger neighborhood than just the directly-connected elements.

Constructor & Destructor Documentation

◆ ElementNeighborhoodTracker()

ElementNeighborhoodTracker::ElementNeighborhoodTracker ( Router *  router,
int  diameter = 1 
)
inline

Construct an ElementNeighborhoodTracker.

Parameters
routerthe router to be traversed
diameterneighborhood diameter (maximum number of connections to traverse)

Member Function Documentation

◆ visit()

bool ElementNeighborhoodTracker::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: