|
Event-Driven Programming in C++ 1.0
A case study on event-driven programming in C++
|
A simple class for handling callback events. More...
#include <callbacks.hpp>
Public Types | |
| using | Callback = std::function< void()> |
| Type alias for a callback function. | |
Public Member Functions | |
| void | setCallback (Callback cb) |
| Sets the callback function. | |
| void | trigger () |
| Triggers the event. | |
Private Attributes | |
| Callback | callback_ |
| The callback function to be triggered. | |
A simple class for handling callback events.
The Event class allows clients to register a callback function which will be invoked when the event is triggered.
| using callbacks::Event::Callback = std::function<void()> |
Type alias for a callback function.
Represents a callable that takes no arguments and returns void.
| void callbacks::Event::setCallback | ( | Callback | cb | ) |
Sets the callback function.
Assigns the callback function that will be invoked when trigger() is called.
| cb | The callback function to set. |
| void callbacks::Event::trigger | ( | ) |
Triggers the event.
Invokes the stored callback function if one has been set.
|
private |
The callback function to be triggered.