1
Fork 0
mirror of https://github.com/SapphireServer/Sapphire.git synced 2025-04-27 14:57:44 +00:00
sapphire/src/common/Event/EventDispatcher.h
2023-02-21 14:30:41 +01:00

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;
};
}