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

#include <StateChangeDistributor.hh>

Public Member Functions

 StateChangeDistributor ()=default
 
 StateChangeDistributor (const StateChangeDistributor &)=delete
 
 StateChangeDistributor (StateChangeDistributor &&)=delete
 
StateChangeDistributoroperator= (const StateChangeDistributor &)=delete
 
StateChangeDistributoroperator= (StateChangeDistributor &&)=delete
 
 ~StateChangeDistributor ()
 
void registerListener (StateChangeListener &listener)
 (Un)registers the given object to receive state change events.
 
void unregisterListener (StateChangeListener &listener)
 
void registerRecorder (ReverseManager &recorder)
 (Un)registers the given object to receive state change events.
 
void unregisterRecorder (ReverseManager &recorder)
 
template<typename T , typename... Args>
void distributeNew (EmuTime::param time, Args &&...args)
 Deliver the event to all registered listeners MSX input devices should call the distributeNew() version, only the replayer should call the distributeReplay() version.
 
void distributeReplay (const StateChange &event) const
 
void stopReplay (EmuTime::param time)
 Explicitly stop replay.
 
void setViewOnlyMode (bool value)
 Set viewOnlyMode.
 
bool isViewOnlyMode () const
 
auto tempBlockNewEventsDuringReplay ()
 
bool isReplaying () const
 

Detailed Description

Definition at line 14 of file StateChangeDistributor.hh.

Constructor & Destructor Documentation

◆ StateChangeDistributor() [1/3]

openmsx::StateChangeDistributor::StateChangeDistributor ( )
default

◆ StateChangeDistributor() [2/3]

openmsx::StateChangeDistributor::StateChangeDistributor ( const StateChangeDistributor )
delete

◆ StateChangeDistributor() [3/3]

openmsx::StateChangeDistributor::StateChangeDistributor ( StateChangeDistributor &&  )
delete

◆ ~StateChangeDistributor()

openmsx::StateChangeDistributor::~StateChangeDistributor ( )

Definition at line 12 of file StateChangeDistributor.cc.

Member Function Documentation

◆ distributeNew()

template<typename T , typename... Args>
void openmsx::StateChangeDistributor::distributeNew ( EmuTime::param  time,
Args &&...  args 
)
inline

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. Instead of a 'StateChange' parameter this method takes a template-parameter 'T' and run-time parameters 'time' and '...arg' that together can construct a 'StateChange' subclass 'T'.

Definition at line 54 of file StateChangeDistributor.hh.

References isReplaying(), openmsx::ReverseManager::record(), and stopReplay().

◆ distributeReplay()

void openmsx::StateChangeDistributor::distributeReplay ( const StateChange event) const
inline

Definition at line 69 of file StateChangeDistributor.hh.

References isReplaying().

◆ isReplaying()

bool openmsx::StateChangeDistributor::isReplaying ( ) const

◆ isViewOnlyMode()

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

Definition at line 88 of file StateChangeDistributor.hh.

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

◆ operator=() [1/2]

StateChangeDistributor & openmsx::StateChangeDistributor::operator= ( const StateChangeDistributor )
delete

◆ operator=() [2/2]

StateChangeDistributor & openmsx::StateChangeDistributor::operator= ( StateChangeDistributor &&  )
delete

◆ registerListener()

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

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

Parameters
listenerListener that will be notified when an event arrives.

Definition at line 22 of file StateChangeDistributor.cc.

Referenced by openmsx::Autofire::Autofire(), openmsx::Keyboard::Keyboard(), and openmsx::RecordedCommand::RecordedCommand().

◆ registerRecorder()

void openmsx::StateChangeDistributor::registerRecorder ( ReverseManager 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 33 of file StateChangeDistributor.cc.

◆ 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 87 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 63 of file StateChangeDistributor.cc.

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

Referenced by distributeNew().

◆ tempBlockNewEventsDuringReplay()

auto openmsx::StateChangeDistributor::tempBlockNewEventsDuringReplay ( )
inline

Definition at line 90 of file StateChangeDistributor.hh.

◆ unregisterListener()

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

◆ unregisterRecorder()

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

Definition at line 39 of file StateChangeDistributor.cc.


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