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

#include <AddFUImplementationCmd.hh>

Inheritance diagram for AddFUImplementationCmd:
Inheritance graph
Collaboration diagram for AddFUImplementationCmd:
Collaboration graph

Public Member Functions

 AddFUImplementationCmd ()
 
virtual ~AddFUImplementationCmd ()
 
virtual bool Do ()
 
virtual int id () const
 
virtual AddFUImplementationCmdcreate () const
 
virtual std::string icon () const
 
virtual bool isEnabled ()
 
- Public Member Functions inherited from GUICommand
 GUICommand (std::string name, wxWindow *parent)
 
virtual ~GUICommand ()
 
virtual bool isChecked () const
 
virtual std::string shortName () const
 
void setParentWindow (wxWindow *view)
 
wxWindow * parentWindow () const
 
std::string name () const
 

Detailed Description

Command for adding implementation of a FU architecture to HDB.

Definition at line 41 of file AddFUImplementationCmd.hh.

Constructor & Destructor Documentation

◆ AddFUImplementationCmd()

AddFUImplementationCmd::AddFUImplementationCmd ( )

The Constructor.

Definition at line 53 of file AddFUImplementationCmd.cc.

Referenced by create().

◆ ~AddFUImplementationCmd()

AddFUImplementationCmd::~AddFUImplementationCmd ( )
virtual

The Destructor.

Definition at line 61 of file AddFUImplementationCmd.cc.

61  {
62 }

Member Function Documentation

◆ create()

AddFUImplementationCmd * AddFUImplementationCmd::create ( ) const
virtual

Creates a new instance of this command.

Returns
Newly created instance of this command.

Implements GUICommand.

Definition at line 155 of file AddFUImplementationCmd.cc.

155  {
156  return new AddFUImplementationCmd();
157 }

References AddFUImplementationCmd().

Here is the call graph for this function:

◆ Do()

bool AddFUImplementationCmd::Do ( )
virtual

Executes the command.

Implements GUICommand.

Definition at line 68 of file AddFUImplementationCmd.cc.

68  {
69 
70  HDB::HDBManager* manager = wxGetApp().mainFrame().hdbManager();
71  if (manager == NULL) {
72  return false;
73  }
74 
75  HDBBrowserWindow* browser = wxGetApp().mainFrame().browser();
76 
78  new HDB::FUImplementation("", "", "","", "", "");
79 
80  HDB::FUEntry* entry = NULL;
81 
82  if (browser->isFUEntrySelected()) {
83  entry = manager->fuByEntryID(browser->selectedFUEntry());
84  } else if (browser->isFUArchitectureSelected()) {
85  int id = manager->addFUEntry();
86  manager->setArchitectureForFU(id, browser->selectedFUArchitecture());
87  entry = manager->fuByEntryID(id);
88  } else {
89  return false;
90  }
91 
92  const TTAMachine::FunctionUnit& arch =
93  entry->architecture().architecture();
94 
95  for (int i = 0; i < arch.portCount(); i++) {
97  "", arch.port(i)->name(), "", "", "", *implementation);
98  }
99 
100  FUImplementationDialog dialog(parentWindow(), -1, *implementation, arch);
101 
102  if (dialog.ShowModal() == wxID_OK) {
103  try {
105  int id = manager->addFUImplementation(*entry);
106  wxGetApp().mainFrame().update();
107  wxGetApp().mainFrame().browser()->selectFUImplementation(id);
108  } catch (Exception& e) {
109  wxString message = _T("Error:\n");
110  message.Append(WxConversion::toWxString(e.errorMessage()));
111  message.Append(_T("\n"));
112  message.Append(WxConversion::toWxString(e.lineNum()));
113  message.Append(_T(": "));
114  message.Append(WxConversion::toWxString(e.fileName()));
115  ErrorDialog dialog(parentWindow(), message);
116  dialog.ShowModal();
117  delete entry;
118  delete implementation;
119  return false;
120  }
121  } else {
122  delete implementation;
123  }
124  delete entry;
125  return true;
126 }

References HDB::HDBManager::addFUEntry(), HDB::HDBManager::addFUImplementation(), HDB::FUEntry::architecture(), HDB::FUArchitecture::architecture(), Exception::errorMessage(), Exception::fileName(), HDB::HDBManager::fuByEntryID(), implementation, HDBBrowserWindow::isFUArchitectureSelected(), HDBBrowserWindow::isFUEntrySelected(), Exception::lineNum(), TTAMachine::Port::name(), GUICommand::parentWindow(), TTAMachine::FunctionUnit::port(), TTAMachine::Unit::portCount(), HDBBrowserWindow::selectedFUArchitecture(), HDBBrowserWindow::selectedFUEntry(), HDB::HDBManager::setArchitectureForFU(), HDB::FUEntry::setImplementation(), and WxConversion::toWxString().

Here is the call graph for this function:

◆ icon()

std::string AddFUImplementationCmd::icon ( ) const
virtual

Returns name of the command icon file.

Returns
Command icon file name.

Implements GUICommand.

Definition at line 134 of file AddFUImplementationCmd.cc.

134  {
135  return "";
136 }

◆ id()

int AddFUImplementationCmd::id ( ) const
virtual

Returns the command id.

Returns
Command identifier.

Implements GUICommand.

Definition at line 144 of file AddFUImplementationCmd.cc.

References HDBEditorConstants::COMMAND_ADD_FU_IMPLEMENTATION.

◆ isEnabled()

bool AddFUImplementationCmd::isEnabled ( )
virtual

Returns true if the command should be enabled in the tool/menubar.

Returns
True if the command is enabled, false if not.

Implements GUICommand.

Definition at line 166 of file AddFUImplementationCmd.cc.

166  {
167  HDB::HDBManager* manager = wxGetApp().mainFrame().hdbManager();
168 
169  if (manager == NULL) {
170  return false;
171  }
172 
173  HDBBrowserWindow* browser = wxGetApp().mainFrame().browser();
174 
175  if (browser->isFUArchitectureSelected()) {
176  return true;
177  } else if (browser->isFUEntrySelected()) {
178  HDB::FUEntry* entry = manager->fuByEntryID(browser->selectedFUEntry());
179  if (entry->hasArchitecture() && !entry->hasImplementation()) {
180  delete entry;
181  return true;
182  }
183  delete entry;
184  }
185  return false;
186 }

References HDB::HDBManager::fuByEntryID(), HDB::FUEntry::hasArchitecture(), HDB::FUEntry::hasImplementation(), HDBBrowserWindow::isFUArchitectureSelected(), HDBBrowserWindow::isFUEntrySelected(), and HDBBrowserWindow::selectedFUEntry().

Here is the call graph for this function:

The documentation for this class was generated from the following files:
HDB::FUEntry
Definition: FUEntry.hh:49
HDB::HDBManager::addFUImplementation
RowID addFUImplementation(const FUEntry &entry) const
Definition: HDBManager.cc:1112
Exception::lineNum
int lineNum() const
WxConversion::toWxString
static wxString toWxString(const std::string &source)
HDBBrowserWindow
Definition: HDBBrowserWindow.hh:59
implementation
IDF::MachineImplementation * implementation
the implementation definition of the estimated processor
Definition: EstimatorCmdLineUI.cc:61
FUImplementationDialog
Definition: FUImplementationDialog.hh:52
HDB::FUPortImplementation
Definition: FUPortImplementation.hh:46
HDB::FUArchitecture::architecture
TTAMachine::FunctionUnit & architecture() const
Definition: FUArchitecture.cc:131
TTAMachine::FunctionUnit::port
virtual BaseFUPort * port(const std::string &name) const
Definition: FunctionUnit.cc:145
Exception::fileName
std::string fileName() const
TTAMachine::FunctionUnit
Definition: FunctionUnit.hh:55
HDB::FUEntry::hasArchitecture
virtual bool hasArchitecture() const
Definition: FUEntry.cc:117
ErrorDialog
Definition: ErrorDialog.hh:42
HDBBrowserWindow::isFUEntrySelected
bool isFUEntrySelected()
Definition: HDBBrowserWindow.cc:387
HDBBrowserWindow::selectedFUArchitecture
RowID selectedFUArchitecture()
Definition: HDBBrowserWindow.cc:466
HDBEditorConstants::COMMAND_ADD_FU_IMPLEMENTATION
@ COMMAND_ADD_FU_IMPLEMENTATION
Definition: HDBEditorConstants.hh:51
HDB::FUEntry::architecture
FUArchitecture & architecture() const
Definition: FUEntry.cc:129
HDB::HDBManager
Definition: HDBManager.hh:82
Exception
Definition: Exception.hh:54
HDBEditorConstants::COMMAND_NAME_ADD_FU_IMPLEMENTATION
static const std::string COMMAND_NAME_ADD_FU_IMPLEMENTATION
Name of the add fu implementation cmd.
Definition: HDBEditorConstants.hh:96
TTAMachine::Unit::portCount
virtual int portCount() const
Definition: Unit.cc:135
Exception::errorMessage
std::string errorMessage() const
Definition: Exception.cc:123
HDB::HDBManager::addFUEntry
RowID addFUEntry() const
Definition: HDBManager.cc:1014
HDB::FUImplementation
Definition: FUImplementation.hh:53
GUICommand::GUICommand
GUICommand(std::string name, wxWindow *parent)
Definition: GUICommand.cc:42
TTAMachine::Port::name
virtual std::string name() const
Definition: Port.cc:141
HDB::FUEntry::setImplementation
void setImplementation(FUImplementation *implementation)
Definition: FUEntry.cc:103
HDBBrowserWindow::isFUArchitectureSelected
bool isFUArchitectureSelected()
Definition: HDBBrowserWindow.cc:343
AddFUImplementationCmd::AddFUImplementationCmd
AddFUImplementationCmd()
Definition: AddFUImplementationCmd.cc:53
HDB::FUEntry::hasImplementation
virtual bool hasImplementation() const
Definition: FUEntry.cc:74
HDB::HDBManager::fuByEntryID
FUEntry * fuByEntryID(RowID id) const
Definition: HDBManager.cc:2828
GUICommand::parentWindow
wxWindow * parentWindow() const
Definition: GUICommand.cc:75
HDBBrowserWindow::selectedFUEntry
RowID selectedFUEntry()
Definition: HDBBrowserWindow.cc:533
HDB::HDBManager::setArchitectureForFU
void setArchitectureForFU(RowID fuID, RowID archID) const
Definition: HDBManager.cc:1401