openMSX
StateChangeDistributor.hh
Go to the documentation of this file.
1 #ifndef STATECHANGEDISTRIBUTOR_HH
2 #define STATECHANGEDISTRIBUTOR_HH
3 
4 #include "EmuTime.hh"
5 #include <memory>
6 #include <vector>
7 
8 namespace openmsx {
9 
10 class StateChangeListener;
11 class StateChangeRecorder;
12 class StateChange;
13 
15 {
16 public:
17  using EventPtr = std::shared_ptr<StateChange>;
18 
21 
25  void registerListener (StateChangeListener& listener);
27 
35  void registerRecorder (StateChangeRecorder& recorder);
37 
49  void distributeNew (const EventPtr& event);
50  void distributeReplay(const EventPtr& event);
51 
58  void stopReplay(EmuTime::param time);
59 
65  void setViewOnlyMode(bool value) { viewOnlyMode = value; }
66  bool isViewOnlyMode() const { return viewOnlyMode; }
67 
68  bool isReplaying() const;
69 
70 private:
71  bool isRegistered(StateChangeListener* listener) const;
72  void distribute(const EventPtr& event);
73 
74  std::vector<StateChangeListener*> listeners; // unordered
75  StateChangeRecorder* recorder;
76  bool viewOnlyMode;
77 };
78 
79 } // namespace openmsx
80 
81 #endif
void unregisterListener(StateChangeListener &listener)
void distributeNew(const EventPtr &event)
Deliver the event to all registered listeners MSX input devices should call the distributeNew() versi...
void registerListener(StateChangeListener &listener)
(Un)registers the given object to receive state change events.
void stopReplay(EmuTime::param time)
Explicitly stop replay.
std::shared_ptr< StateChange > EventPtr
void unregisterRecorder(StateChangeRecorder &recorder)
void registerRecorder(StateChangeRecorder &recorder)
(Un)registers the given object to receive state change events.
void distributeReplay(const EventPtr &event)
Thanks to enen for testing this on a real cartridge:
Definition: Autofire.cc:5
void setViewOnlyMode(bool value)
Set viewOnlyMode.