/$$$$$$$$ /$$ /$$ /$$$$$$$$ /$$ /$$ /$$$$$$$$ /$$$$$$
| $$_____/| $$ | $$| $$_____/| $$$ | $$|__ $$__/ /$$__ $$
| $$ | $$ | $$| $$ | $$$$| $$ | $$ | $$ \__/
| $$$$$ | $$ / $$/| $$$$$ | $$ $$ $$ | $$ | $$$$$$
| $$__/ \ $$ $$/ | $$__/ | $$ $$$$ | $$ \____ $$
| $$ \ $$$/ | $$ | $$\ $$$ | $$ /$$ \ $$
| $$$$$$$$ \ $/ | $$$$$$$$| $$ \ $$ | $$ | $$$$$$/
|________/ \_/ |________/|__/ \__/ |__/ \______/
This repository contains a templated c++17 (and up) Event system that allows for clients to attach callbacks to a host which then can be invoked at any time. Could also be understood as a 'act, react' pattern.
Real-time applications typically have many things that must be interconnected. Whether its a controller input resulting in the player jumping, audio playing etc., or a time sensitive event such as a client entering a queue, this api makes it quick and easy to modulate those responses. This project started as a key element to a custom game engine, written in c++. All player and NPC actions along with the startup and shutting down of systems were driven by these events, making them crucial for a fast development.
- The following platforms are supported:
- Windows: Tested on Windows 10 Professional 64-bit.
- Linux: Tested on Ubuntu 18.04.4 LTS
- C++17 capable compiler:
- Visual C++ 15 (Visual Studio 2017)
- Clang 5+
- GCC 7+
Current documentation available on the Wiki.
Not much, it is the overhead of calling std::function times the number of hooked functions.
(if your application is slow, it is most likely not the events)
Create a wrapper function for the event.
Macro example:
//! Creates a function wrapper for an event
#define STATIC_EVENT_WRAPPER(TYPE, NAME) static TYPE& Get##NAME() { static TYPE NAME; return NAME; }
// Use example
STATIC_EVENT_WRAPPER(Event<void()>, ApplicationStart)
int main()
{
// ...
GetApplicationStart().Invoke();
// ...
return 0;
}