[Click] dynamic_cast ?
Eddie Kohler
kohler at cs.ucla.edu
Mon Nov 9 00:54:50 EST 2009
Hi Harald,
Click elements don't know what element(s) are connected to a push input port,
or a pull output port. This is because it is valid for one or more elements
to connect there.
So if e->input_is_push(i), then e->input(i).element() == 0.
To find the element or elements connected to a push input port, use
Router functions to traverse the element graph. I've just checked in a rework
of this functionality that should help you. On current mainline, you could say:
#include <click/routervisitor.hh>
...
ElementNeighborTracker tracker(router());
router()->visit_upstream(this, 0, &tracker);
tracker.elements() // is a vector containing exactly those elements
// that are connected to [0]this
Does this make sense?
Eddie
Harald Schiöberg wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Eddie Kohler wrote:
>> Hi Harald,
>>
>> Click already provides a cast() method on Element that should do what
>> you want.
>
> Thanks a lot, apparently I'm to blind to see the obvious.
>
> yet (completly off-topic) this segfaults:
>
> int
> MultiFlowDispatcher::initialize(ErrorHandler * errh ) {
>
> int i;
> for (i=0; i<=1; i++){
> if ( input(i).element()->cast("MultiFlowDispatcher") ){
>
>
> and the debugger tells me that the input has no element
>
> (gdb) p input(0)
> $1 = (const Element::Port &) @0x826d324: {_e = 0x0, _port = -1}
>
> are the neighbors not known at initialization time?
> Is there anything better than this really ugly thing:
>
> MultiFlowDispatcher::push( ) {
> if (!_neighbor_config)
> do_neighbor_config()
> }
>
>
> - --
> Harald Schiöberg
> Technische Universität Berlin | T-Laboratories | FG INET
> www: http://www.net.t-labs.tu-berlin.de
> Phone: +49-(0)30-8353-58476 | Fax: +49-(0)391 534 783 47
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.6 (GNU/Linux)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
>
> iD8DBQFK9DyNy8wrZ9OvkU0RAsl+AJ4+8Y5EP/j8ZlOt7dG78svoqE+uZgCfbmBu
> 6CCRyQO7iXU0u1R39ce5nx0=
> =D1SM
> -----END PGP SIGNATURE-----
More information about the click
mailing list