mal-packet-weaver
C++20 packet serialization/deserialization library.
|
A system for managing and invoking callback functions. More...
#include "callback-system.hpp"
Public Types | |
using | CallbackFunction = F |
using | CallbackId = uint32_t |
using | CallbackAddress = size_t |
Public Member Functions | |
CallbackId | AddCallback (CallbackFunction const &callback) |
Add a new callback function. | |
void | RemoveCallback (CallbackId id) |
Remove a callback by its ID. | |
void | RemoveCallback (CallbackFunction const &callback) |
Remove a callback by its function object. | |
void | InvokeCallbacks (T const &data) |
Invoke all registered callbacks with the provided data. | |
Private Attributes | |
std::unordered_map< CallbackId, Callback > | callbacks_ |
std::unordered_map< CallbackId, CallbackAddress > | callback_addresses_ |
CallbackId | next_id_ = 0 |
A system for managing and invoking callback functions.
F | Type of the callback function. |
Definition at line 34 of file callback-system.hpp.
using mal_toolkit::CallbackSystem< F >::CallbackAddress = size_t |
Definition at line 39 of file callback-system.hpp.
using mal_toolkit::CallbackSystem< F >::CallbackFunction = F |
Definition at line 37 of file callback-system.hpp.
using mal_toolkit::CallbackSystem< F >::CallbackId = uint32_t |
Definition at line 38 of file callback-system.hpp.
|
inline |
Add a new callback function.
callback | The callback function to add. |
Definition at line 47 of file callback-system.hpp.
|
inline |
Invoke all registered callbacks with the provided data.
data | The data to be passed to the callbacks. |
Definition at line 89 of file callback-system.hpp.
|
inline |
Remove a callback by its function object.
callback | The callback function to remove. |
Definition at line 71 of file callback-system.hpp.
|
inline |
Remove a callback by its ID.
id | The ID of the callback to remove. |
Definition at line 60 of file callback-system.hpp.
|
private |
Definition at line 99 of file callback-system.hpp.
|
private |
Definition at line 98 of file callback-system.hpp.
|
private |
Definition at line 100 of file callback-system.hpp.