[Click] How to reference Method Interfaces?

Eddie Kohler kohler at cs.ucla.edu
Wed Jun 4 11:42:11 EDT 2008


Hi Bjorn,

Something like

class YourElement { ... Queue *_q; ... }

int YourElement::configure(Vector<String> &conf, ErrorHandler *errh)
{
     Element *e;
     if (cp_va_kparse(conf, this, errh,
                      "QUEUE", cpkP+cpkM, cpElement, &e,
                      cpEnd) < 0)
         return -1;
     if (!(_q = static_cast<Queue *>(e->cast("Queue"))))
         return errh->error("bad QUEUE");
     return 0;
}

should work.  Now _q is a pointer to your queue.  You will need to #include 
"elements/standard/fullnotequeue.hh".  Also check out RED, QueueYankTest,...

Eddie


刘冰洋 wrote:
> Hi~, I'm a fresh man for click.
> I learned "Flow-Based Router Context", and it is said that "A can refer to B
> by name". But I couldn't find any tutorial about "Refer Element's Method
> Interface by Name".
> For example, there is a configuration:
>     ... -> q::Queue -> MyPrint(config string) -> ...
>     MyPrint() is just an element which passes packets unchanged, and will
> print any type of data as configured.
>     and i want to print q's length().
>     How can I achieve that?
> Thx!!
> 




More information about the click mailing list