GXemul Class Reference

Back to the index.

Public Types | Public Member Functions | Static Public Member Functions | List of all members
GXemul Class Reference

The main emulator class. More...

#include <GXemul.h>

Public Types

enum  RunState { Paused, SingleStepping, Running, Quitting }
 

Public Member Functions

 GXemul ()
 Creates a GXemul instance. More...
 
bool ParseFilenames (string templateMachine, int filenameCount, char *filenames[])
 Parses command line arguments (file names). More...
 
void ClearEmulation ()
 Discards the current emulation, and starts anew with just an empty root component. More...
 
void InitUI ()
 Initializes the UI. More...
 
int Run ()
 Runs GXemul's main loop. More...
 
const string & GetEmulationFilename () const
 Gets the current emulation setup's filename. More...
 
void SetEmulationFilename (const string &filename)
 Sets the current emulation setup's filename. More...
 
CommandInterpreterGetCommandInterpreter ()
 Gets a reference to the CommandInterpreter. More...
 
UIGetUI ()
 Gets a pointer to the GXemul instance' active UI. More...
 
refcount_ptr< ComponentGetRootComponent ()
 Gets a pointer to the root configuration component. More...
 
const refcount_ptr< ComponentGetRootComponent () const
 
void SetRootComponent (refcount_ptr< Component > newRootComponent)
 Sets the root component, discarding the previous one. More...
 
bool Reset ()
 Resets the emulation. More...
 
void Interrupt ()
 Interrupts emulation. More...
 
bool IsInterrupting () const
 Returns whether or not the current emulation is being interrupted. More...
 
void SetRunState (RunState newState)
 Sets the RunState. More...
 
RunState GetRunState () const
 Gets the current RunState. More...
 
string GetRunStateAsString () const
 Gets the current RunState as a string. More...
 
uint64_t GetStep () const
 Gets the current step of the emulation. More...
 
bool GetSnapshottingEnabled () const
 Checks whether snapshots are currently enabled or not. More...
 
void SetSnapshottingEnabled (bool enabled)
 Sets whether or not to use snapshots. More...
 
bool GetQuietMode () const
 Gets the current quiet mode setting. More...
 
void SetQuietMode (bool quietMode)
 Sets whether or not to run in quiet mode. More...
 
void SetNrOfSingleStepsInARow (uint64_t steps)
 Sets the nr of single-steps to perform in a row. More...
 
bool ModifyStep (int64_t oldStep, int64_t newStep)
 Change step either forwards or backwards. More...
 
void Execute (const int longestTotalRun=100000)
 Run the emulation for "a while". More...
 
bool IsTemplateMachine (const string &templateName) const
 

Static Public Member Functions

static void ListTemplates ()
 Dump a list to stdout with all available machine templates. More...
 
static string Version ()
 Returns the GXemul version string. More...
 
static void DumpMachineAsHTML (const string &machineName)
 
static void GenerateHTMLListOfComponents (bool machines)
 
static void RunUnitTests (int &nSucceeded, int &nFailures)
 

Detailed Description

The main emulator class.

A GXemul instance basically has the following member variables:

  1. a tree of components, which make up the full state of the current emulation setup
  2. a UI, which runs the main [interactive] loop
  3. a CommandInterpreter
  4. a RunState
  5. a list of "on reset commands", which are executed on Reset().

Definition at line 54 of file GXemul.h.

Member Enumeration Documentation

◆ RunState

Enumerator
Paused 
SingleStepping 
Running 
Quitting 

Definition at line 57 of file GXemul.h.

Constructor & Destructor Documentation

◆ GXemul()

GXemul::GXemul ( )

Creates a GXemul instance.

Definition at line 175 of file GXemul.cc.

References ClearEmulation().

Member Function Documentation

◆ ClearEmulation()

void GXemul::ClearEmulation ( )

Discards the current emulation, and starts anew with just an empty root component.

Definition at line 192 of file GXemul.cc.

References GetRunState(), GetUI(), Paused, Running, SetRunState(), and UI::UpdateUI().

Referenced by CloseCommand::Execute(), and GXemul().

◆ DumpMachineAsHTML()

void GXemul::DumpMachineAsHTML ( const string &  machineName)
static

◆ Execute()

void GXemul::Execute ( const int  longestTotalRun = 100000)

Run the emulation for "a while".

When single-stepping, this function will:

  • execute one step,
  • set the run state to Paused,
  • and then return.

When not single-stepping, components will execute multiple steps at once, if possible. In the most common case (no breakpoints or other special cases), when this function returns, the run state will not have been affected.

Parameters
longestTotalRunMaximum number of steps to execute.

Definition at line 894 of file GXemul.cc.

Referenced by ConsoleUI::MainLoop(), and ModifyStep().

◆ GenerateHTMLListOfComponents()

void GXemul::GenerateHTMLListOfComponents ( bool  machines)
static

◆ GetCommandInterpreter()

CommandInterpreter & GXemul::GetCommandInterpreter ( )

Gets a reference to the CommandInterpreter.

Returns
A reference to the GXemul instance' CommandInterpreter.

Definition at line 631 of file GXemul.cc.

Referenced by HelpCommand::Execute(), and Reset().

◆ GetEmulationFilename()

const string & GXemul::GetEmulationFilename ( ) const

Gets the current emulation setup's filename.

Returns
The name of the file that is used for the current emulation setup. If no filename is defined yet, this is an empty string.

Definition at line 617 of file GXemul.cc.

Referenced by SaveCommand::Execute(), and LoadCommand::Execute().

◆ GetQuietMode()

bool GXemul::GetQuietMode ( ) const

Gets the current quiet mode setting.

Returns
True if running in quiet mode, false for normal operation.

Definition at line 788 of file GXemul.cc.

Referenced by Reset(), Run(), and ConsoleUI::ShowDebugMessage().

◆ GetRootComponent() [1/2]

const refcount_ptr< Component > GXemul::GetRootComponent ( )

Gets a pointer to the root configuration component.

Returns
A pointer to the root component. If no configuration tree is loaded, then this is at least an empty dummy component. (The return value is never NULL.)

Definition at line 667 of file GXemul.cc.

Referenced by BackwardStepCommand::Execute(), GetStep(), ConsoleUI::MainLoop(), Reset(), and Run().

◆ GetRootComponent() [2/2]

const refcount_ptr<Component> GXemul::GetRootComponent ( ) const

◆ GetRunState()

GXemul::RunState GXemul::GetRunState ( ) const

Gets the current RunState.

Returns
The current RunState.

Definition at line 749 of file GXemul.cc.

Referenced by ClearEmulation(), CPUDyntransComponent::DyntransToBeTranslatedDone(), CPUDyntransComponent::Execute(), Interrupt(), ConsoleUI::MainLoop(), ModifyStep(), ParseFilenames(), and Run().

◆ GetRunStateAsString()

string GXemul::GetRunStateAsString ( ) const

Gets the current RunState as a string.

Returns
The current RunState, formatted as a string.

Definition at line 755 of file GXemul.cc.

References Paused, Quitting, Running, and SingleStepping.

Referenced by StatusCommand::Execute().

◆ GetSnapshottingEnabled()

bool GXemul::GetSnapshottingEnabled ( ) const

Checks whether snapshots are currently enabled or not.

Returns
True if running in quiet mode, false for normal operation.

Definition at line 772 of file GXemul.cc.

Referenced by Component::CheckVariableWrite(), and ModifyStep().

◆ GetStep()

uint64_t GXemul::GetStep ( ) const

Gets the current step of the emulation.

Returns
The nr of steps that the emulation has been executing, since the start.

Definition at line 637 of file GXemul.cc.

References GetRootComponent(), Component::GetVariable(), and StateVariable::ToInteger().

Referenced by StatusCommand::Execute(), and ModifyStep().

◆ GetUI()

UI * GXemul::GetUI ( )

◆ InitUI()

void GXemul::InitUI ( )

Initializes the UI.

Definition at line 545 of file GXemul.cc.

References GetUI(), and UI::Initialize().

◆ Interrupt()

void GXemul::Interrupt ( )

Interrupts emulation.

Only meaningful if RunState is Running or SingleStepping.

Definition at line 728 of file GXemul.cc.

References GetRunState(), Running, and SingleStepping.

◆ IsInterrupting()

bool GXemul::IsInterrupting ( ) const
inline

Returns whether or not the current emulation is being interrupted.

Only meaningful if RunState is Running or SingleStepping.

Definition at line 178 of file GXemul.h.

Referenced by CPUComponent::FunctionTraceCall(), and CPUComponent::FunctionTraceReturn().

◆ IsTemplateMachine()

bool GXemul::IsTemplateMachine ( const string &  templateName) const

Definition at line 204 of file GXemul.cc.

References ComponentFactory::HasAttribute().

◆ ListTemplates()

void GXemul::ListTemplates ( )
static

Dump a list to stdout with all available machine templates.

Definition at line 239 of file GXemul.cc.

