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

#include <HDBEditorModifyCmd.hh>

Inheritance diagram for HDBEditorModifyCmd:
Inheritance graph
Collaboration diagram for HDBEditorModifyCmd:
Collaboration graph

Public Member Functions

 HDBEditorModifyCmd ()
 
virtual ~HDBEditorModifyCmd ()
 
virtual bool Do ()
 
virtual int id () const
 
virtual HDBEditorModifyCmdcreate () 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 modifying HDB items.

Definition at line 41 of file HDBEditorModifyCmd.hh.

Constructor & Destructor Documentation

◆ HDBEditorModifyCmd()

HDBEditorModifyCmd::HDBEditorModifyCmd ( )

The Constructor.

Definition at line 60 of file HDBEditorModifyCmd.cc.

Referenced by create().

◆ ~HDBEditorModifyCmd()

HDBEditorModifyCmd::~HDBEditorModifyCmd ( )
virtual

The Destructor.

Definition at line 68 of file HDBEditorModifyCmd.cc.

68  {
69 }

Member Function Documentation

◆ create()

HDBEditorModifyCmd * HDBEditorModifyCmd::create ( ) const
virtual

Creates a new instance of this command.

Returns
Newly created instance of this command.

Implements GUICommand.

Definition at line 207 of file HDBEditorModifyCmd.cc.

207  {
208  return new HDBEditorModifyCmd();
209 }

References HDBEditorModifyCmd().

Here is the call graph for this function:

◆ Do()

bool HDBEditorModifyCmd::Do ( )
virtual

Executes the command.

Implements GUICommand.

Definition at line 75 of file HDBEditorModifyCmd.cc.

75  {
76 
77  HDB::HDBManager* manager = wxGetApp().mainFrame().hdbManager();
78  if (manager == NULL) {
79  return false;
80  }
81 
82  HDBBrowserWindow* browser = wxGetApp().mainFrame().browser();
83 
84 
85  if (browser->isFUImplementationSelected()) {
86 
87  // FU implementation modification.
88 
89  int entryID = manager->fuEntryIDOfImplementation(
90  browser->selectedFUImplementation());
91 
92  HDB::FUEntry* entry = manager->fuByEntryID(entryID);
93 
95  parentWindow(), -1, entry->implementation(),
96  entry->architecture().architecture());
97 
98  if (dialog.ShowModal() == wxID_OK) {
99  try {
100  assert(entry->hasImplementation() &&
101  entry->implementation().hasID());
102 
103  int implID = entry->implementation().id();
104  manager->removeFUImplementation(implID);
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  return false;
119  }
120  } else {
121  delete entry;
122  }
123 
124  return true;
125  } else if (browser->isRFImplementationSelected()) {
126 
127  // RF implementation modification.
128 
129  int entryID = manager->rfEntryIDOfImplementation(
130  browser->selectedRFImplementation());
131 
132  HDB::RFEntry* entry = manager->rfByEntryID(entryID);
133 
134  RFImplementationDialog dialog(
135  parentWindow(), -1, entry->implementation());
136 
137  if (dialog.ShowModal() == wxID_OK) {
138  try {
139  assert(entry->hasImplementation() &&
140  entry->implementation().hasID());
141 
142  int implID = entry->implementation().id();
143  manager->removeRFImplementation(implID);
144  int id = manager->addRFImplementation(
145  entry->implementation(), entryID);
146  //can be commented for not update DB-> fast editing
147  wxGetApp().mainFrame().update();
148  wxGetApp().mainFrame().browser()->selectRFImplementation(id);
149  } catch (Exception& e) {
150  wxString message = _T("Error:\n");
151  message.Append(WxConversion::toWxString(e.errorMessage()));
152  message.Append(_T("\n"));
153  message.Append(WxConversion::toWxString(e.lineNum()));
154  message.Append(_T(": "));
155  message.Append(WxConversion::toWxString(e.fileName()));
156  ErrorDialog dialog(parentWindow(), message);
157  dialog.ShowModal();
158  delete entry;
159  return false;
160  }
161  } else {
162  delete entry;
163  }
164 
165  return true;
166  } else if (browser->isCostFunctionPluginSelected()) {
167 
169  parentWindow(), -1,
170  *manager, browser->selectedCostFunctionPlugin());
171 
172  dialog.ShowModal();
173  wxGetApp().mainFrame().update();
174  return true;
175  }
176 
177  return false;
178 }

References HDB::HDBManager::addFUImplementation(), HDB::HDBManager::addRFImplementation(), HDB::FUEntry::architecture(), HDB::FUArchitecture::architecture(), assert, Exception::errorMessage(), Exception::fileName(), HDB::HDBManager::fuByEntryID(), HDB::HDBManager::fuEntryIDOfImplementation(), HDB::HWBlockImplementation::hasID(), HDB::RFEntry::hasImplementation(), HDB::FUEntry::hasImplementation(), HDB::HWBlockImplementation::id(), HDB::RFEntry::implementation(), HDB::FUEntry::implementation(), HDBBrowserWindow::isCostFunctionPluginSelected(), HDBBrowserWindow::isFUImplementationSelected(), HDBBrowserWindow::isRFImplementationSelected(), Exception::lineNum(), GUICommand::parentWindow(), HDB::HDBManager::removeFUImplementation(), HDB::HDBManager::removeRFImplementation(), HDB::HDBManager::rfByEntryID(), HDB::HDBManager::rfEntryIDOfImplementation(), HDBBrowserWindow::selectedCostFunctionPlugin(), HDBBrowserWindow::selectedFUImplementation(), HDBBrowserWindow::selectedRFImplementation(), and WxConversion::toWxString().

Here is the call graph for this function:

◆ icon()

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

Returns name of the command icon file.

Returns
Command icon file name.

Implements GUICommand.

Definition at line 186 of file HDBEditorModifyCmd.cc.

186  {
187  return "";
188 }

◆ id()

int HDBEditorModifyCmd::id ( ) const
virtual

Returns the command id.

Returns
Command identifier.

Implements GUICommand.

Definition at line 196 of file HDBEditorModifyCmd.cc.

196  {
198 }

References HDBEditorConstants::COMMAND_MODIFY.

◆ isEnabled()

bool HDBEditorModifyCmd::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 218 of file HDBEditorModifyCmd.cc.

218  {
219  HDB::HDBManager* manager = wxGetApp().mainFrame().hdbManager();
220 
221  if (manager == NULL) {
222  return false;
223  }
224 
225  HDBBrowserWindow* browser = wxGetApp().mainFrame().browser();
226 
227  if (browser->isFUImplementationSelected() ||
228  browser->isRFImplementationSelected() ||
229  browser->isCostFunctionPluginSelected()) {
230  return true;
231  }
232 
233  return false;
234 }

References HDBBrowserWindow::isCostFunctionPluginSelected(), HDBBrowserWindow::isFUImplementationSelected(), and HDBBrowserWindow::isRFImplementationSelected().

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)
HDB::RFEntry::hasImplementation
virtual bool hasImplementation() const
Definition: RFEntry.cc:74
HDBBrowserWindow
Definition: HDBBrowserWindow.hh:59
FUImplementationDialog
Definition: FUImplementationDialog.hh:52
HDB::RFEntry
Definition: RFEntry.hh:47
HDBBrowserWindow::isRFImplementationSelected
bool isRFImplementationSelected()
Definition: HDBBrowserWindow.cc:376
HDB::FUArchitecture::architecture
TTAMachine::FunctionUnit & architecture() const
Definition: FUArchitecture.cc:131
HDB::HDBManager::removeFUImplementation
virtual void removeFUImplementation(RowID implementationID) const
Definition: HDBManager.cc:1325
HDBEditorModifyCmd::HDBEditorModifyCmd
HDBEditorModifyCmd()
Definition: HDBEditorModifyCmd.cc:60
HDBEditorConstants::COMMAND_NAME_MODIFY
static const std::string COMMAND_NAME_MODIFY
Name of the modify command.
Definition: HDBEditorConstants.hh:100
HDB::HDBManager::rfEntryIDOfImplementation
RowID rfEntryIDOfImplementation(RowID implID) const
Definition: HDBManager.cc:2796
Exception::fileName
std::string fileName() const
assert
#define assert(condition)
Definition: Application.hh:86
CostFunctionPluginDialog
Definition: CostFunctionPluginDialog.hh:46
HDBEditorConstants::COMMAND_MODIFY
@ COMMAND_MODIFY
Definition: HDBEditorConstants.hh:59
ErrorDialog
Definition: ErrorDialog.hh:42
HDB::FUEntry::architecture
FUArchitecture & architecture() const
Definition: FUEntry.cc:129
HDBBrowserWindow::selectedCostFunctionPlugin
RowID selectedCostFunctionPlugin()
Definition: HDBBrowserWindow.cc:598
HDB::HDBManager::fuEntryIDOfImplementation
RowID fuEntryIDOfImplementation(RowID implID) const
Definition: HDBManager.cc:2765
HDB::HDBManager
Definition: HDBManager.hh:82
HDB::RFEntry::implementation
RFImplementation & implementation() const
Definition: RFEntry.cc:102
HDBBrowserWindow::selectedRFImplementation
RowID selectedRFImplementation()
Definition: HDBBrowserWindow.cc:517
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::selectedFUImplementation
RowID selectedFUImplementation()
Definition: HDBBrowserWindow.cc:500
HDB::HWBlockImplementation::id
RowID id() const
Definition: HWBlockImplementation.cc:128
HDB::HDBManager::removeRFImplementation
virtual void removeRFImplementation(RowID implID) const
Definition: HDBManager.cc:1808
HDB::FUEntry::hasImplementation
virtual bool hasImplementation() const
Definition: FUEntry.cc:74
HDB::FUEntry::implementation
FUImplementation & implementation() const
Definition: FUEntry.cc:86
HDB::HDBManager::fuByEntryID
FUEntry * fuByEntryID(RowID id) const
Definition: HDBManager.cc:2828
HDBBrowserWindow::isFUImplementationSelected
bool isFUImplementationSelected()
Definition: HDBBrowserWindow.cc:364
HDBBrowserWindow::isCostFunctionPluginSelected
bool isCostFunctionPluginSelected()
Definition: HDBBrowserWindow.cc:428
HDB::HWBlockImplementation::hasID
bool hasID() const
Definition: HWBlockImplementation.cc:105
RFImplementationDialog
Definition: RFImplementationDialog.hh:45
GUICommand::parentWindow
wxWindow * parentWindow() const
Definition: GUICommand.cc:75
HDB::HDBManager::rfByEntryID
RFEntry * rfByEntryID(RowID id) const
Definition: HDBManager.cc:2885