Hey All,
I've been debating with some coworkers how the event system works with different event types (static member HashString that gets compared), and a few things come to mind.
First, given that the type-implementation appears to duplicate the function of RTTI, has anyone considered just identifying events using RTTI? I assume that it's not really worth the overhead (one int vs the typeid struct).
Secondly, what about each event having a static list of event listeners? This removes the overhead of searching the map, as each event can simply be dispatched to that class' static list of listeners (referenced directly through that instance of the class). Similarly, listeners could register by doing EventTypeA::AddListener(listener); or something similar. The biggest downsides we came up with for this was that this then requires more identical code between event classes, and as there is no way to subclass a static and have it be unique to that subclass (other than possibly through specializing a template), it would be a little bit messier.
I'm not saying either of these things are improvements, but they've been fun to debate
Thoughts anyone?
Cheers,
RVP
I've been debating with some coworkers how the event system works with different event types (static member HashString that gets compared), and a few things come to mind.
First, given that the type-implementation appears to duplicate the function of RTTI, has anyone considered just identifying events using RTTI? I assume that it's not really worth the overhead (one int vs the typeid struct).
Secondly, what about each event having a static list of event listeners? This removes the overhead of searching the map, as each event can simply be dispatched to that class' static list of listeners (referenced directly through that instance of the class). Similarly, listeners could register by doing EventTypeA::AddListener(listener); or something similar. The biggest downsides we came up with for this was that this then requires more identical code between event classes, and as there is no way to subclass a static and have it be unique to that subclass (other than possibly through specializing a template), it would be a little bit messier.
I'm not saying either of these things are improvements, but they've been fun to debate
Thoughts anyone?
Cheers,
RVP
The post was edited 1 time, last by rickvanprim ().