OpenASIP 2.2
Loading...
Searching...
No Matches
Public Member Functions | Private Member Functions | List of all members
HDBEditorDeleteCmd Class Reference

#include <HDBEditorDeleteCmd.hh>

Inheritance diagram for HDBEditorDeleteCmd:
Inheritance graph
Collaboration diagram for HDBEditorDeleteCmd:
Collaboration graph

Public Member Functions

 HDBEditorDeleteCmd ()
 
virtual ~HDBEditorDeleteCmd ()
 
virtual bool Do ()
 
virtual int id () const
 
virtual HDBEditorDeleteCmdcreate () 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
 

Private Member Functions

bool confirmDeletion (const wxString &component)
 

Detailed Description

Command for deleting entries from the HDB.

Definition at line 41 of file HDBEditorDeleteCmd.hh.

Constructor & Destructor Documentation

◆ HDBEditorDeleteCmd()

HDBEditorDeleteCmd::HDBEditorDeleteCmd ( )

The Constructor.

Definition at line 46 of file HDBEditorDeleteCmd.cc.

46 :
48}
static const std::string COMMAND_NAME_DELETE
Name of the delete command.

Referenced by create().

◆ ~HDBEditorDeleteCmd()

HDBEditorDeleteCmd::~HDBEditorDeleteCmd ( )
virtual

The Destructor.

Definition at line 54 of file HDBEditorDeleteCmd.cc.

54 {
55}

Member Function Documentation

◆ confirmDeletion()

bool HDBEditorDeleteCmd::confirmDeletion ( const wxString &  component)
private

Creates a dialog box to confirm deletion.

Parameters
componentType of component to be deleted.
Returns
true if Yes was pressed, false otherwise.

Definition at line 252 of file HDBEditorDeleteCmd.cc.

252 {
253 wxString message = _T("Are you sure you want to delete this ");
254 message.Append(component);
255 message.Append(_T("?"));
256 MessageDialog dialog(parentWindow(), _T("Confirm deletion"), message,
257 wxYES_DEFAULT | wxYES_NO);
258 return dialog.ShowModal() == wxID_YES;
259}
wxWindow * parentWindow() const
Definition GUICommand.cc:75

References GUICommand::parentWindow().

Referenced by Do().

Here is the call graph for this function:

◆ create()

HDBEditorDeleteCmd * HDBEditorDeleteCmd::create ( ) const
virtual

Creates a new instance of this command.

Returns
Newly created instance of this command.

Implements GUICommand.

Definition at line 206 of file HDBEditorDeleteCmd.cc.

206 {
207 return new HDBEditorDeleteCmd();
208}

References HDBEditorDeleteCmd().

Here is the call graph for this function:

◆ Do()

bool HDBEditorDeleteCmd::Do ( )
virtual

Executes the command.

Implements GUICommand.

Definition at line 61 of file HDBEditorDeleteCmd.cc.

61 {
62 HDB::HDBManager* manager = wxGetApp().mainFrame().hdbManager();
63
64 if (manager == NULL) {
65 return false;
66 }
67
68 HDBBrowserWindow* browser = wxGetApp().browser();
69 if (browser->isFUArchitectureSelected()) {
70 int id = browser->selectedFUArchitecture();
71 if (manager->canRemoveFUArchitecture(id)) {
72 if (confirmDeletion(_T("FU Architecture"))) {
73 manager->removeFUArchitecture(id);
74 } else {
75 return false;
76 }
77 } else {
78 wxString message = _T("FU Architecture ");
79 message.Append(WxConversion::toWxString(id));
80 message.Append(_T(" cannot be removed,\n"));
81 message.Append(_T("because it has an implementation."));
82 InformationDialog dialog(parentWindow(), message);
83 dialog.ShowModal();
84 return false;
85 }
86 } else if (browser->isRFArchitectureSelected()) {
87 int id = browser->selectedRFArchitecture();
88 if (manager->canRemoveRFArchitecture(id)) {
89 if (confirmDeletion(_T("RF Architecture"))) {
90 manager->removeRFArchitecture(id);
91 } else {
92 return false;
93 }
94 } else {
95 wxString message = _T("RF Architecture ");
96 message.Append(WxConversion::toWxString(id));
97 message.Append(_T(" cannot be removed,\n"));
98 message.Append(_T("because it has an implementation."));
99 InformationDialog dialog(parentWindow(), message);
100 dialog.ShowModal();
101 return false;
102 }
103 } else if (browser->isFUImplementationSelected()) {
104 if (confirmDeletion(_T("FU Implementation"))) {
105 int id = manager->fuEntryIDOfImplementation(
106 browser->selectedFUImplementation());
107 manager->removeFUEntry(id);
108 } else {
109 return false;
110 }
111 } else if (browser->isRFImplementationSelected()) {
112 if (confirmDeletion(_T("RF Implementation"))) {
113 int id = manager->rfEntryIDOfImplementation(
114 browser->selectedRFImplementation());
115 manager->removeRFEntry(id);
116 } else {
117 return false;
118 }
119 } else if (browser->isCostFunctionPluginSelected()) {
120 if (confirmDeletion(_T("Cost Function Plugin"))) {
121 int id = browser->selectedCostFunctionPlugin();
122 manager->removeCostFunctionPlugin(id);
123 } else {
124 return false;
125 }
126 } else if (browser->isFUEntrySelected()) {
127 if (confirmDeletion(_T("FU Entry"))) {
128 int id = browser->selectedFUEntry();
129 manager->removeFUEntry(id);
130 } else {
131 return false;
132 }
133 } else if (browser->isRFEntrySelected()) {
134 if (confirmDeletion(_T("RF Entry"))) {
135 int id = browser->selectedRFEntry();
136 manager->removeRFEntry(id);
137 } else {
138 return false;
139 }
140 } else if (browser->isBusEntrySelected()) {
141 if (confirmDeletion(_T("Bus Entry"))) {
142 int id = browser->selectedBusEntry();
143 manager->removeBusEntry(id);
144 } else {
145 return false;
146 }
147 } else if (browser->isSocketEntrySelected()) {
148 if (confirmDeletion(_T("Socket Entry"))) {
149 int id = browser->selectedSocketEntry();
150 manager->removeSocketEntry(id);
151 } else {
152 return false;
153 }
154 } else if (browser->isOperationImplementationSelected()) {
155 if (confirmDeletion(_T("Operation Implementation"))) {
156 int id = browser->selectedOperationImplementation();
158 } else {
159 return false;
160 }
161 } else if (browser->isOperationImplementationResourceSelected()) {
162 if (confirmDeletion(_T("Operation Implementation Resource"))) {
163 int id = browser->selectedOperationImplementationResource();
165 } else {
166 return false;
167 }
168 } else {
169 return false;
170 }
171
172 wxGetApp().mainFrame().update();
173
174 return true;
175}
bool isCostFunctionPluginSelected()
RowID selectedOperationImplementation()
bool isOperationImplementationResourceSelected()
RowID selectedOperationImplementationResource()
bool isOperationImplementationSelected()
RowID selectedCostFunctionPlugin()
bool confirmDeletion(const wxString &component)
virtual void removeFUEntry(RowID id) const
void removeOperationImplementation(RowID id)
virtual void removeSocketEntry(RowID id) const
void removeOperationImplementationResource(RowID id)
bool canRemoveFUArchitecture(RowID archID) const
virtual void removeRFEntry(RowID id) const
RowID fuEntryIDOfImplementation(RowID implID) const
virtual void removeBusEntry(RowID id) const
virtual void removeRFArchitecture(RowID archID) const
RowID rfEntryIDOfImplementation(RowID implID) const
virtual void removeCostFunctionPlugin(RowID pluginID) const
bool canRemoveRFArchitecture(RowID archID) const
virtual void removeFUArchitecture(RowID archID) const
static wxString toWxString(const std::string &source)

