mirror of
https://github.com/SapphireServer/Sapphire.git
synced 2025-04-27 14:57:44 +00:00
24 lines
454 B
C++
24 lines
454 B
C++
#pragma once
|
|
#include <functional>
|
|
#include "Event.h"
|
|
#include <unordered_map>
|
|
|
|
namespace Sapphire::Common::EventSystem
|
|
{
|
|
|
|
class EventDispatcher
|
|
{
|
|
public:
|
|
using SlotType = std::function< void( const Event& ) >;
|
|
|
|
void subscribe( const Event::DescriptorType& descriptor, SlotType&& slot );
|
|
|
|
void emit( const Event& event ) const;
|
|
|
|
private:
|
|
std::unordered_map< Event::DescriptorType, std::vector< SlotType > > m_observers;
|
|
|
|
};
|
|
|
|
}
|
|
|