| 1 |
#ifndef MSXEVENTDISTRIBUTOR_HH |
| 2 |
#define MSXEVENTDISTRIBUTOR_HH |
| 3 |
|
| 4 |
#include "EmuTime.hh" |
| 5 |
#include "Event.hh" |
| 6 |
#include <vector> |
| 7 |
|
| 8 |
namespace openmsx { |
| 9 |
|
| 10 |
class MSXEventListener; |
| 11 |
|
| 12 |
class MSXEventDistributor |
| 13 |
{ |
| 14 |
public: |
| 15 |
MSXEventDistributor() = default; |
| 16 |
MSXEventDistributor(const MSXEventDistributor&) = delete; |
| 17 |
MSXEventDistributor(MSXEventDistributor&&) = delete; |
| 18 |
MSXEventDistributor& operator=(const MSXEventDistributor&) = delete; |
| 19 |
MSXEventDistributor& operator=(MSXEventDistributor&&) = delete; |
| 20 |
~MSXEventDistributor(); |
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
void registerEventListener(MSXEventListener& listener); |
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
void unregisterEventListener(MSXEventListener& listener); |
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
void distributeEvent(const Event& event, EmuTime time); |
| 42 |
|
| 43 |
private: |
| 44 |
[[nodiscard]] bool isRegistered(MSXEventListener* listener) const; |
| 45 |
|
| 46 |
private: |
| 47 |
std::vector<MSXEventListener*> listeners; |
| 48 |
std::vector<MSXEventListener*> listenersCopy; |
| 49 |
}; |
| 50 |
|
| 51 |
} |
| 52 |
|
| 53 |
#endif |