Wink-Signals icon indicating copy to clipboard operation
Wink-Signals copied to clipboard

Signal group.

Open Wolftein opened this issue 11 years ago • 3 comments

I was thinking is possible to add signal group / order, like boost, to order signal handlers.

Wolftein avatar Apr 23 '13 21:04 Wolftein

Could you give an example of usage? Or how this could be used for an application.

miguelmartin75 avatar Apr 24 '13 12:04 miguelmartin75

An example would be:

#define NORMAL 0 #define HIGHEST 2 #define HIGH 1

EventManager.addSignal<void (Event&>("MyEvent", &Function1, NORMAL); EventManager.addSignal<void (Event&>("MyEvent", &Function2, HIGHEST); EventManager.addSignal<void (Event&>("MyEvent", &Function3, HIGH); EventManager.execute("MyEvent", &EventStructure);

Function1, Function3 and Function2 is executed in that order. The example is for a game that use delegates to make an event system.

Function1 ( setEventCancelled(canMove()); )

Funcion3 ( if( isCancelled() ) return TriggerACustomMovementEvent() )

Function2 ( if( !isCancelled() ) return; updateTiles() )

Wolftein avatar Apr 24 '13 13:04 Wolftein

One thing I'd like to mention, a signal can have multiple "slots"* (a.k.a. functions) connected to it. Are you sure you're referring to a signal? All a signal really is a wrapper for a vector of slots.

Also, I don't really have time to implement any of this anytime soon (I'm quite busy with other projects ATM). Perhaps you could do it and make a fork. If you do try to keep the same naming conventions.

*std::function, and my custom slots work with signals. Just thought I'd mention it, if I didn't in the README, as I haven't updated this library in months.

miguelmartin75 avatar Apr 24 '13 13:04 miguelmartin75