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

#include <AddFUCmd.hh>

Inheritance diagram for AddFUCmd:
Inheritance graph
Collaboration diagram for AddFUCmd:
Collaboration graph

Public Member Functions

 AddFUCmd ()
 
virtual bool Do ()
 
virtual int id () const
 
virtual AddFUCmdcreate () 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 function units to the Machine.

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

Definition at line 43 of file AddFUCmd.hh.

Constructor & Destructor Documentation

◆ AddFUCmd()

AddFUCmd::AddFUCmd ( )

The Constructor.

Definition at line 52 of file AddFUCmd.cc.

Referenced by create().

Member Function Documentation

◆ create()

AddFUCmd * AddFUCmd::create ( ) const
virtual

Creates and returns a new instance of this command.

Returns
Newly created instance of this command.

Implements GUICommand.

Definition at line 117 of file AddFUCmd.cc.

117  {
118  return new AddFUCmd();
119 }

References AddFUCmd().

Here is the call graph for this function:

◆ Do()

bool AddFUCmd::Do ( )
virtual

Executes the command.

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

Implements GUICommand.

Definition at line 63 of file AddFUCmd.cc.

63  {
64 
65  assert(parentWindow() != NULL);
66  assert(view() != NULL);
67 
68  Model* model = dynamic_cast<MDFDocument*>(
69  view()->GetDocument())->getModel();
70 
71  model->pushToStack();
72 
73  // Generate name for the new FU.
77  int i = 1;
78  while (navigator.hasItem(newName)) {
81  i++;
82  }
83 
84  FunctionUnit* functionUnit = new FunctionUnit(newName);
85  functionUnit->setMachine(*(model->getMachine()));
86 
87  FUDialog dialog(parentWindow(), functionUnit);
88 
89  if (dialog.ShowModal() == wxID_OK) {
90  model->notifyObservers();
91  return true;
92  } else {
93  // FU creation was cancelled
94  model->popFromStack();
95  return false;
96  }
97 }

References assert, ProDeConstants::COMP_NEW_NAME_PREFIX_FU, TTAMachine::Machine::functionUnitNavigator(), Model::getMachine(), TTAMachine::Machine::Navigator< ComponentType >::hasItem(), 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 AddFUCmd::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 106 of file AddFUCmd.cc.

106  {
108 }

References ProDeConstants::COMMAND_ADD_FU.

◆ isEnabled()

bool AddFUCmd::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 141 of file AddFUCmd.cc.

141  {
142  wxDocManager* manager = wxGetApp().docManager();
143  if (manager->GetCurrentView() != NULL) {
144  return true;
145  }
146  return false;
147 }

◆ shortName()

string AddFUCmd::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 128 of file AddFUCmd.cc.

128  {
130 }

References ProDeConstants::CMD_SNAME_ADD_FU.


The documentation for this class was generated from the following files:
AddFUCmd::AddFUCmd
AddFUCmd()
Definition: AddFUCmd.cc:52
FUDialog
Definition: FUDialog.hh:48
ProDeConstants::CMD_SNAME_ADD_FU
static const std::string CMD_SNAME_ADD_FU
Command name for the "Add Function Unit" command.
Definition: ProDeConstants.hh:205
ProDeConstants::COMP_NEW_NAME_PREFIX_FU
static const std::string COMP_NEW_NAME_PREFIX_FU
Prefix for new function unit names.
Definition: ProDeConstants.hh:363
ProDeConstants::COMMAND_ADD_FU
@ COMMAND_ADD_FU
Definition: ProDeConstants.hh:417
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
TTAMachine::FunctionUnit
Definition: FunctionUnit.hh:55
ProDeConstants::CMD_NAME_ADD_FU
static const std::string CMD_NAME_ADD_FU
Command name for the "Add Function Unit" command.
Definition: ProDeConstants.hh:93
EditorCommand::view
wxView * view() const
Definition: EditorCommand.cc:76
TTAMachine::Machine::Navigator::hasItem
bool hasItem(const std::string &name) const
TTAMachine::Machine::functionUnitNavigator
virtual FunctionUnitNavigator functionUnitNavigator() const
Definition: Machine.cc:380
Model::popFromStack
void popFromStack(bool modified=false)
Definition: Model.cc:195
MDFDocument
Definition: MDFDocument.hh:51
Model
Definition: Model.hh:50
TTAMachine::Unit::setMachine
virtual void setMachine(Machine &mach)
Definition: Unit.cc:253
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