[Click] using handlers

Johan Theunis johan.theunis at esat.kuleuven.be
Mon Mar 27 08:37:21 EST 2006


I.E.Pearce-02 at student.lboro.ac.uk wrote:

>Hi,
>
>I have a question about handlers. I want to read a value from an upstream
>element using a handlercall. I am trying to read the value "diffs" from the
>upstream ComparePackets element using the below code.
>
>int
>TOSUnqueue::configure(Vector<String> &conf, ErrorHandler *errh)
>{
>String rate_str = HandlerCall::call_read(Element *ComparePackets,"diffs",
>errh);
>unsigned different;
>(void) cp_unsigned(cp_uncomment(rate_str), &different);
>
>.....
>
>I have put this code in the configure part of my element. However I keep
>recieving the below error when tryin to compile the element.
>
>
>tosunqueue.cc: In member function `virtual int
>   TOSUnqueue::configure(Vector<String>&, ErrorHandler*)':
>tosunqueue.cc:51: error: parse error before `*' token
>make: *** [tosunqueue.uo] Error 1
>
>Can anyone help me with this error?
>
>It is quite urgent i get this working as quickly as possibe so a quick
>response would be greatly appreciated.
>
>Thanks
>
>Ian
>
>
>
>
>
>_______________________________________________
>click mailing list
>click at amsterdam.lcs.mit.edu
>https://amsterdam.lcs.mit.edu/mailman/listinfo/click
>  
>
Ian,

A solution to your problem is:

1. in your click configuration, give the ComparePackets element a name 
-> comppacks :: ComparePackets(...);
2. put this name in the config string of TOSUnqueue element -> 
TOSUnqueue(comppacks, ...);
3. in tosunqueue.cc, put the following code:

int
TOSUnqueue::configure(Vector<String> &conf, ErrorHandler *errh)
{
  int result = cp_va_parse(conf, this, errh,
             		   cpElement, "ComparePackets element", &_cpack,
			   ... // if you want to parse other params
             		   0);
  ...

Don't forget to add to tosunqueue.hh -> Element *_cpack; 

4. Now you can call the handler of the ComparePackets element by calling:

String handler_name = String("diffs"); //whatever name you give to the Handler
String rate_str = HandlerCall::call_read(_cpack, handler_name, errh);

Hope this helps,

Johan



-- 
Johan Theunis
Dept. ESAT-Telemic
K.U.Leuven, Belgium
Tel. +32 16 32 18 22


Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm



More information about the click mailing list