openMSX
Public Types | Public Member Functions | List of all members
openmsx::StateChangeDistributor Class Reference

#include <StateChangeDistributor.hh>

Public Types

using EventPtr = std::shared_ptr< StateChange >
 

Public Member Functions

 StateChangeDistributor ()
 
 ~StateChangeDistributor ()
 
void registerListener (StateChangeListener &listener)
 (Un)registers the given object to receive state change events. More...
 
void unregisterListener (StateChangeListener &listener)
 
void registerRecorder (StateChangeRecorder &recorder)
 (Un)registers the given object to receive state change events. More...
 
void unregisterRecorder (StateChangeRecorder &recorder)
 
void distributeNew (const EventPtr &event)
 Deliver the event to all registered listeners MSX input devices should call the distributeNew() version, only the replayer should call the distributeReplay() version. More...
 
void distributeReplay (const EventPtr &event)
 
void stopReplay (EmuTime::param time)
 Explicitly stop replay. More...
 
void setViewOnlyMode (bool value)
 Set viewOnlyMode. More...
 
bool isViewOnlyMode () const
 
bool isReplaying () const
 

Detailed Description

Definition at line 14 of file StateChangeDistributor.hh.

Member Typedef Documentation

◆ EventPtr

Definition at line 17 of file StateChangeDistributor.hh.

Constructor & Destructor Documentation

◆ StateChangeDistributor()

openmsx::StateChangeDistributor::StateChangeDistributor ( )

Definition at line 10 of file StateChangeDistributor.cc.

◆ ~StateChangeDistributor()

openmsx::StateChangeDistributor::~StateChangeDistributor ( )

Definition at line 16 of file StateChangeDistributor.cc.

References contains().

Member Function Documentation

◆ distributeNew()

void openmsx::StateChangeDistributor::distributeNew ( const EventPtr event)

Deliver the event to all registered listeners MSX input devices should call the distributeNew() version, only the replayer should call the distributeReplay() version.

These two different versions are used to detect the transition from replayed events to live events. Note that a transition from live to replay is not allowed. This transition should be done by creating a new StateChangeDistributor object (object always starts in replay state), but this is automatically taken care of because replay always starts from a freshly restored snapshot.

Parameters
eventThe event

Definition at line 50 of file StateChangeDistributor.cc.

References isReplaying(), and stopReplay().

Referenced by openmsx::DiskChanger::getContainerName(), openmsx::Keyboard::transferHostKeyMatrix(), openmsx::Joystick::write(), and openmsx::RecordedCommand::~RecordedCommand().

◆ distributeReplay()

void openmsx::StateChangeDistributor::distributeReplay ( const EventPtr event)

◆ isReplaying()

bool openmsx::StateChangeDistributor::isReplaying ( ) const

◆ isViewOnlyMode()

bool openmsx::StateChangeDistributor::isViewOnlyMode ( ) const
inline

Definition at line 66 of file StateChangeDistributor.hh.

References isReplaying().

◆ registerListener()

void openmsx::StateChangeDistributor::registerListener ( StateChangeListener listener)

◆ registerRecorder()

void openmsx::StateChangeDistributor::registerRecorder ( StateChangeRecorder recorder)

(Un)registers the given object to receive state change events.

Parameters
recorderListener that will be notified when an event arrives. These two methods are very similar to the two above. The difference is that there can be at most one registered recorder. This recorder object is always the first object that gets informed about state changing events.

Definition at line 37 of file StateChangeDistributor.cc.

Referenced by openmsx::ReverseManager::~ReverseManager().

◆ setViewOnlyMode()

void openmsx::StateChangeDistributor::setViewOnlyMode ( bool  value)
inline

Set viewOnlyMode.

Call this if you don't want distributeNew events to stop replaying and go to live events (value=true).

Parameters
valuefalse if new events stop replay mode

Definition at line 65 of file StateChangeDistributor.hh.

◆ stopReplay()

void openmsx::StateChangeDistributor::stopReplay ( EmuTime::param  time)

Explicitly stop replay.

Should be called when replay->live transition cannot be signaled via a new event, so for example when we reach the end of the replay log. It's OK to call this method when replay was already stopped, in that case this call has no effect.

Definition at line 84 of file StateChangeDistributor.cc.

References isReplaying(), and openmsx::StateChangeListener::stopReplay().

Referenced by distributeNew(), and openmsx::RestoreMachineCommand::execute().

◆ unregisterListener()

void openmsx::StateChangeDistributor::unregisterListener ( StateChangeListener listener)

◆ unregisterRecorder()

void openmsx::StateChangeDistributor::unregisterRecorder ( StateChangeRecorder recorder)

Definition at line 43 of file StateChangeDistributor.cc.

Referenced by openmsx::ReverseManager::~ReverseManager().


The documentation for this class was generated from the following files: