OpenASIP 2.2
Loading...
Searching...
No Matches
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.

60 :
62}
static const std::string COMMAND_NAME_MODIFY
Name of the modify command.

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
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}
#define assert(condition)
std::string fileName() const
std::string errorMessage() const
Definition Exception.cc:123
int lineNum() const
wxWindow * parentWindow() const
Definition GUICommand.cc:75
bool isCostFunctionPluginSelected()
RowID selectedCostFunctionPlugin()
TTAMachine::FunctionUnit & architecture() const
FUImplementation & implementation() const
Definition FUEntry.cc:86
virtual bool hasImplementation() const
Definition FUEntry.cc:74
FUArchitecture & architecture() const
Definition FUEntry.cc:129
FUEntry * fuByEntryID(RowID id) const
virtual void removeFUImplementation(RowID implementationID) const
virtual void removeRFImplementation(RowID implID) const
RowID addFUImplementation(const FUEntry &entry) const
RowID addRFImplementation(const RFImplementation &implementation, RowID rfEntryID)
RowID fuEntryIDOfImplementation(RowID implID) const
RowID rfEntryIDOfImplementation(RowID implID) const
RFEntry * rfByEntryID(RowID id) const
virtual bool hasImplementation() const
Definition RFEntry.cc:74
RFImplementation & implementation() const
Definition RFEntry.cc:102
static wxString toWxString(const std::string &source)

References HDB::HDBManager::addFUImplementation(), HDB::HDBManager::addRFImplementation(), HDB::FUArchitecture::architecture(), HDB::FUEntry::architecture(), assert, Exception::errorMessage(), Exception::fileName(), HDB::HDBManager::fuByEntryID(), HDB::HDBManager::fuEntryIDOfImplementation(), HDB::HWBlockImplementation::hasID(), HDB::FUEntry::hasImplementation(), HDB::RFEntry::hasImplementation(), HDB::HWBlockImplementation::id(), HDB::FUEntry::implementation(), HDB::RFEntry::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.

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: