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

#include <SetRFArchitectureCmd.hh>

Inheritance diagram for SetRFArchitectureCmd:
Inheritance graph
Collaboration diagram for SetRFArchitectureCmd:
Collaboration graph

Public Member Functions

 SetRFArchitectureCmd ()
 
virtual ~SetRFArchitectureCmd ()
 
virtual bool Do ()
 
virtual int id () const
 
virtual SetRFArchitectureCmdcreate () 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 RFEntry.

Definition at line 41 of file SetRFArchitectureCmd.hh.

Constructor & Destructor Documentation

◆ SetRFArchitectureCmd()

SetRFArchitectureCmd::SetRFArchitectureCmd ( )

The Constructor.

Definition at line 48 of file SetRFArchitectureCmd.cc.

Referenced by create().

◆ ~SetRFArchitectureCmd()

SetRFArchitectureCmd::~SetRFArchitectureCmd ( )
virtual

The Destructor.

Definition at line 56 of file SetRFArchitectureCmd.cc.

56  {
57 }

Member Function Documentation

◆ create()

SetRFArchitectureCmd * SetRFArchitectureCmd::create ( ) const
virtual

Creates and returns a new instance of the command.

Returns
Newly created instance of this command.

Implements GUICommand.

Definition at line 132 of file SetRFArchitectureCmd.cc.

132  {
133  return new SetRFArchitectureCmd();
134 }

References SetRFArchitectureCmd().

Here is the call graph for this function:

◆ Do()

bool SetRFArchitectureCmd::Do ( )
virtual

Executes the command.

Implements GUICommand.

Definition at line 63 of file SetRFArchitectureCmd.cc.

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

References HDB::HDBEntry::id(), GUICommand::parentWindow(), HDB::HDBManager::rfArchitectureIDs(), HDB::HDBManager::setArchitectureForRF(), Conversion::toInt(), WxConversion::toString(), WxConversion::toWxString(), and HDB::HDBManager::unsetArchitectureForRF().

Here is the call graph for this function:

◆ icon()

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

Returns name of the command icon file.

Returns
Command icon file name.

Implements GUICommand.

Definition at line 109 of file SetRFArchitectureCmd.cc.

109  {
110  return "";
111 
112 }

◆ id()

int SetRFArchitectureCmd::id ( ) const
virtual

Returns the command id.

Returns
Command identifier for this command.

Implements GUICommand.

Definition at line 121 of file SetRFArchitectureCmd.cc.

121  {
123 }

References HDBEditorConstants::COMMAND_SET_RF_ARCH.

◆ isEnabled()

bool SetRFArchitectureCmd::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 142 of file SetRFArchitectureCmd.cc.

142  {
143  HDB::HDBManager* manager = wxGetApp().mainFrame().hdbManager();
144 
145  if (manager == NULL) {
146  return false;
147  }
148 
149  if (!wxGetApp().mainFrame().browser()->isRFEntrySelected()) {
150  return false;
151  }
152  return true;
153 }

The documentation for this class was generated from the following files:
WxConversion::toWxString
static wxString toWxString(const std::string &source)
HDB::HDBEntry::id
RowID id() const
Definition: HDBEntry.cc:85
SetRFArchitectureCmd::SetRFArchitectureCmd
SetRFArchitectureCmd()
Definition: SetRFArchitectureCmd.cc:48
HDB::RFEntry
Definition: RFEntry.hh:47
RowID
int RowID
Type definition of row ID in relational databases.
Definition: DBTypes.hh:37
HDB::HDBManager::unsetArchitectureForRF
void unsetArchitectureForRF(RowID rfID) const
Definition: HDBManager.cc:1930
HDB::HDBManager::setArchitectureForRF
void setArchitectureForRF(RowID rfID, RowID archID) const
Definition: HDBManager.cc:1895
HDBEditorConstants::COMMAND_NAME_SET_RF_ARCH
static const std::string COMMAND_NAME_SET_RF_ARCH
Name of the set rf architecture command.
Definition: HDBEditorConstants.hh:92
HDB::HDBManager
Definition: HDBManager.hh:82
HDB::HDBManager::rfArchitectureIDs
std::set< RowID > rfArchitectureIDs() const
Definition: HDBManager.cc:2734
GUICommand::GUICommand
GUICommand(std::string name, wxWindow *parent)
Definition: GUICommand.cc:42
HDBEditorConstants::COMMAND_SET_RF_ARCH
@ COMMAND_SET_RF_ARCH
Definition: HDBEditorConstants.hh:50
Conversion::toInt
static int toInt(const T &source)
WxConversion::toString
static std::string toString(const wxString &source)
GUICommand::parentWindow
wxWindow * parentWindow() const
Definition: GUICommand.cc:75