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
openmsx::MSXEventDistributor::MSXEventDistributor
MSXEventDistributor(const MSXEventDistributor &)=delete
openmsx::MSXEventDistributor
Definition: MSXEventDistributor.hh:14
openmsx::MSXEventDistributor::MSXEventDistributor
MSXEventDistributor()=default
openmsx::MSXEventListener
Definition: MSXEventListener.hh:12
openmsx::MSXEventDistributor::distributeEvent
void distributeEvent(const EventPtr &event, EmuTime::param time)
Deliver the event to all registered listeners.
Definition: MSXEventDistributor.cc:29
openmsx::MSXEventDistributor::operator=
MSXEventDistributor & operator=(const MSXEventDistributor &)=delete
openmsx::MSXEventDistributor::EventPtr
std::shared_ptr< const Event > EventPtr
Definition: MSXEventDistributor.hh:16
openmsx::MSXEventDistributor::unregisterEventListener
void unregisterEventListener(MSXEventListener &listener)
Unregisters a previously registered event listener.
Definition: MSXEventDistributor.cc:24
EmuTime.hh
openmsx::MSXEventDistributor::~MSXEventDistributor
~MSXEventDistributor()
Definition: MSXEventDistributor.cc:8
openmsx
Thanks to enen for testing this on a real cartridge:
Definition: Autofire.cc:5
openmsx::MSXEventDistributor::registerEventListener
void registerEventListener(MSXEventListener &listener)
Registers a given object to receive certain events.
Definition: MSXEventDistributor.cc:18