OpenASIP  2.0
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.

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 =
91  Machine::ZERO);
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 }

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(), and EditorCommand::view().

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.

115  {
117 }

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 }

References ProDeConstants::CMD_SNAME_ADD_IU.


The documentation for this class was generated from the following files:
ProDeConstants::COMMAND_ADD_IU
@ COMMAND_ADD_IU
Definition: ProDeConstants.hh:422
ProDeConstants::CMD_SNAME_ADD_IU
static const std::string CMD_SNAME_ADD_IU
Command name for the "Add Immediate Unit" command.
Definition: ProDeConstants.hh:215
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
TTAMachine::Machine::immediateUnitNavigator
virtual ImmediateUnitNavigator immediateUnitNavigator() const
Definition: Machine.cc:416
EditorCommand::view
wxView * view() const
Definition: EditorCommand.cc:76
TTAMachine::Machine::Navigator::hasItem
bool hasItem(const std::string &name) const
ModelConstants::DEFAULT_IU_SIZE
static const int DEFAULT_IU_SIZE
Default immediate unit size.
Definition: ModelConstants.hh:56
ProDeConstants::CMD_NAME_ADD_IU
static const std::string CMD_NAME_ADD_IU
Command name for the "Add Immediate Unit" command.
Definition: ProDeConstants.hh:103
Model::popFromStack
void popFromStack(bool modified=false)
Definition: Model.cc:195
MDFDocument
Definition: MDFDocument.hh:51
IUDialog
Definition: IUDialog.hh:48
ProDeConstants::COMP_NEW_NAME_PREFIX_IU
static const std::string COMP_NEW_NAME_PREFIX_IU
Prefix for new immediate unit names.
Definition: ProDeConstants.hh:367
Model
Definition: Model.hh:50
ModelConstants::DEFAULT_IU_GUARD_LATENCY
static const int DEFAULT_IU_GUARD_LATENCY
Default local IU guard latency.
Definition: ModelConstants.hh:64
TTAMachine::Unit::setMachine
virtual void setMachine(Machine &mach)
Definition: Unit.cc:253
AddIUCmd::AddIUCmd
AddIUCmd()
Definition: AddIUCmd.cc:52
ModelConstants::DEFAULT_IU_MAX_READS
static const int DEFAULT_IU_MAX_READS
Default maximum read ports of a immediate unit.
Definition: ModelConstants.hh:60
TTAMachine::Machine::Navigator
Definition: Machine.hh:186
GUICommand::parentWindow
wxWindow * parentWindow() const
Definition: GUICommand.cc:75
Model::getMachine
TTAMachine::Machine * getMachine()
Definition: Model.cc:88
TTAMachine::ImmediateUnit
Definition: ImmediateUnit.hh:50