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

#include <AddFUArchFromADFCmd.hh>

Inheritance diagram for AddFUArchFromADFCmd:
Inheritance graph
Collaboration diagram for AddFUArchFromADFCmd:
Collaboration graph

Public Member Functions

 AddFUArchFromADFCmd ()
 
virtual ~AddFUArchFromADFCmd ()
 
virtual bool Do ()
 
virtual int id () const
 
virtual AddFUArchFromADFCmdcreate () const
 
virtual std::string icon () const
 
virtual bool isEnabled ()
 
 AddFUArchFromADFCmd ()
 
virtual ~AddFUArchFromADFCmd ()
 
virtual bool Do ()
 
virtual int id () const
 
virtual AddFUArchFromADFCmdcreate () 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 new FU architectures to HDB from an ADF file.

Definition at line 41 of file AddFUArchFromADFCmd.hh.

Constructor & Destructor Documentation

◆ AddFUArchFromADFCmd() [1/2]

AddFUArchFromADFCmd::AddFUArchFromADFCmd ( )

The Constructor.

Definition at line 55 of file AddFUArchFromADFCmd.cc.

Referenced by create().

◆ ~AddFUArchFromADFCmd() [1/2]

AddFUArchFromADFCmd::~AddFUArchFromADFCmd ( )
virtual

The Destructor.

Definition at line 63 of file AddFUArchFromADFCmd.cc.

63  {
64 }

◆ AddFUArchFromADFCmd() [2/2]

AddFUArchFromADFCmd::AddFUArchFromADFCmd ( )

◆ ~AddFUArchFromADFCmd() [2/2]

virtual AddFUArchFromADFCmd::~AddFUArchFromADFCmd ( )
virtual

Member Function Documentation

◆ create() [1/2]

AddFUArchFromADFCmd * AddFUArchFromADFCmd::create ( ) const
virtual

Creates a new instance of this command.

Returns
Newly created instance of this command.

Implements GUICommand.

Definition at line 193 of file AddFUArchFromADFCmd.cc.

193  {
194  return new AddFUArchFromADFCmd();
195 }

References AddFUArchFromADFCmd().

Here is the call graph for this function:

◆ create() [2/2]

virtual AddFUArchFromADFCmd* AddFUArchFromADFCmd::create ( ) const
virtual

Creates a new GUICommand instance.

Returns
New GUICommand instance.

Implements GUICommand.

◆ Do() [1/2]

bool AddFUArchFromADFCmd::Do ( )
virtual

Executes the command.

Returns
True, if the command was succesfully executed.

Implements GUICommand.

Definition at line 72 of file AddFUArchFromADFCmd.cc.

72  {
73  HDB::HDBManager* manager = wxGetApp().mainFrame().hdbManager();
74 
75  if (manager == NULL) {
76  return false;
77  }
78 
79  wxString wildcard = _T("Architecture Definition Files (*.adf)|*.adf");
80  wildcard.Append(_T("|All files|*.*"));
81 
82  wxFileDialog dialog(
83  parentWindow(), _T("Choose a file."), _T(""), _T(""),
84  wildcard, wxOPEN);
85 
86  if (dialog.ShowModal() == wxID_CANCEL) {
87  return false;
88  }
89 
90  wxString fileName = dialog.GetPath();
91 
92  ADFSerializer reader;
93  reader.setSourceFile(WxConversion::toString(fileName));
95 
96  try {
97  machine = reader.readMachine();
98  } catch (Exception& e) {
99  wxString message = _T("Error opening ");
100  message.Append(fileName);
101  message.Append(_T(":\n\n"));
102  message.Append(WxConversion::toWxString(e.errorMessage()));
103  ErrorDialog dialog(parentWindow(), message);
104  dialog.ShowModal();
105  return false;
106  }
107 
110 
111  if (nav.count() == 0) {
112  wxString message = _T("The file ");
113  message.Append(fileName);
114  message.Append(_T(" doesn't contain any function units."));
115  ErrorDialog dialog(parentWindow(), message);
116  dialog.ShowModal();
117  delete machine;
118  return false;
119  }
120 
121  wxString fus[1000];
122 
123  for (int i = 0; i < nav.count(); i++) {
124  fus[i] = WxConversion::toWxString(nav.item(i)->name());
125  }
126 
127  wxSingleChoiceDialog choicer(
128  parentWindow(), _T("Choose Function Unit"), _T("Choose Function Unit"),
129  nav.count(), fus);
130 
131  if (choicer.ShowModal() != wxID_OK) {
132  delete machine;
133  return false;
134  }
135 
136 
137  TTAMachine::FunctionUnit* fu = nav.item(choicer.GetSelection());
138  fu->unsetMachine();
139  delete machine;
140 
141  HDB::FUArchitecture fuArch(fu);
142 
143  FUArchitectureDialog paramDialog(parentWindow(), -1 , fuArch);
144 
145  if (paramDialog.ShowModal() != wxID_OK) {
146  return false;
147  }
148 
149  int id = -1;
150  try {
151  id = manager->addFUArchitecture(fuArch);
152  } catch (Exception& e) {
153  wxString message = _T("Erroneous function unit architecture:\n\n");
154  message.Append(WxConversion::toWxString(e.errorMessage()));
155  ErrorDialog dialog(parentWindow(), message);
156  dialog.ShowModal();
157  return false;
158  }
159 
160  wxGetApp().mainFrame().update();
161  wxGetApp().mainFrame().browser()->selectFUArchitecture(id);
162 
163  return true;
164 }

References HDB::HDBManager::addFUArchitecture(), TTAMachine::Machine::Navigator< ComponentType >::count(), Exception::errorMessage(), TTAMachine::Machine::functionUnitNavigator(), TTAMachine::Machine::Navigator< ComponentType >::item(), machine, GUICommand::parentWindow(), ADFSerializer::readMachine(), XMLSerializer::setSourceFile(), WxConversion::toString(), WxConversion::toWxString(), and TTAMachine::FunctionUnit::unsetMachine().

Here is the call graph for this function:

◆ Do() [2/2]

virtual bool AddFUArchFromADFCmd::Do ( )
virtual

Executes the command.

Returns
True, if the command was succesfully executed, false otherwise.

Implements GUICommand.

◆ icon() [1/2]

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

Returns name of the command icon file.

Returns
Command icon file name.

Implements GUICommand.

Definition at line 172 of file AddFUArchFromADFCmd.cc.

172  {
173  return "";
174 }

◆ icon() [2/2]

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

Returns name of the command icon file.

Returns
Name of the command icon file.

Implements GUICommand.

◆ id() [1/2]

virtual int AddFUArchFromADFCmd::id ( ) const
virtual

Returns the ID of the command.

Returns
The ID of the command.

Implements GUICommand.

◆ id() [2/2]

int AddFUArchFromADFCmd::id ( ) const
virtual

Returns the command id.

Returns
Command identifier.

Implements GUICommand.

Definition at line 182 of file AddFUArchFromADFCmd.cc.

182  {
184 }

References HDBEditorConstants::COMMAND_ADD_FU_FROM_ADF.

◆ isEnabled() [1/2]

virtual bool AddFUArchFromADFCmd::isEnabled ( )
virtual

Returns true if the command is executable, false otherwise.

Returns
True, if the command is executable, false otherwise.

Implements GUICommand.

◆ isEnabled() [2/2]

bool AddFUArchFromADFCmd::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 204 of file AddFUArchFromADFCmd.cc.

204  {
205  HDB::HDBManager* manager = wxGetApp().mainFrame().hdbManager();
206 
207  if (manager == NULL) {
208  return false;
209  }
210 
211  return true;
212 }

The documentation for this class was generated from the following files:
HDB::FUArchitecture
Definition: FUArchitecture.hh:55
WxConversion::toWxString
static wxString toWxString(const std::string &source)
XMLSerializer::setSourceFile
void setSourceFile(const std::string &fileName)
Definition: XMLSerializer.cc:115
machine
TTAMachine::Machine * machine
the architecture definition of the estimated processor
Definition: EstimatorCmdLineUI.cc:59
HDB::HDBManager::addFUArchitecture
RowID addFUArchitecture(const FUArchitecture &architecture) const
Definition: HDBManager.cc:717
HDBEditorConstants::COMMAND_NAME_ADD_FU_FROM_ADF
static const std::string COMMAND_NAME_ADD_FU_FROM_ADF
Name of the add fu architecture from adf command.
Definition: HDBEditorConstants.hh:88
TTAMachine::FunctionUnit::unsetMachine
virtual void unsetMachine()
Definition: FunctionUnit.cc:648
TTAMachine::Machine::Navigator::count
int count() const
TTAMachine::FunctionUnit
Definition: FunctionUnit.hh:55
AddFUArchFromADFCmd::AddFUArchFromADFCmd
AddFUArchFromADFCmd()
Definition: AddFUArchFromADFCmd.cc:55
ErrorDialog
Definition: ErrorDialog.hh:42
ADFSerializer
Definition: ADFSerializer.hh:49
TTAMachine::Machine::functionUnitNavigator
virtual FunctionUnitNavigator functionUnitNavigator() const
Definition: Machine.cc:380
HDB::HDBManager
Definition: HDBManager.hh:82
Exception
Definition: Exception.hh:54
Exception::errorMessage
std::string errorMessage() const
Definition: Exception.cc:123
FUArchitectureDialog
Definition: FUArchitectureDialog.hh:46
GUICommand::GUICommand
GUICommand(std::string name, wxWindow *parent)
Definition: GUICommand.cc:42
HDBEditorConstants::COMMAND_ADD_FU_FROM_ADF
@ COMMAND_ADD_FU_FROM_ADF
Definition: HDBEditorConstants.hh:47
ADFSerializer::readMachine
TTAMachine::Machine * readMachine()
Definition: ADFSerializer.cc:275
TTAMachine::Machine::Navigator::item
ComponentType * item(int index) const
WxConversion::toString
static std::string toString(const wxString &source)
TTAMachine::Machine::Navigator
Definition: Machine.hh:186
GUICommand::parentWindow
wxWindow * parentWindow() const
Definition: GUICommand.cc:75
TTAMachine::Machine
Definition: Machine.hh:73