Wink-Signals
Wink-Signals copied to clipboard
Signal group.
I was thinking is possible to add signal group / order, like boost, to order signal handlers.
Could you give an example of usage? Or how this could be used for an application.
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() )
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.