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

#include <SetFUArchitectureCmd.hh>

Inheritance diagram for SetFUArchitectureCmd:
Inheritance graph
Collaboration diagram for SetFUArchitectureCmd:
Collaboration graph

Public Member Functions

 SetFUArchitectureCmd ()
 
virtual ~SetFUArchitectureCmd ()
 
virtual bool Do ()
 
virtual int id () const
 
virtual SetFUArchitectureCmdcreate () 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 setting architecture of a FUEntry.

Definition at line 41 of file SetFUArchitectureCmd.hh.

Constructor & Destructor Documentation

◆ SetFUArchitectureCmd()

SetFUArchitectureCmd::SetFUArchitectureCmd ( )

The Constructor.

Definition at line 48 of file SetFUArchitectureCmd.cc.

Referenced by create().

◆ ~SetFUArchitectureCmd()

SetFUArchitectureCmd::~SetFUArchitectureCmd ( )
virtual

The Destructor.

Definition at line 56 of file SetFUArchitectureCmd.cc.

56  {
57 }

Member Function Documentation

◆ create()

SetFUArchitectureCmd * SetFUArchitectureCmd::create ( ) const
virtual

Creates and returns a new instance of the command.

Returns
Newly created instance of this command.

Implements GUICommand.

Definition at line 131 of file SetFUArchitectureCmd.cc.

131  {
132  return new SetFUArchitectureCmd();
133 }

References SetFUArchitectureCmd().

Here is the call graph for this function:

◆ Do()

bool SetFUArchitectureCmd::Do ( )
virtual

Executes the command.

Implements GUICommand.

Definition at line 63 of file SetFUArchitectureCmd.cc.

63  {
64  HDBManager* manager = wxGetApp().mainFrame().hdbManager();
65 
66  if (manager == NULL) {
67  return false;
68  }
69 
70  const FUEntry* entry = manager->fuByID(
71  wxGetApp().mainFrame().browser()->selectedFUEntry());
72 
73  wxString fus[1000];
74  const std::set<RowID> fuIDs = manager->fuArchitectureIDs();
75  std::set<RowID>::iterator iter = fuIDs.begin();
76  int i = 0;
77  for (;iter != fuIDs.end(); iter++) {
78  fus[i] = WxConversion::toWxString(*iter);
79  i++;
80  }
81 
82  wxSingleChoiceDialog choicer(
83  parentWindow(), _T("Choose Architecture"), _T("Choose Architecture"),
84  i, fus);
85 
86  if (choicer.ShowModal() != wxID_OK) {
87  return false;
88  }
89 
90 
91  std::string archID = WxConversion::toString(choicer.GetStringSelection());
92  RowID rowID = Conversion::toInt(archID);
93  manager->unsetArchitectureForFU(entry->id());
94  manager->setArchitectureForFU(entry->id(), rowID);
95 
96  wxGetApp().mainFrame().update();
97  wxGetApp().mainFrame().browser()->selectFUEntry(entry->id());
98 
99  return true;
100 }

References HDB::HDBManager::fuArchitectureIDs(), HDB::HDBEntry::id(), GUICommand::parentWindow(), HDB::HDBManager::setArchitectureForFU(), Conversion::toInt(), WxConversion::toString(), WxConversion::toWxString(), and HDB::HDBManager::unsetArchitectureForFU().

Here is the call graph for this function:

◆ icon()

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

Returns name of the command icon file.

Returns
Command icon file name.

Implements GUICommand.

Definition at line 108 of file SetFUArchitectureCmd.cc.

108  {
109  return "";
110 
111 }

◆ id()

int SetFUArchitectureCmd::id ( ) const
virtual

Returns the command id.

Returns
Command identifier for this command.

Implements GUICommand.

Definition at line 120 of file SetFUArchitectureCmd.cc.

120  {
122 }

References HDBEditorConstants::COMMAND_SET_FU_ARCH.

◆ isEnabled()

bool SetFUArchitectureCmd::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 141 of file SetFUArchitectureCmd.cc.

141  {
142  HDB::HDBManager* manager = wxGetApp().mainFrame().hdbManager();
143 
144  if (manager == NULL) {
145  return false;
146  }
147 
148  HDBBrowserWindow* browser = wxGetApp().mainFrame().browser();
149 
150  if (!browser->isFUEntrySelected() ||
151  manager->fuByID(browser->selectedFUEntry())->hasArchitecture()) {
152 
153  return false;
154  }
155  return true;
156 }

References HDBBrowserWindow::isFUEntrySelected(), and HDBBrowserWindow::selectedFUEntry().

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
WxConversion::toWxString
static wxString toWxString(const std::string &source)
HDBBrowserWindow
Definition: HDBBrowserWindow.hh:59
HDB::HDBEntry::id
RowID id() const
Definition: HDBEntry.cc:85
RowID
int RowID
Type definition of row ID in relational databases.
Definition: DBTypes.hh:37
HDB::HDBManager::fuArchitectureIDs
std::set< RowID > fuArchitectureIDs() const
Definition: HDBManager.cc:2163
HDBBrowserWindow::isFUEntrySelected
bool isFUEntrySelected()
Definition: HDBBrowserWindow.cc:387
HDB::HDBManager
Definition: HDBManager.hh:82
GUICommand::GUICommand
GUICommand(std::string name, wxWindow *parent)
Definition: GUICommand.cc:42
HDBEditorConstants::COMMAND_SET_FU_ARCH
@ COMMAND_SET_FU_ARCH
Definition: HDBEditorConstants.hh:49
HDBEditorConstants::COMMAND_NAME_SET_FU_ARCH
static const std::string COMMAND_NAME_SET_FU_ARCH
Name of the set fu architecture command.
Definition: HDBEditorConstants.hh:90
Conversion::toInt
static int toInt(const T &source)
SetFUArchitectureCmd::SetFUArchitectureCmd
SetFUArchitectureCmd()
Definition: SetFUArchitectureCmd.cc:48
WxConversion::toString
static std::string toString(const wxString &source)
GUICommand::parentWindow
wxWindow * parentWindow() const
Definition: GUICommand.cc:75
HDB::HDBManager::unsetArchitectureForFU
void unsetArchitectureForFU(RowID fuID) const
Definition: HDBManager.cc:1432
HDBBrowserWindow::selectedFUEntry
RowID selectedFUEntry()
Definition: HDBBrowserWindow.cc:533
HDB::HDBManager::setArchitectureForFU
void setArchitectureForFU(RowID fuID, RowID archID) const
Definition: HDBManager.cc:1401