OpenASIP  2.0
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.

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 }

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();
157  manager->removeOperationImplementation(id);
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 }

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.

195  {
197 }

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:
HDB::HDBManager::removeOperationImplementationResource
void removeOperationImplementationResource(RowID id)
Definition: HDBManager.cc:2658
WxConversion::toWxString
static wxString toWxString(const std::string &source)
HDBBrowserWindow
Definition: HDBBrowserWindow.hh:59
HDB::HDBManager::removeFUEntry
virtual void removeFUEntry(RowID id) const
Definition: HDBManager.cc:1039
HDBBrowserWindow::isRFArchitectureSelected
bool isRFArchitectureSelected()
Definition: HDBBrowserWindow.cc:353
HDB::HDBManager::removeOperationImplementation
void removeOperationImplementation(RowID id)
Definition: HDBManager.cc:2622
HDB::HDBManager::removeBusEntry
virtual void removeBusEntry(RowID id) const
Definition: HDBManager.cc:3418
HDBBrowserWindow::isRFImplementationSelected
bool isRFImplementationSelected()
Definition: HDBBrowserWindow.cc:376
HDBEditorConstants::COMMAND_NAME_DELETE
static const std::string COMMAND_NAME_DELETE
Name of the delete command.
Definition: HDBEditorConstants.hh:82
HDB::HDBManager::removeRFEntry
virtual void removeRFEntry(RowID id) const
Definition: HDBManager.cc:1583
HDB::HDBManager::removeSocketEntry
virtual void removeSocketEntry(RowID id) const
Definition: HDBManager.cc:3631
HDB::HDBManager::rfEntryIDOfImplementation
RowID rfEntryIDOfImplementation(RowID implID) const
Definition: HDBManager.cc:2796
MessageDialog
Definition: MessageDialog.hh:44
HDBBrowserWindow::isSocketEntrySelected
bool isSocketEntrySelected()
Definition: HDBBrowserWindow.cc:417
HDBBrowserWindow::selectedOperationImplementationResource
RowID selectedOperationImplementationResource()
Definition: HDBBrowserWindow.cc:632
HDBBrowserWindow::isBusEntrySelected
bool isBusEntrySelected()
Definition: HDBBrowserWindow.cc:407
HDBBrowserWindow::isFUEntrySelected
bool isFUEntrySelected()
Definition: HDBBrowserWindow.cc:387
HDB::HDBManager::canRemoveFUArchitecture
bool canRemoveFUArchitecture(RowID archID) const
Definition: HDBManager.cc:904
HDBEditorDeleteCmd::HDBEditorDeleteCmd
HDBEditorDeleteCmd()
Definition: HDBEditorDeleteCmd.cc:46
HDBBrowserWindow::selectedFUArchitecture
RowID selectedFUArchitecture()
Definition: HDBBrowserWindow.cc:466
HDBBrowserWindow::isOperationImplementationResourceSelected
bool isOperationImplementationResourceSelected()
Definition: HDBBrowserWindow.cc:439
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
HDBBrowserWindow::selectedRFImplementation
RowID selectedRFImplementation()
Definition: HDBBrowserWindow.cc:517
HDBBrowserWindow::selectedOperationImplementation
RowID selectedOperationImplementation()
Definition: HDBBrowserWindow.cc:614
HDB::HDBManager::removeCostFunctionPlugin
virtual void removeCostFunctionPlugin(RowID pluginID) const
Definition: HDBManager.cc:684
GUICommand::GUICommand
GUICommand(std::string name, wxWindow *parent)
Definition: GUICommand.cc:42
HDBBrowserWindow::selectedFUImplementation
RowID selectedFUImplementation()
Definition: HDBBrowserWindow.cc:500
HDBBrowserWindow::selectedRFEntry
RowID selectedRFEntry()
Definition: HDBBrowserWindow.cc:549
HDBEditorConstants::COMMAND_DELETE
@ COMMAND_DELETE
Definition: HDBEditorConstants.hh:60
HDBBrowserWindow::selectedBusEntry
RowID selectedBusEntry()
Definition: HDBBrowserWindow.cc:565
HDBBrowserWindow::isFUArchitectureSelected
bool isFUArchitectureSelected()
Definition: HDBBrowserWindow.cc:343
HDBEditorDeleteCmd::confirmDeletion
bool confirmDeletion(const wxString &component)
Definition: HDBEditorDeleteCmd.cc:252
InformationDialog
Definition: InformationDialog.hh:42
HDBBrowserWindow::selectedSocketEntry
RowID selectedSocketEntry()
Definition: HDBBrowserWindow.cc:581
HDBBrowserWindow::isOperationImplementationSelected
bool isOperationImplementationSelected()
Definition: HDBBrowserWindow.cc:453
HDB::HDBManager::canRemoveRFArchitecture
bool canRemoveRFArchitecture(RowID archID) const
Definition: HDBManager.cc:1508
HDB::HDBManager::removeFUArchitecture
virtual void removeFUArchitecture(RowID archID) const
Definition: HDBManager.cc:941
HDBBrowserWindow::isFUImplementationSelected
bool isFUImplementationSelected()
Definition: HDBBrowserWindow.cc:364
HDBBrowserWindow::isCostFunctionPluginSelected
bool isCostFunctionPluginSelected()
Definition: HDBBrowserWindow.cc:428
HDB::HDBManager::removeRFArchitecture
virtual void removeRFArchitecture(RowID archID) const
Definition: HDBManager.cc:1535
GUICommand::parentWindow
wxWindow * parentWindow() const
Definition: GUICommand.cc:75
HDBBrowserWindow::selectedFUEntry
RowID selectedFUEntry()
Definition: HDBBrowserWindow.cc:533
HDBBrowserWindow::isRFEntrySelected
bool isRFEntrySelected()
Definition: HDBBrowserWindow.cc:397
HDBBrowserWindow::selectedRFArchitecture
RowID selectedRFArchitecture()
Definition: HDBBrowserWindow.cc:483