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

#include <AddFUImplementationCmd.hh>

Inheritance diagram for AddFUImplementationCmd:
Inheritance graph
Collaboration diagram for AddFUImplementationCmd:
Collaboration graph

Public Member Functions

 AddFUImplementationCmd ()
 
virtual ~AddFUImplementationCmd ()
 
virtual bool Do ()
 
virtual int id () const
 
virtual AddFUImplementationCmdcreate () 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 adding implementation of a FU architecture to HDB.

Definition at line 41 of file AddFUImplementationCmd.hh.

Constructor & Destructor Documentation

◆ AddFUImplementationCmd()

AddFUImplementationCmd::AddFUImplementationCmd ( )

The Constructor.

Definition at line 53 of file AddFUImplementationCmd.cc.

53 :
55}
static const std::string COMMAND_NAME_ADD_FU_IMPLEMENTATION
Name of the add fu implementation cmd.

Referenced by create().

◆ ~AddFUImplementationCmd()

AddFUImplementationCmd::~AddFUImplementationCmd ( )
virtual

The Destructor.

Definition at line 61 of file AddFUImplementationCmd.cc.

61 {
62}

Member Function Documentation

◆ create()

AddFUImplementationCmd * AddFUImplementationCmd::create ( ) const
virtual

Creates a new instance of this command.

Returns
Newly created instance of this command.

Implements GUICommand.

Definition at line 155 of file AddFUImplementationCmd.cc.

155 {
156 return new AddFUImplementationCmd();
157}

References AddFUImplementationCmd().

Here is the call graph for this function:

◆ Do()

bool AddFUImplementationCmd::Do ( )
virtual

Executes the command.

Implements GUICommand.

Definition at line 68 of file AddFUImplementationCmd.cc.

68 {
69
70 HDB::HDBManager* manager = wxGetApp().mainFrame().hdbManager();
71 if (manager == NULL) {
72 return false;
73 }
74
75 HDBBrowserWindow* browser = wxGetApp().mainFrame().browser();
76
78 new HDB::FUImplementation("", "", "","", "", "");
79
80 HDB::FUEntry* entry = NULL;
81
82 if (browser->isFUEntrySelected()) {
83 entry = manager->fuByEntryID(browser->selectedFUEntry());
84 } else if (browser->isFUArchitectureSelected()) {
85 int id = manager->addFUEntry();
86 manager->setArchitectureForFU(id, browser->selectedFUArchitecture());
87 entry = manager->fuByEntryID(id);
88 } else {
89 return false;
90 }
91
92 const TTAMachine::FunctionUnit& arch =
93 entry->architecture().architecture();
94
95 for (int i = 0; i < arch.portCount(); i++) {
97 "", arch.port(i)->name(), "", "", "", *implementation);
98 }
99
101
102 if (dialog.ShowModal() == wxID_OK) {
103 try {
105 int id = manager->addFUImplementation(*entry);
106 wxGetApp().mainFrame().update();
107 wxGetApp().mainFrame().browser()->selectFUImplementation(id);
108 } catch (Exception& e) {
109 wxString message = _T("Error:\n");
110 message.Append(WxConversion::toWxString(e.errorMessage()));
111 message.Append(_T("\n"));
112 message.Append(WxConversion::toWxString(e.lineNum()));
113 message.Append(_T(": "));
114 message.Append(WxConversion::toWxString(e.fileName()));
115 ErrorDialog dialog(parentWindow(), message);
116 dialog.ShowModal();
117 delete entry;
118 delete implementation;
119 return false;
120 }
121 } else {
122 delete implementation;
123 }
124 delete entry;
125 return true;
126}
IDF::MachineImplementation * implementation
the implementation definition of the estimated processor
std::string fileName() const
std::string errorMessage() const
Definition Exception.cc:123
int lineNum() const
wxWindow * parentWindow() const
Definition GUICommand.cc:75
TTAMachine::FunctionUnit & architecture() const
void setImplementation(FUImplementation *implementation)
Definition FUEntry.cc:103
FUArchitecture & architecture() const
Definition FUEntry.cc:129
FUEntry * fuByEntryID(RowID id) const
RowID addFUEntry() const
RowID addFUImplementation(const FUEntry &entry) const
void setArchitectureForFU(RowID fuID, RowID archID) const
virtual BaseFUPort * port(const std::string &name) const
virtual std::string name() const
Definition Port.cc:141
virtual int portCount() const
Definition Unit.cc:135
static wxString toWxString(const std::string &source)

References HDB::HDBManager::addFUEntry(), HDB::HDBManager::addFUImplementation(), HDB::FUArchitecture::architecture(), HDB::FUEntry::architecture(), Exception::errorMessage(), Exception::fileName(), HDB::HDBManager::fuByEntryID(), implementation, HDBBrowserWindow::isFUArchitectureSelected(), HDBBrowserWindow::isFUEntrySelected(), Exception::lineNum(), TTAMachine::Port::name(), GUICommand::parentWindow(), TTAMachine::FunctionUnit::port(), TTAMachine::Unit::portCount(), HDBBrowserWindow::selectedFUArchitecture(), HDBBrowserWindow::selectedFUEntry(), HDB::HDBManager::setArchitectureForFU(), HDB::FUEntry::setImplementation(), and WxConversion::toWxString().

Here is the call graph for this function:

◆ icon()

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

Returns name of the command icon file.

Returns
Command icon file name.

Implements GUICommand.

Definition at line 134 of file AddFUImplementationCmd.cc.

134 {
135 return "";
136}

◆ id()

int AddFUImplementationCmd::id ( ) const
virtual

Returns the command id.

Returns
Command identifier.

Implements GUICommand.

Definition at line 144 of file AddFUImplementationCmd.cc.

References HDBEditorConstants::COMMAND_ADD_FU_IMPLEMENTATION.

◆ isEnabled()

bool AddFUImplementationCmd::isEnabled ( )
virtual

Returns true if the command should be enabled in the tool/menubar.

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

Implements GUICommand.

Definition at line 166 of file AddFUImplementationCmd.cc.

166 {
167 HDB::HDBManager* manager = wxGetApp().mainFrame().hdbManager();
168
169 if (manager == NULL) {
170 return false;
171 }
172
173 HDBBrowserWindow* browser = wxGetApp().mainFrame().browser();
174
175 if (browser->isFUArchitectureSelected()) {
176 return true;
177 } else if (browser->isFUEntrySelected()) {
178 HDB::FUEntry* entry = manager->fuByEntryID(browser->selectedFUEntry());
179 if (entry->hasArchitecture() && !entry->hasImplementation()) {
180 delete entry;
181 return true;
182 }
183 delete entry;
184 }
185 return false;
186}
virtual bool hasImplementation() const
Definition FUEntry.cc:74
virtual bool hasArchitecture() const
Definition FUEntry.cc:117

References HDB::HDBManager::fuByEntryID(), HDB::FUEntry::hasArchitecture(), HDB::FUEntry::hasImplementation(), HDBBrowserWindow::isFUArchitectureSelected(), HDBBrowserWindow::isFUEntrySelected(), and HDBBrowserWindow::selectedFUEntry().

Here is the call graph for this function:

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