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

#include <AddRFImplementationCmd.hh>

Inheritance diagram for AddRFImplementationCmd:
Inheritance graph
Collaboration diagram for AddRFImplementationCmd:
Collaboration graph

Public Member Functions

 AddRFImplementationCmd ()
 
virtual ~AddRFImplementationCmd ()
 
virtual bool Do ()
 
virtual int id () const
 
virtual AddRFImplementationCmdcreate () 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 RF architecture to HDB.

Definition at line 41 of file AddRFImplementationCmd.hh.

Constructor & Destructor Documentation

◆ AddRFImplementationCmd()

AddRFImplementationCmd::AddRFImplementationCmd ( )

The Constructor.

Definition at line 49 of file AddRFImplementationCmd.cc.

Referenced by create().

◆ ~AddRFImplementationCmd()

AddRFImplementationCmd::~AddRFImplementationCmd ( )
virtual

The Destructor.

Definition at line 57 of file AddRFImplementationCmd.cc.

57  {
58 }

Member Function Documentation

◆ create()

AddRFImplementationCmd * AddRFImplementationCmd::create ( ) const
virtual

Creates a new instance of this command.

Returns
Newly created instance of this command.

Implements GUICommand.

Definition at line 144 of file AddRFImplementationCmd.cc.

144  {
145  return new AddRFImplementationCmd();
146 }

References AddRFImplementationCmd().

Here is the call graph for this function:

◆ Do()

bool AddRFImplementationCmd::Do ( )
virtual

Executes the command.

Implements GUICommand.

Definition at line 64 of file AddRFImplementationCmd.cc.

64  {
65 
66  HDB::HDBManager* manager = wxGetApp().mainFrame().hdbManager();
67  if (manager == NULL) {
68  return false;
69  }
70 
71  HDBBrowserWindow* browser = wxGetApp().mainFrame().browser();
72 
74  = new HDB::RFImplementation("", "", "","", "", "", "");
75 
76  HDB::RFEntry* entry = NULL;
77 
78  if (browser->isRFEntrySelected()) {
79  entry = manager->rfByEntryID(browser->selectedRFEntry());
80  } else if (browser->isRFArchitectureSelected()) {
81  int id = manager->addRFEntry();
82  manager->setArchitectureForRF(id, browser->selectedRFArchitecture());
83  entry = manager->rfByEntryID(id);
84  } else {
85  return false;
86  }
87 
89 
90  if (dialog.ShowModal() == wxID_OK) {
91  try {
92  int id =
93  manager->addRFImplementation(*implementation, entry->id());
94  wxGetApp().mainFrame().update();
95  wxGetApp().mainFrame().browser()->selectRFImplementation(id);
96  } catch (Exception& e) {
97  wxString message = _T("Error:\n");
98  message.Append(WxConversion::toWxString(e.errorMessage()));
99  message.Append(_T("\n"));
100  message.Append(WxConversion::toWxString(e.lineNum()));
101  message.Append(_T(": "));
102  message.Append(WxConversion::toWxString(e.fileName()));
103  ErrorDialog dialog(parentWindow(), message);
104  dialog.ShowModal();
105  delete entry;
106  delete implementation;
107  return false;
108  }
109  } else {
110  delete implementation;
111  }
112 
113  delete entry;
114  return true;
115 }

References HDB::HDBManager::addRFEntry(), HDB::HDBManager::addRFImplementation(), Exception::errorMessage(), Exception::fileName(), HDB::HDBEntry::id(), implementation, HDBBrowserWindow::isRFArchitectureSelected(), HDBBrowserWindow::isRFEntrySelected(), Exception::lineNum(), GUICommand::parentWindow(), HDB::HDBManager::rfByEntryID(), HDBBrowserWindow::selectedRFArchitecture(), HDBBrowserWindow::selectedRFEntry(), HDB::HDBManager::setArchitectureForRF(), and WxConversion::toWxString().

Here is the call graph for this function:

◆ icon()

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

Returns name of the command icon file.

Returns
Command icon file name.

Implements GUICommand.

Definition at line 123 of file AddRFImplementationCmd.cc.

123  {
124  return "";
125 }

◆ id()

int AddRFImplementationCmd::id ( ) const
virtual

Returns the command id.

Returns
Command identifier.

Implements GUICommand.

Definition at line 133 of file AddRFImplementationCmd.cc.

References HDBEditorConstants::COMMAND_ADD_RF_IMPLEMENTATION.

◆ isEnabled()

bool AddRFImplementationCmd::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 155 of file AddRFImplementationCmd.cc.

155  {
156 
157  HDB::HDBManager* manager = wxGetApp().mainFrame().hdbManager();
158 
159  if (manager == NULL) {
160  return false;
161  }
162 
163  HDBBrowserWindow* browser = wxGetApp().mainFrame().browser();
164 
165 
166  if (browser->isRFArchitectureSelected()) {
167  return true;
168  } else if (browser->isRFEntrySelected()) {
169  HDB::RFEntry* entry = manager->rfByEntryID(browser->selectedRFEntry());
170  if (entry->hasArchitecture() && !entry->hasImplementation()) {
171  delete entry;
172  return true;
173  }
174  delete entry;
175  }
176 
177  return false;
178 }

References HDB::RFEntry::hasArchitecture(), HDB::RFEntry::hasImplementation(), HDBBrowserWindow::isRFArchitectureSelected(), HDBBrowserWindow::isRFEntrySelected(), HDB::HDBManager::rfByEntryID(), and HDBBrowserWindow::selectedRFEntry().

Here is the call graph for this function:

The documentation for this class was generated from the following files:
Exception::lineNum
int lineNum() const
WxConversion::toWxString
static wxString toWxString(const std::string &source)
HDB::RFEntry::hasImplementation
virtual bool hasImplementation() const
Definition: RFEntry.cc:74
HDBBrowserWindow
Definition: HDBBrowserWindow.hh:59
HDBBrowserWindow::isRFArchitectureSelected
bool isRFArchitectureSelected()
Definition: HDBBrowserWindow.cc:353
implementation
IDF::MachineImplementation * implementation
the implementation definition of the estimated processor
Definition: EstimatorCmdLineUI.cc:61
HDB::HDBEntry::id
RowID id() const
Definition: HDBEntry.cc:85
HDB::RFEntry
Definition: RFEntry.hh:47
HDB::HDBManager::addRFEntry
RowID addRFEntry() const
Definition: HDBManager.cc:1557
Exception::fileName
std::string fileName() const
HDBEditorConstants::COMMAND_NAME_ADD_RF_IMPLEMENTATION
static const std::string COMMAND_NAME_ADD_RF_IMPLEMENTATION
Name of the add rf implementation cmd.
Definition: HDBEditorConstants.hh:98
HDB::RFImplementation
Definition: RFImplementation.hh:50
ErrorDialog
Definition: ErrorDialog.hh:42
HDB::HDBManager::setArchitectureForRF
void setArchitectureForRF(RowID rfID, RowID archID) const
Definition: HDBManager.cc:1895
HDBEditorConstants::COMMAND_ADD_RF_IMPLEMENTATION
@ COMMAND_ADD_RF_IMPLEMENTATION
Definition: HDBEditorConstants.hh:52
HDB::HDBManager
Definition: HDBManager.hh:82
Exception
Definition: Exception.hh:54
Exception::errorMessage
std::string errorMessage() const
Definition: Exception.cc:123
HDB::HDBManager::addRFImplementation
RowID addRFImplementation(const RFImplementation &implementation, RowID rfEntryID)
Definition: HDBManager.cc:1640
GUICommand::GUICommand
GUICommand(std::string name, wxWindow *parent)
Definition: GUICommand.cc:42
HDBBrowserWindow::selectedRFEntry
RowID selectedRFEntry()
Definition: HDBBrowserWindow.cc:549
AddRFImplementationCmd::AddRFImplementationCmd
AddRFImplementationCmd()
Definition: AddRFImplementationCmd.cc:49
RFImplementationDialog
Definition: RFImplementationDialog.hh:45
HDB::RFEntry::hasArchitecture
virtual bool hasArchitecture() const
Definition: RFEntry.cc:117
GUICommand::parentWindow
wxWindow * parentWindow() const
Definition: GUICommand.cc:75
HDBBrowserWindow::isRFEntrySelected
bool isRFEntrySelected()
Definition: HDBBrowserWindow.cc:397
HDB::HDBManager::rfByEntryID
RFEntry * rfByEntryID(RowID id) const
Definition: HDBManager.cc:2885
HDBBrowserWindow::selectedRFArchitecture
RowID selectedRFArchitecture()
Definition: HDBBrowserWindow.cc:483