|
Mountain
1.0.0
Simple C++ 2D Game Framework
|
Encapsulates a delegate system similar to its C# implementation. More...
#include <event.hpp>
Public Types | |
| using | FunctionT = void(Args...) |
| Signature of the event function. | |
| using | StdFunctionT = std::function< FunctionT > |
Public Member Functions | |
| void | Invoke (Args... args) const |
| Invokes the currently registered events with the provided parameters. More... | |
| void | Clear () |
| Clears the event list. | |
| void | operator() (Args... args) const |
Invokes the currently registered events with the provided parameters. Effectively the same as calling Invoke. | |
| Event & | operator+= (StdFunctionT func) |
| Adds a function to the event list. More... | |
| Event & | operator-= (const StdFunctionT &func) |
| Removes a function from the event list. More... | |
Encapsulates a delegate system similar to its C# implementation.
It works by having an underlying list of functions that always return void and have the provided types as arguments The += and -= operators can be used to respectively add and remove events to the list
Event variable names should always start with 'on', for example: onUpdate, onReload, onCollision, etc...
| Args | Event function arguments |
| void Mountain::Event< Args >::Invoke | ( | Args... | args | ) | const |
Invokes the currently registered events with the provided parameters.
| args | Parameters |
| Event& Mountain::Event< Args >::operator+= | ( | StdFunctionT | func | ) |
Adds a function to the event list.
| func | Function |
| Event& Mountain::Event< Args >::operator-= | ( | const StdFunctionT & | func | ) |
Removes a function from the event list.
| func | Function |