KoMo2  1.0.0
A modern ARM emulator GUI.
Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | Friends | List of all members
Model Class Referenceabstract

The superclass for all other Model classes. Uses a pure virtual function, so is abastract. Keeps KoMo2Model as a friend so it alone can call setJimulatorState. This class provides basic data that are needed by all other. More...

#include <Model.h>

Inheritance diagram for Model:
CompileLoadModel ControlsModel DisassemblyModel KoMo2Model RegistersModel TerminalModel

Public Member Functions

 Model (KoMo2Model *const parent)
 Constructs a new Model object - just assigns the parent variable. More...
 
KoMo2Model *const getParent () const
 Returns the parent pointer. More...
 

Protected Member Functions

template<class T1 , class T2 >
void setButtonListener (Gtk::Button *const button, const T1 b, const T2 c)
 Connect any button to any member function of. More...
 
void setButtonState (Gtk::Button *const button, const bool state, Gtk::Image *const img=nullptr, const std::string newTooltip="", const std::string newLabelText="") const
 Sets the state of a button to some boolean - the assumption is that if a button is not meant to be sensitive (get_sensitive() == false) then it should also not have a tooltip or many other attributes. You can also optionally update the buttons image, tooltip text, and label text. More...
 
virtual const bool handleKeyPress (const GdkEventKey *const e)=0
 Handles key presses for each model. More...
 
virtual void changeJimulatorState (const JimulatorState newState)=0
 Changes the state of Jimulator into newState. This function does not necessarily need to be virtual, as at no point should a child be stored as Model pointer. However, by making it a pure virtual function, we ensure this class cannot be instantiated. More...
 
JimulatorState getJimulatorState () const
 Return the jimulatorState member object. More...
 

Private Member Functions

void setJimulatorState (const JimulatorState val)
 set the JimulatorState member object. More...
 
 Model (const Model &)=delete
 
 Model (const Model &&)=delete
 
Modeloperator= (const Model &)=delete
 
Modeloperator= (const Model &&)=delete
 

Private Attributes

KoMo2Model *const parent
 All models have a parent model - KoMo2Model, the most senior model in the hierarchy, sets its parent to self.
 

Static Private Attributes

static JimulatorState jimulatorState = JimulatorState::INITIAL
 JimulatorState reflects the state in which Jimulator is operating, which in turn affects the model of this process and it the views. JimulatorState is static, so all subclasses of Model can simply call getState() on themselves and have the expected value.
 

Friends

class KoMo2Model
 

Detailed Description

The superclass for all other Model classes. Uses a pure virtual function, so is abastract. Keeps KoMo2Model as a friend so it alone can call setJimulatorState. This class provides basic data that are needed by all other.

Definition at line 35 of file Model.h.

Constructor & Destructor Documentation

Model::Model ( KoMo2Model *const  parent)

Constructs a new Model object - just assigns the parent variable.

Parameters
parentThe parent pointer.

Definition at line 22 of file Model.cpp.

Member Function Documentation

virtual void Model::changeJimulatorState ( const JimulatorState  newState)
protectedpure virtual

Changes the state of Jimulator into newState. This function does not necessarily need to be virtual, as at no point should a child be stored as Model pointer. However, by making it a pure virtual function, we ensure this class cannot be instantiated.

Parameters
newStateThe state to change the program to.

Implemented in KoMo2Model, CompileLoadModel, DisassemblyModel, ControlsModel, TerminalModel, and RegistersModel.

JimulatorState Model::getJimulatorState ( ) const
protected

Return the jimulatorState member object.

Returns
JimulatorState the jimulatorState member.

Definition at line 75 of file Model.cpp.

KoMo2Model *const Model::getParent ( ) const

Returns the parent pointer.

Returns
KoMo2Model* The parent pointer.

Definition at line 67 of file Model.cpp.

virtual const bool Model::handleKeyPress ( const GdkEventKey *const  e)
protectedpure virtual

Handles key presses for each model.

Parameters
eThe key press event.
Returns
bool If a key pressed.

Implemented in KoMo2Model, CompileLoadModel, DisassemblyModel, TerminalModel, ControlsModel, and RegistersModel.

template<class T1 , class T2 >
void Model::setButtonListener ( Gtk::Button *const  button,
const T1  b,
const T2  c 
)
protected

Connect any button to any member function of.

Template Parameters
T1A pointer type to some object of any type.
T2A pointer to a T1 member function.
Parameters
buttonA pointer to the button to set the onClick event for.
bA pointer to some object.
cA pointer to some member function of the b object.

Definition at line 52 of file Model.h.

void Model::setButtonState ( Gtk::Button *const  button,
const bool  state,
Gtk::Image *const  img = nullptr,
const std::string  newTooltip = "",
const std::string  newLabelText = "" 
) const
protected

Sets the state of a button to some boolean - the assumption is that if a button is not meant to be sensitive (get_sensitive() == false) then it should also not have a tooltip or many other attributes. You can also optionally update the buttons image, tooltip text, and label text.

Parameters
buttonThe button to set the attributes of.
stateWhat value to set the attributes to - specifically, if the button should be sensitive or display a tooltip.
newTooltipThe new tooltip text to display.
imgThe new image to display.
newLabelTextThe new label text to display.

Definition at line 37 of file Model.cpp.

void Model::setJimulatorState ( const JimulatorState  val)
private

set the JimulatorState member object.

Parameters
valThe value to set JimulatorState to.

Definition at line 83 of file Model.cpp.


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