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

48 :
50}
static const std::string COMMAND_NAME_SET_FU_ARCH
Name of the set fu architecture command.

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}
int RowID
Type definition of row ID in relational databases.
Definition DBTypes.hh:37
static int toInt(const T &source)
wxWindow * parentWindow() const
Definition GUICommand.cc:75
RowID id() const
Definition HDBEntry.cc:85
std::set< RowID > fuArchitectureIDs() const
void setArchitectureForFU(RowID fuID, RowID archID) const
void unsetArchitectureForFU(RowID fuID) const
static wxString toWxString(const std::string &source)
static std::string toString(const wxString &source)

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.

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: