OpenASIP  2.0
Public Member Functions | List of all members
AddRFCmd Class Reference

#include <AddRFCmd.hh>

Inheritance diagram for AddRFCmd:
Inheritance graph
Collaboration diagram for AddRFCmd:
Collaboration graph

Public Member Functions

 AddRFCmd ()
 
virtual bool Do ()
 
virtual int id () const
 
virtual AddRFCmdcreate () const
 
virtual std::string shortName () const
 
virtual bool isEnabled ()
 
- Public Member Functions inherited from EditorCommand
 EditorCommand (std::string name, wxWindow *parent=NULL)
 
virtual ~EditorCommand ()
 
void setView (wxView *view)
 
wxView * view () const
 
virtual std::string icon () const
 
- Public Member Functions inherited from GUICommand
 GUICommand (std::string name, wxWindow *parent)
 
virtual ~GUICommand ()
 
virtual bool isChecked () const
 
void setParentWindow (wxWindow *view)
 
wxWindow * parentWindow () const
 
std::string name () const
 

Detailed Description

Command for adding new register files to the Machine.

Displays a register file dialog and creates a new register file according to the dialog output.

Definition at line 43 of file AddRFCmd.hh.

Constructor & Destructor Documentation

◆ AddRFCmd()

AddRFCmd::AddRFCmd ( )

The Constructor.

Definition at line 54 of file AddRFCmd.cc.

Referenced by create().

Member Function Documentation

◆ create()

AddRFCmd * AddRFCmd::create ( ) const
virtual

Creates and returns a new instance of this command.

Returns
Newly created instance of this command.

Implements GUICommand.

Definition at line 126 of file AddRFCmd.cc.

126  {
127  return new AddRFCmd();
128 }

References AddRFCmd().

Here is the call graph for this function:

◆ Do()

bool AddRFCmd::Do ( )
virtual

Executes the command.

Returns
true, if the command was succesfully executed, false otherwise.

Implements GUICommand.

Definition at line 66 of file AddRFCmd.cc.

