new Event parameters

For help with anything that CEGUI doesn't offer straight out-of-the-box, e.g.:
- Implementation of new features, such as new Core classes, widgets, WindowRenderers, etc. ...
- Modification of any existing features for specific purposes
- Integration of CEGUI in new engines or frameworks and writing of new plugins (Renderer, Parser, ...) or modules

Moderators: CEGUI MVP, CEGUI Team

User avatar
spannerman
Home away from home
Home away from home
Posts: 330
Joined: Wed Jan 12, 2005 12:06

new Event parameters

Postby spannerman » Tue Dec 14, 2004 19:18

Hi Eddie,

I posted this question in the wrong forum at one point, so you may have seen it briefly, but here it is again.

I am upgrading my application to use the new event subscription technique...I have been holding off doing it for a while but Ive heard that the new way yields better performance. It's all going well, but I have a few lines that I cant get to compile anymore, and these concern the passing of some extra parameters to my method which handles the event.

So, for example, I used to use this line of code which subscribed an event and in addition passed the String "Basic" through to my handlePanelShown method:


Code: Select all

myPanel->subscribeEvent( StaticText::EventShown,boost::bind(&MyWindow::handlePanelShown, this, _1, "Basic") );


The new way which does away with boost and uses the Subscriber probably should look something like this:

Code: Select all

myPanel->subscribeEvent( StaticText::EventShown,Event::Subscriber(&MyWindow::handlePanelShown, this,  "Basic") );


except this no longer compiles. The error says I am passing the wrong number of arguments, but my handlePanelShown method has not changed.

Any ideas what I might be doing wrong?

User avatar
nfz
Not too shy to talk
Not too shy to talk
Posts: 27
Joined: Wed Jan 12, 2005 12:06

new Event parameters

Postby nfz » Tue Dec 14, 2004 19:53

I know I am not CE but I'll make a stab at this since I started you on the change and I suspected this would cause a headache for you.

Event::Subscriber template does not support user definable number of arguments like boost::bind does. I think you have two alternatives. The first one is to change your design a bit and pass those user defined arguments by some other means or setup some state machines. The second option is to continue using boost::bind for those methods that take more arguments than the Event::Subscriber does and live with the overhead for those few methods that use it.

User avatar
spannerman
Home away from home
Home away from home
Posts: 330
Joined: Wed Jan 12, 2005 12:06

new Event parameters

Postby spannerman » Tue Dec 14, 2004 21:17

Aah, ok, Cheers nfz. I dont fancy going back to boost so I'll get some alternative going instead. Like you said, not too many methods are affected so shouldnt be too bad.

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

new Event parameters

Postby CrazyEddie » Wed Dec 15, 2004 09:30

Hi,

These would have been my suggestions too :D

The approach I would take would probably be to code a template functor class that could accept additional parameters (or something of that nature).

CE.


Return to “Modifications / Integrations / Customisations”

Who is online

Users browsing this forum: No registered users and 8 guests