Mineserver
A rewrite of Minecraft 1.8.9 in C++ !
|
Handler for a type of event. More...
#include <event.h>
Public Types | |
typedef std::function< void(T &) | callbackType) |
The type of function that should be passed. | |
typedef int | subId |
The Subscription Id. | |
Public Member Functions | |
EventHandler () | |
Construct a new Event Handler object. | |
void | fire (T &event) |
Fire an event. | |
subId | subscribe (const callbackType &func) |
Subscribe to an event. | |
subId | subscribe (callbackType &&func) |
Subscribe to an event. | |
void | unsubscribe (subId id) |
Unsubscribe from an event. | |
const std::type_info * | getTypeInfo () const |
Get the Type Info of T. | |
Handler for a type of event.
T | the event that should extend IEvent |
The type of function that should be passed.
All event-receiving functions should be declared as a void return type with a single parameter, the event in question.
The Subscription Id.
Used to unsubscribe from events.
|
inline |
Construct a new Event Handler object.
It will not compile if you try it with a class that does not derive from IEvent
Fire an event.
Cascade the event to all of the listeners
event | the event |
|
inline |
Get the Type Info of T.
Returns the type info of T
|
inline |
Subscribe to an event.
Subscribe to an event for rvalue functions
func | the function that will listen to events |
|
inline |
Subscribe to an event.
Subscribe to an event for lvalue functions
func | the function that will listen to events |
Unsubscribe from an event.
Stop listening from events
id | the id of the listener |