Event-Driven Programming in C++ 1.0
A case study on event-driven programming in C++
Loading...
Searching...
No Matches
callbacks::Event Class Reference

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.
 

Detailed Description

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.

Member Typedef Documentation

◆ Callback

using callbacks::Event::Callback = std::function<void()>

Type alias for a callback function.

Represents a callable that takes no arguments and returns void.

Member Function Documentation

◆ setCallback()

void callbacks::Event::setCallback ( Callback  cb)

Sets the callback function.

Assigns the callback function that will be invoked when trigger() is called.

Parameters
cbThe callback function to set.

◆ trigger()

void callbacks::Event::trigger ( )

Triggers the event.

Invokes the stored callback function if one has been set.

Member Data Documentation

◆ callback_

Callback callbacks::Event::callback_
private

The callback function to be triggered.


The documentation for this class was generated from the following files: