OpenASIP 2.2
Loading...
Searching...
No Matches
Public Member Functions | List of all members
AddIUCmd Class Reference

#include <AddIUCmd.hh>

Inheritance diagram for AddIUCmd:
Inheritance graph
Collaboration diagram for AddIUCmd:
Collaboration graph

Public Member Functions

 AddIUCmd ()
 
virtual bool Do ()
 
virtual int id () const
 
virtual AddIUCmdcreate () 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 immediate units to the Machine.

Displays a immediate unit dialog and creates a new immediate unit according to the dialog output.

Definition at line 43 of file AddIUCmd.hh.

Constructor & Destructor Documentation

◆ AddIUCmd()

AddIUCmd::AddIUCmd ( )

The Constructor.

Definition at line 52 of file AddIUCmd.cc.

52 :
54}
static const std::string CMD_NAME_ADD_IU
Command name for the "Add Immediate Unit" command.

Referenced by create().

Member Function Documentation

◆ create()

AddIUCmd * AddIUCmd::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 AddIUCmd.cc.

126 {
127 return new AddIUCmd();
128}

References AddIUCmd().

Here is the call graph for this function:

◆ Do()

bool AddIUCmd::Do ( )
virtual

Executes the command.

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

Implements GUICommand.

Definition at line 64 of file AddIUCmd.cc.

64 {
65
66 assert(parentWindow() != NULL);
67 assert(view() != NULL);
68
69
70 Model* model =
71 dynamic_cast<MDFDocument*>(view()->GetDocument())->getModel();
72
73 model->pushToStack();
74
75 // Generate name for the new IU.
79 int i = 1;
80 while (navigator.hasItem(newName)) {
83 i++;
84 }
85
86 ImmediateUnit* iu =
92
93 iu->setMachine(*(model->getMachine()));
94
95 IUDialog dialog(parentWindow(), iu);
96
97 if (dialog.ShowModal() == wxID_OK) {
98 model->notifyObservers();
99 return true;
100 } else {
101 // immediate unit creation was cancelled
102 model->popFromStack();
103 return false;
104 }
105 return false;
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_IU_GUARD_LATENCY
Default local IU guard latency.
static const int DEFAULT_WIDTH
Default bit width.
static const int DEFAULT_IU_SIZE
Default immediate unit size.
static const int DEFAULT_IU_MAX_READS
Default maximum read ports of a immediate unit.
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_IU
Prefix for new immediate unit names.
bool hasItem(const std::string &name) const
virtual ImmediateUnitNavigator immediateUnitNavigator() const
Definition Machine.cc:416
@ ZERO
Zero extension.
Definition Machine.hh:81
virtual void setMachine(Machine &mach)
Definition Unit.cc:253

References assert, ProDeConstants::COMP_NEW_NAME_PREFIX_IU, ModelConstants::DEFAULT_IU_GUARD_LATENCY, ModelConstants::DEFAULT_IU_MAX_READS, ModelConstants::DEFAULT_IU_SIZE, ModelConstants::DEFAULT_WIDTH, Model::getMachine(), TTAMachine::Machine::Navigator< ComponentType >::hasItem(), TTAMachine::Machine::immediateUnitNavigator(), Model::notifyObservers(), GUICommand::parentWindow(), Model::popFromStack(), Model::pushToStack(), TTAMachine::Unit::setMachine(), Conversion::toString(), EditorCommand::view(), and TTAMachine::Machine::ZERO.

Here is the call graph for this function:

◆ id()

int AddIUCmd::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 AddIUCmd.cc.

References ProDeConstants::COMMAND_ADD_IU.

◆ isEnabled()

bool AddIUCmd::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 150 of file AddIUCmd.cc.

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

◆ shortName()

string AddIUCmd::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 137 of file AddIUCmd.cc.

137 {
139}
static const std::string CMD_SNAME_ADD_IU
Command name for the "Add Immediate Unit" command.

References ProDeConstants::CMD_SNAME_ADD_IU.


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