yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
yaze::EventBus Class Reference

#include <event_bus.h>

Classes

struct  HandlerEntry
 

Public Types

using HandlerId = size_t
 

Public Member Functions

template<typename T >
HandlerId Subscribe (std::function< void(const T &)> handler)
 
template<typename T >
void Publish (const T &event)
 
void Unsubscribe (HandlerId id)
 

Private Attributes

std::unordered_map< std::type_index, std::vector< HandlerEntry > > handlers_
 
HandlerId next_id_ = 1
 

Detailed Description

Definition at line 17 of file event_bus.h.

Member Typedef Documentation

◆ HandlerId

using yaze::EventBus::HandlerId = size_t

Definition at line 19 of file event_bus.h.

Member Function Documentation

◆ Subscribe()

template<typename T >
HandlerId yaze::EventBus::Subscribe ( std::function< void(const T &)> handler)
inline

Definition at line 22 of file event_bus.h.

References handlers_, and next_id_.

Referenced by yaze::editor::StatusBar::Initialize().

◆ Publish()

template<typename T >
void yaze::EventBus::Publish ( const T & event)
inline

Definition at line 35 of file event_bus.h.

References handlers_.

◆ Unsubscribe()

void yaze::EventBus::Unsubscribe ( HandlerId id)
inline

Definition at line 45 of file event_bus.h.

References handlers_.

Member Data Documentation

◆ handlers_

std::unordered_map<std::type_index, std::vector<HandlerEntry> > yaze::EventBus::handlers_
private

Definition at line 62 of file event_bus.h.

Referenced by Publish(), Subscribe(), and Unsubscribe().

◆ next_id_

HandlerId yaze::EventBus::next_id_ = 1
private

Definition at line 63 of file event_bus.h.

Referenced by Subscribe().


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