[Click] Using the same element in several compounds

Bart Braem bart.braem at ua.ac.be
Wed Jun 8 10:40:49 EDT 2005


Op woensdag 8 juni 2005 16:06, schreef u:
> I have several compounds that should use the same instance of an
> element. But it seems not to be possible to pass an element to an
> elementclass. Only primitive objects like strings and integer are
> possible. What is the reason for this or did I miss something?

You clearly missed something. Here's some constructor code that works for me:
	MyElement* my;
	Element* other_element;
	int res = cp_va_parse(conf, this, errh, cpElement, "The element name", 
&other_element, 0);
	if(res < 0) return res;
	if (other_element->class_name() != "ElementName"){
		errh->error("Supplied element is not an ElementName element but a 
%s",other_element->class_name());
		return -1;
	}
	if (!(my=(MyElement*)other_element)){
		errh->error("Supplied element is not a valid ElementName element (cast 
failed)");
		return -1;
	}
	
	return 0;

Bart


More information about the click mailing list