|
|
|
@ -52,11 +52,11 @@ public: |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
template <typename EventType> |
|
|
|
|
class EventQueue : private Queue<EventType>{ |
|
|
|
|
std::set<Listener<EventType> *> listeners; |
|
|
|
|
template <typename T> |
|
|
|
|
class EventQueue : private Queue<T>{ |
|
|
|
|
std::set<Listener<T> *> listeners; |
|
|
|
|
void update() override { |
|
|
|
|
EventType * event = this->pop(); |
|
|
|
|
T * event = this->pop(); |
|
|
|
|
|
|
|
|
|
for (auto listener : listeners) |
|
|
|
|
listener->accept(event); |
|
|
|
@ -64,13 +64,13 @@ class EventQueue : private Queue<EventType>{ |
|
|
|
|
delete event; |
|
|
|
|
} |
|
|
|
|
public: |
|
|
|
|
void submitEvent(EventType * event){ |
|
|
|
|
void submitEvent(T * event){ |
|
|
|
|
this->push(event); |
|
|
|
|
} |
|
|
|
|
void registerListener(Listener<EventType> * listener){ |
|
|
|
|
void registerListener(Listener<T> * listener){ |
|
|
|
|
listeners.insert(listener); |
|
|
|
|
} |
|
|
|
|
void unregisterListener(Listener<EventType> * listener){ |
|
|
|
|
void unregisterListener(Listener<T> * listener){ |
|
|
|
|
listeners.erase(listener); |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|