References HDB::HDBManager::canRemoveFUArchitecture(), HDB::HDBManager::canRemoveRFArchitecture(), confirmDeletion(), HDB::HDBManager::fuEntryIDOfImplementation(), HDBBrowserWindow::isBusEntrySelected(), HDBBrowserWindow::isCostFunctionPluginSelected(), HDBBrowserWindow::isFUArchitectureSelected(), HDBBrowserWindow::isFUEntrySelected(), HDBBrowserWindow::isFUImplementationSelected(), HDBBrowserWindow::isOperationImplementationResourceSelected(), HDBBrowserWindow::isOperationImplementationSelected(), HDBBrowserWindow::isRFArchitectureSelected(), HDBBrowserWindow::isRFEntrySelected(), HDBBrowserWindow::isRFImplementationSelected(), HDBBrowserWindow::isSocketEntrySelected(), GUICommand::parentWindow(), HDB::HDBManager::removeBusEntry(), HDB::HDBManager::removeCostFunctionPlugin(), HDB::HDBManager::removeFUArchitecture(), HDB::HDBManager::removeFUEntry(), HDB::HDBManager::removeOperationImplementation(), HDB::HDBManager::removeOperationImplementationResource(), HDB::HDBManager::removeRFArchitecture(), HDB::HDBManager::removeRFEntry(), HDB::HDBManager::removeSocketEntry(), HDB::HDBManager::rfEntryIDOfImplementation(), HDBBrowserWindow::selectedBusEntry(), HDBBrowserWindow::selectedCostFunctionPlugin(), HDBBrowserWindow::selectedFUArchitecture(), HDBBrowserWindow::selectedFUEntry(), HDBBrowserWindow::selectedFUImplementation(), HDBBrowserWindow::selectedOperationImplementation(), HDBBrowserWindow::selectedOperationImplementationResource(), HDBBrowserWindow::selectedRFArchitecture(), HDBBrowserWindow::selectedRFEntry(), HDBBrowserWindow::selectedRFImplementation(), HDBBrowserWindow::selectedSocketEntry(), and WxConversion::toWxString().

Here is the call graph for this function:

◆ icon()

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

Returns name of the command icon file.

Returns
Command icon file name.

Implements GUICommand.

Definition at line 184 of file HDBEditorDeleteCmd.cc.

184 {
185 return "";
186}

◆ id()

int HDBEditorDeleteCmd::id ( ) const
virtual

Returns the command id.

Returns
Command identifier of this command.

Implements GUICommand.

Definition at line 195 of file HDBEditorDeleteCmd.cc.

References HDBEditorConstants::COMMAND_DELETE.

◆ isEnabled()

bool HDBEditorDeleteCmd::isEnabled ( )
virtual

Returns true if the command should be enabled in the menu/toolbar.

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

Implements GUICommand.

Definition at line 217 of file HDBEditorDeleteCmd.cc.

217 {
218 HDB::HDBManager* manager = wxGetApp().mainFrame().hdbManager();
219
220 if (manager == NULL) {
221 return false;
222 }
223
224 HDBBrowserWindow* browser = wxGetApp().browser();
225
226 if (browser->isFUArchitectureSelected() ||
227 browser->isRFArchitectureSelected() ||
228 browser->isFUImplementationSelected() ||
229 browser->isRFImplementationSelected() ||
230 browser->isCostFunctionPluginSelected() ||
231 browser->isFUEntrySelected() ||
232 browser->isRFEntrySelected() ||
233 browser->isBusEntrySelected() ||
234 browser->isSocketEntrySelected() ||
237 ) {
238
239 return true;
240 }
241
242 return false;
243}

References HDBBrowserWindow::isBusEntrySelected(), HDBBrowserWindow::isCostFunctionPluginSelected(), HDBBrowserWindow::isFUArchitectureSelected(), HDBBrowserWindow::isFUEntrySelected(), HDBBrowserWindow::isFUImplementationSelected(), HDBBrowserWindow::isOperationImplementationResourceSelected(), HDBBrowserWindow::isOperationImplementationSelected(), HDBBrowserWindow::isRFArchitectureSelected(), HDBBrowserWindow::isRFEntrySelected(), HDBBrowserWindow::isRFImplementationSelected(), and HDBBrowserWindow::isSocketEntrySelected().

Here is the call graph for this function:

The documentation for this class was generated from the following files: