I hope you've had a great day today! I'm here to ask y'all to help me review my single header event manager that I'm using in my game.
disclaimer:
I ripped everything from these lovely people: https://austinmorlan.com/posts/entity_component_system/ ; C++ Event System - Game Engine so give me little to no credit for the ideas used, but I did write every single line myself (using they're implementations as heavy motivation).
looking for:
- if its readable
- if there are any hidden bugs (I'm an amateur c++ hobbiest programmer, ~1 year, little experience with static and used it anyway)
- features i should add (does this cover everything i need to make a small scale game? i have little experience and don't know if i covered everything)
- just an overall review would be nice (:
the goals of the event manager:
- no base event class
- events are just POD structs
- as few virtual methods as possible
- no explicit registering of events
- fast contiguous execution of functions (I don't really mind if subscribing takes longer to achieve this)
- simple api (no std::bind, lambdas, etc...)
- single header
API (Main.cpp):
tldr if you don't wanna read the code
- you can subscribe with a pod struct type and a raw function pointer
- you can unsubscribe by passing in the handle returned by the subscribe and the event type
- you can publish blocking events with the event type and the same instance of that event type (has to be pod)
- you can publish to the bus (same rules as publishing a blocking event)
- you can poll bus events by calling poll events, this is blocking
- unsubscribing does exactly what it says, needs event type and handle from subscribe.
implementation (EventManager.h):
requires c++ 17 btw
what it printed
what I'm worried about
- I'm worried the static s_Callbacks in the EventManager class is bad
- scaleability (in usage and with features)
- features I should add (in the context of opengl and windows.h gamedev)
- is there any way to get rid of the base CallbackContainer class? do I even need too?