References ComponentFactory::GetAllComponentNames(), and ComponentFactory::GetAttribute().

◆ ModifyStep()

bool GXemul::ModifyStep ( int64_t  oldStep,
int64_t  newStep 
)

Change step either forwards or backwards.

Parameters
oldStepThe old step count.
newStepThe new step count.
Returns
True if changing step worked, false if there was a failure.

Definition at line 809 of file GXemul.cc.

References Component::Clone(), Execute(), GetRunState(), GetSnapshottingEnabled(), GetStep(), GetUI(), Running, SetRootComponent(), SetRunState(), and UI::ShowDebugMessage().

Referenced by Component::CheckVariableWrite().

◆ ParseFilenames()

bool GXemul::ParseFilenames ( string  templateMachine,
int  filenameCount,
char *  filenames[] 
)

Parses command line arguments (file names).

Parameters
templateMachineThe template machine to use.
filenameCountfor parsing command line options.
filenamesfor parsing command line options.
Returns
true if options were parsable, false if there was some error.

Definition at line 427 of file GXemul.cc.

References GetRunState(), and Paused.

◆ Reset()

bool GXemul::Reset ( )

Resets the emulation.

This function recursively resets all components in the tree, and then executes the "on reset" commands (usually commands to load files into CPUs).

Returns
false if any of the reset commands failed.

Definition at line 700 of file GXemul.cc.

References GetCommandInterpreter(), GetQuietMode(), GetRootComponent(), GetUI(), Component::Reset(), CommandInterpreter::RunCommand(), and UI::ShowDebugMessage().

Referenced by ResetCommand::Execute(), and Run().

◆ Run()

int GXemul::Run ( )

◆ RunUnitTests()

static void GXemul::RunUnitTests ( int &  nSucceeded,
int &  nFailures 
)
static

◆ SetEmulationFilename()

void GXemul::SetEmulationFilename ( const string &  filename)

Sets the current emulation setup's filename.

Parameters
filenameThis is the name of the file that is used for the current emulation setup.

Definition at line 623 of file GXemul.cc.

References GetUI(), and UI::UpdateUI().

◆ SetNrOfSingleStepsInARow()

void GXemul::SetNrOfSingleStepsInARow ( uint64_t  steps)

Sets the nr of single-steps to perform in a row.

Parameters
stepsThe number of steps, at least 1.

Definition at line 800 of file GXemul.cc.

Referenced by StepCommand::Execute().

◆ SetQuietMode()

void GXemul::SetQuietMode ( bool  quietMode)

Sets whether or not to run in quiet mode.

Parameters
quietModetrue to run in quiet mode, false otherwise.

Definition at line 794 of file GXemul.cc.

Referenced by CPUDyntransComponent::DyntransToBeTranslatedDone().

◆ SetRootComponent()

void GXemul::SetRootComponent ( refcount_ptr< Component newRootComponent)

Sets the root component, discarding the previous one.

This function should not be used to set the root component to NULL. Use ClearEmulation() instead.

Parameters
newRootComponentA reference counted pointer to the new root component. It may not be a NULL pointer.

Definition at line 679 of file GXemul.cc.

References Component::AsRootComponent(), GetUI(), refcount_ptr< T >::IsNULL(), RootComponent::SetOwner(), and UI::UpdateUI().

Referenced by ModifyStep().

◆ SetRunState()

void GXemul::SetRunState ( RunState  newState)

Sets the RunState.

Parameters
newStateThe new RunState.

Definition at line 741 of file GXemul.cc.

References GetUI(), and UI::UpdateUI().

Referenced by ClearEmulation(), StepCommand::Execute(), QuitCommand::Execute(), ContinueCommand::Execute(), PauseCommand::Execute(), ResetCommand::Execute(), ConsoleUI::MainLoop(), ModifyStep(), and Run().

◆ SetSnapshottingEnabled()

void GXemul::SetSnapshottingEnabled ( bool  enabled)

Sets whether or not to use snapshots.

Parameters
enabledtrue to enable snapshotting, false to disable it.

Definition at line 778 of file GXemul.cc.

References GetUI(), and UI::ShowDebugMessage().

◆ Version()

string GXemul::Version ( )
static

Returns the GXemul version string.

Returns
A string describing the GXemul version.

Definition at line 509 of file GXemul.cc.

References COPYRIGHT_MSG, and SECONDARY_MSG.

Referenced by VersionCommand::Execute(), and ConsoleUI::ShowStartupBanner().


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

Generated on Tue Mar 24 2020 14:04:48 for GXemul by doxygen 1.8.17