[Click] Compile a non-element class in Click

Giovanni Di Stasi gdistasi at gmail.com
Thu Sep 4 09:23:57 EDT 2008


On Thursday 04 September 2008 12:32:18 Tushar Soni wrote:
> Well as you mentioned, it is a non-element class. So due to this reason it
> wont be present in elements.conf file.
>
The directive ELEMENT_PROVIDES is supposed to tell Click that I want it to 
compile that class too.

> Now your class will be compiled when there is a call to this class. That
> could for example creating an object of this class.
>
> Say i have non-element class NEC and it is defined in nec.hh and nec.cc. I
> have an elemental class called EC and it is defined in ec.hh and ec.cc.
>
> /*ec.hh*/
> #ifndef EC_HH
> #define EC_HH
> //include the necessary headers
>
> #include "nec.hh"
>
> CLICK_DECLS
>
> class EC: public Element
> {
>     //some code
>     NEC _nec_obj,
>     //some code
> }
>
>
> CLICK_ENDDECLS
> #endif
>
> /*ec.cc*/
> //include the necessary header
>
> CLICK_DECLS
>
> //your code
>
> CLICK_DECLS
>
> #include "nec.cc" //this is required if you have functions of the class
> defined in nec.cc (not required if you have inline functions in nec.hh)
>
This is a nice workaround (and it is helpful in my case), but doesn't work 
well when you have multiple elements that require that class, as you have 
duplication of the code.


-- 
Giovanni Di Stasi, Junior Researcher
Dipartimento di Informatica e Sistemistica
Università degli Studi di Napoli "Federico II"
Via Claudio, 21 - 80125 Napoli - Italy

Phone:    +39 081 7683821
Fax:      +39 081 7683816
E-mail:   giovanni.distasi at unina.it



More information about the click mailing list