Doxygen with github
Loading...
Searching...
No Matches
ksf::evt::ksEvent< Params > Class Template Reference

Base class for multicasting events. More...

#include <ksEvent.h>

+ Inheritance diagram for ksf::evt::ksEvent< Params >:

Public Member Functions

bool isBound () const
 Returns whether any callback is bound to this event.
 
void registerEvent (std::unique_ptr< ksf::evt::ksEventHandle > &outHandle, std::function< void(Params...)> &&function)
 Registers event (binds to callback list).
 
void unbind (std::size_t callbackUID) override
 Unbinds event callback by specified unique ID.
 
void broadcast (Params... params)
 Broadcasts event to all bound callbacks.
 

Protected Attributes

std::vector< std::pair< std::size_t, std::function< void(Params...)> > > callbacks
 List of bond callbacks.
 
std::size_t lastCallbackUID {0}
 Last unique callback ID for this event (used as counter).
 

Additional Inherited Members

- Protected Member Functions inherited from ksf::evt::ksEventInterface

Detailed Description

template<typename... Params>
class ksf::evt::ksEvent< Params >

Base class for multicasting events.

Template Parameters
Params...Event parameters.

Member Function Documentation

◆ broadcast()

◆ isBound()

template<typename... Params>
bool ksf::evt::ksEvent< Params >::isBound ( ) const
inline

Returns whether any callback is bound to this event.

Returns
True if any callback is bound to this event. False otherwise.

References ksf::evt::ksEvent< Params >::callbacks.

Referenced by ksf::comps::ksMqttConnector::mqttMessageInternal().

◆ registerEvent()

template<typename... Params>
void ksf::evt::ksEvent< Params >::registerEvent ( std::unique_ptr< ksf::evt::ksEventHandle > & outHandle,
std::function< void(Params...)> && function )
inline

Registers event (binds to callback list).

Parameters
outHandleReference to outHandle shared ptr (destruction of ksEventHandle object will unbind the event)
functionR-value reference to callback function

References ksf::evt::ksEvent< Params >::callbacks, and ksf::evt::ksEvent< Params >::lastCallbackUID.

Referenced by ksf::comps::ksDevStatMqttReporter::postInit().

◆ unbind()

template<typename... Params>
void ksf::evt::ksEvent< Params >::unbind ( std::size_t callbackUID)
inlineoverridevirtual

Unbinds event callback by specified unique ID.

This ID is automatically assigned by registerEvent function and ksEventHandle uses it to unbind automatically upon destruction.

Parameters
callbackUIDUnique id of the callback to unbind.

Implements ksf::evt::ksEventInterface.

References ksf::evt::ksEvent< Params >::callbacks.


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