Implements a Broadcaster for a given MessageType and BroadcasterState. More...
#include <ikarus/utils/broadcaster/broadcaster.hh>
Public Types | |
| using | MessageType = MT |
| using | State = S |
| using | Callback = std::function< void(MT, const State &)> |
| using | Token = std::shared_ptr< Callback > |
Public Member Functions | |
| Token | registerListener (Callback callback) |
| This method is used to register a Listener function. More... | |
| void | unregisterListener (Token token) |
| deregisters a specific function More... | |
| void | notify (MT message, const State &data) |
| This calls all the registered functions. More... | |
| MT | the message type |
| S | the broadcaster state |
| using Ikarus::Broadcaster< MT, S >::Callback = std::function<void(MT, const State&)> |
| using Ikarus::Broadcaster< MT, S >::MessageType = MT |
| using Ikarus::Broadcaster< MT, S >::State = S |
| using Ikarus::Broadcaster< MT, S >::Token = std::shared_ptr<Callback> |
|
inline |
|
inline |
The function that is passed in is first stored in a shared_ptr. After this, the shared_ptr is added to the vector of listener functions, which leads to a implicit conversion to a weak_ptr. The shared_ptr is then returned to the Listener that has called this function to be stored in a vector of shared_ptr<void> listener.hh.
| callback | the callback function |
|
inline |