66  {
67 
68  assert(parentWindow() != NULL);
69  assert(view() != NULL);
70 
71  Model* model = dynamic_cast<MDFDocument*>(
72  view()->GetDocument())->getModel();
73 
74  model->pushToStack();
75 
76  // Generate name for the new RF.
80  int i = 1;
81  while (navigator.hasItem(newName)) {
84  i++;
85  }
86 
87  RegisterFile* rf = new RegisterFile(
93 
94  rf->setMachine(*(model->getMachine()));
95 
96  RFDialog dialog(parentWindow(), rf);
97 
98  if (dialog.ShowModal() == wxID_OK) {
99  model->notifyObservers();
100  return true;
101  } else {
102  // register file creation was cancelled
103  model->popFromStack();
104  return false;
105  }
106 }

References assert, ProDeConstants::COMP_NEW_NAME_PREFIX_RF, ModelConstants::DEFAULT_RF_GUARD_LATENCY, ModelConstants::DEFAULT_RF_MAX_READS, ModelConstants::DEFAULT_RF_MAX_WRITES, ModelConstants::DEFAULT_RF_SIZE, ModelConstants::DEFAULT_WIDTH, Model::getMachine(), TTAMachine::Machine::Navigator< ComponentType >::hasItem(), NORMAL, Model::notifyObservers(), GUICommand::parentWindow(), Model::popFromStack(), Model::pushToStack(), TTAMachine::Machine::registerFileNavigator(), TTAMachine::Unit::setMachine(), Conversion::toString(), and EditorCommand::view().

Here is the call graph for this function:

◆ id()

int AddRFCmd::id ( ) const
virtual

Returns id of this command.

Returns
ID for this command to be used in menus and toolbars.

Implements GUICommand.

Definition at line 115 of file AddRFCmd.cc.

115  {
117 }

References ProDeConstants::COMMAND_ADD_RF.

◆ isEnabled()

bool AddRFCmd::isEnabled ( )
virtual

Returns true when the command is executable, false when not.

This command is executable when a document is open.

Returns
True, if a document is open.

Reimplemented from EditorCommand.

Definition at line 149 of file AddRFCmd.cc.

149  {
150  wxDocManager* manager = wxGetApp().docManager();
151  if (manager->GetCurrentView() != NULL) {
152  return true;
153  }
154  return false;
155 }

◆ shortName()

string AddRFCmd::shortName ( ) const
virtual

Returns short version of the command name.

Returns
Short name of the command to be used in the toolbar.

Reimplemented from GUICommand.

Definition at line 136 of file AddRFCmd.cc.

136  {
138 }

References ProDeConstants::CMD_SNAME_ADD_RF.


The documentation for this class was generated from the following files:
AddRFCmd::AddRFCmd
AddRFCmd()
Definition: AddRFCmd.cc:54
ModelConstants::DEFAULT_RF_SIZE
static const int DEFAULT_RF_SIZE
Default register file type.
Definition: ModelConstants.hh:48
ModelConstants::DEFAULT_RF_GUARD_LATENCY
static const int DEFAULT_RF_GUARD_LATENCY
Default local RF guard latency.
Definition: ModelConstants.hh:54
ProDeConstants::CMD_SNAME_ADD_RF
static const std::string CMD_SNAME_ADD_RF
Command name for the "Add Register File" command.
Definition: ProDeConstants.hh:207
ProDeConstants::CMD_NAME_ADD_RF
static const std::string CMD_NAME_ADD_RF
Command name for the "Add Register File" command.
Definition: ProDeConstants.hh:95
Conversion::toString
static std::string toString(const T &source)
Model::pushToStack
void pushToStack()
Definition: Model.cc:167
EditorCommand::EditorCommand
EditorCommand(std::string name, wxWindow *parent=NULL)
Definition: EditorCommand.cc:42
Model::notifyObservers
void notifyObservers(bool modified=true)
Definition: Model.cc:152
assert
#define assert(condition)
Definition: Application.hh:86
ModelConstants::DEFAULT_WIDTH
static const int DEFAULT_WIDTH
Default bit width.
Definition: ModelConstants.hh:46
EditorCommand::view
wxView * view() const
Definition: EditorCommand.cc:76
TTAMachine::Machine::Navigator::hasItem
bool hasItem(const std::string &name) const
NORMAL
@ NORMAL
Definition: tceopgen.cc:45
ProDeConstants::COMMAND_ADD_RF
@ COMMAND_ADD_RF
Definition: ProDeConstants.hh:418
Model::popFromStack
void popFromStack(bool modified=false)
Definition: Model.cc:195
MDFDocument
Definition: MDFDocument.hh:51
TTAMachine::Machine::registerFileNavigator
virtual RegisterFileNavigator registerFileNavigator() const
Definition: Machine.cc:450
Model
Definition: Model.hh:50
TTAMachine::Unit::setMachine
virtual void setMachine(Machine &mach)
Definition: Unit.cc:253
ProDeConstants::COMP_NEW_NAME_PREFIX_RF
static const std::string COMP_NEW_NAME_PREFIX_RF
Prefix for new register file names.
Definition: ProDeConstants.hh:365
TTAMachine::RegisterFile
Definition: RegisterFile.hh:47
ModelConstants::DEFAULT_RF_MAX_WRITES
static const int DEFAULT_RF_MAX_WRITES
Default maximum read ports while writing for a register file.
Definition: ModelConstants.hh:52
ModelConstants::DEFAULT_RF_MAX_READS
static const int DEFAULT_RF_MAX_READS
Default maximum read ports of register file.
Definition: ModelConstants.hh:50
TTAMachine::Machine::Navigator
Definition: Machine.hh:186
GUICommand::parentWindow
wxWindow * parentWindow() const
Definition: GUICommand.cc:75
RFDialog
Definition: RFDialog.hh:47
Model::getMachine
TTAMachine::Machine * getMachine()
Definition: Model.cc:88