YoggieEngine/BarinkEngine/EventSystem/EventEmitter.cpp

25 lines
535 B
C++

#include "../Include/EventSystem/EventEmitter.h"
void EventEmitter::Subscribe(EventListener& subscriber)
{
subscribers.push_back(&subscriber);
}
void EventEmitter::Unsubscribe(EventListener& subscriber)
{
subscribers.remove(&subscriber);
}
void EventEmitter::EmitEvent(Event& incident)
{
// Notify all subscribers an event has taken place
for (auto it = subscribers.begin(); it != subscribers.end(); ++it)
{
(*it)->ReceiveEvent(incident);
}
}
EventEmitter::EventEmitter() {
subscribers = std::list<EventListener*>{};
}