OpenASIP 2.2
Loading...
Searching...
No Matches
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.

54 :
56}
static const std::string CMD_NAME_ADD_RF
Command name for the "Add Register File" command.

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}
#define assert(condition)
static std::string toString(const T &source)
wxView * view() const
wxWindow * parentWindow() const
Definition GUICommand.cc:75
static const int DEFAULT_RF_MAX_READS
Default maximum read ports of register file.
static const int DEFAULT_WIDTH
Default bit width.
static const int DEFAULT_RF_MAX_WRITES
Default maximum read ports while writing for a register file.
static const int DEFAULT_RF_SIZE
Default register file type.
static const int DEFAULT_RF_GUARD_LATENCY
Default local RF guard latency.
Definition Model.hh:50
void pushToStack()
Definition Model.cc:167
void notifyObservers(bool modified=true)
Definition Model.cc:152
void popFromStack(bool modified=false)
Definition Model.cc:195
TTAMachine::Machine * getMachine()
Definition Model.cc:88
static const std::string COMP_NEW_NAME_PREFIX_RF
Prefix for new register file names.
bool hasItem(const std::string &name) const
virtual RegisterFileNavigator registerFileNavigator() const
Definition Machine.cc:450
@ NORMAL
Used for general register allocation.
virtual void setMachine(Machine &mach)
Definition Unit.cc:253

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(), TTAMachine::RegisterFile::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.

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}
static const std::string CMD_SNAME_ADD_RF
Command name for the "Add Register File" command.

References ProDeConstants::CMD_SNAME_ADD_RF.


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