openMSX
MSXEventDistributor.hh
Go to the documentation of this file.
1 #ifndef MSXEVENTDISTRIBUTOR_HH
2 #define MSXEVENTDISTRIBUTOR_HH
3 
4 #include "EmuTime.hh"
5 #include <memory>
6 #include <vector>
7 
8 namespace openmsx {
9 
10 class MSXEventListener;
11 class Event;
12 
14 {
15 public:
16  using EventPtr = std::shared_ptr<const Event>;
17 
20 
21  MSXEventDistributor() = default;
23 
29 
35 
43  void distributeEvent(const EventPtr& event, EmuTime::param time);
44 
45 private:
46  bool isRegistered(MSXEventListener* listener) const;
47 
48  std::vector<MSXEventListener*> listeners; // unordered
49 };
50 
51 } // namespace openmsx
52 
53 #endif
std::shared_ptr< const Event > EventPtr
void registerEventListener(MSXEventListener &listener)
Registers a given object to receive certain events.
void distributeEvent(const EventPtr &event, EmuTime::param time)
Deliver the event to all registered listeners.
void unregisterEventListener(MSXEventListener &listener)
Unregisters a previously registered event listener.
Thanks to enen for testing this on a real cartridge:
Definition: Autofire.cc:5
MSXEventDistributor & operator=(const MSXEventDistributor &)=delete