OpenASIP 2.2
Loading...
Searching...
No Matches
Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
CallExplorerPluginWindow Class Reference

#include <CallExplorerPlugin.hh>

Inheritance diagram for CallExplorerPluginWindow:
Inheritance graph
Collaboration diagram for CallExplorerPluginWindow:
Collaboration graph

Public Member Functions

 CallExplorerPluginWindow (wxWindow *parent, TTAMachine::Machine &machine, Model &model)
 
virtual ~CallExplorerPluginWindow ()
 

Private Types

enum  {
  ID_TEXT = 10000 , ID_PLUGIN_CHOOSER , ID_DESCRIPTION_FIELD , ID_PARAM_LIST ,
  ID_EDIT , ID_RUN
}
 

Private Member Functions

virtual bool TransferDataToWindow ()
 
void onClose (wxCommandEvent &event)
 
void onEdit (wxCommandEvent &)
 
void onRun (wxCommandEvent &event)
 
void onSelectPlugin (wxCommandEvent &event)
 
void onParamActivate (wxListEvent &event)
 
void onParamSelect (wxListEvent &event)
 
void onParamDeSelect (wxListEvent &event)
 
void doEdit ()
 
void updateParameterList ()
 
void setTexts ()
 
ExplorerPluginParameter getParam (int paramNum)
 
wxSizer * createContents (wxWindow *parent, bool call_fit, bool set_sizer)
 

Private Attributes

TTAMachine::Machinemachine_
 Machine that is being modified.
 
Modelmodel_
 The model.
 
wxComboBox * pluginNames_
 Plugin names combo box.
 
wxTextCtrl * pluginDescription_
 description text field
 
wxListCtrl * parameterList_
 Parameter list;.
 
wxButton * editButton
 Edit button.
 
wxButton * runButton
 Run button.
 
int selectedParam_
 Selected parameter, or -1.
 
DesignSpaceExplorer explorer_
 
std::vector< DesignSpaceExplorerPlugin * > plugins_
 
DesignSpaceExplorerPluginselectedPlugin_
 

Detailed Description

Explorer plugin call window.

Definition at line 52 of file CallExplorerPlugin.hh.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
private
Enumerator
ID_TEXT 
ID_PLUGIN_CHOOSER 
ID_DESCRIPTION_FIELD 
ID_PARAM_LIST 
ID_EDIT 
ID_RUN 

Definition at line 98 of file CallExplorerPlugin.hh.

Constructor & Destructor Documentation

◆ CallExplorerPluginWindow()

CallExplorerPluginWindow::CallExplorerPluginWindow ( wxWindow *  parent,
TTAMachine::Machine machine,
Model model 
)

The Constructor.

Parameters
parentParent window of the dialog.
addressSpaceThe address space to be modified with the dialog.

Definition at line 81 of file CallExplorerPlugin.cc.

84 :
85 wxDialog(parent, -1, _T(""), wxDefaultPosition), machine_(machine),
86 model_(model),
89
90 createContents(this, true, true);
91
93 dynamic_cast<wxComboBox*>(FindWindow(ID_PLUGIN_CHOOSER));
94
96 dynamic_cast<wxTextCtrl*>(FindWindow(ID_DESCRIPTION_FIELD));
97
99 dynamic_cast<wxListCtrl*>(FindWindow(ID_PARAM_LIST));
100
101 editButton =
102 dynamic_cast<wxButton*>(FindWindow(ID_EDIT));
103
104 runButton =
105 dynamic_cast<wxButton*>(FindWindow(ID_RUN));
106
107 // Get explorer plugin names.
108 std::vector<DesignSpaceExplorerPlugin*> plugins = explorer_.getPlugins();
109 std::set<string> addedPlugins;
110
111 for (std::size_t i = 0; i < plugins.size(); i++) {
112 DesignSpaceExplorerPlugin *plugin = plugins[i];
113
114 if (plugin->producesArchitecture() &&
115 !plugin->requiresHDB() &&
116 !plugin->requiresSimulationData() &&
117 addedPlugins.find(plugin->name()) == addedPlugins.end()) {
118
119 plugins_.push_back(plugin);
120 addedPlugins.insert(plugin->name());
121 }
122
123 }
124
125 // set widget texts
126 setTexts();
127
129}
TTAMachine::Machine * machine
the architecture definition of the estimated processor
wxSizer * createContents(wxWindow *parent, bool call_fit, bool set_sizer)
DesignSpaceExplorer explorer_
wxComboBox * pluginNames_
Plugin names combo box.
wxButton * editButton
Edit button.
wxTextCtrl * pluginDescription_
description text field
DesignSpaceExplorerPlugin * selectedPlugin_
std::vector< DesignSpaceExplorerPlugin * > plugins_
TTAMachine::Machine & machine_
Machine that is being modified.
int selectedParam_
Selected parameter, or -1.
wxListCtrl * parameterList_
Parameter list;.
wxButton * runButton
Run button.
virtual bool requiresHDB() const =0
virtual bool requiresSimulationData() const =0
virtual std::string name() const
virtual bool producesArchitecture() const =0
std::vector< DesignSpaceExplorerPlugin * > getPlugins()

References DesignSpaceExplorerPlugin::name(), DesignSpaceExplorerPlugin::producesArchitecture(), DesignSpaceExplorerPlugin::requiresHDB(), and DesignSpaceExplorerPlugin::requiresSimulationData().

Here is the call graph for this function:

◆ ~CallExplorerPluginWindow()

CallExplorerPluginWindow::~CallExplorerPluginWindow ( )
virtual

The Destructor.

Definition at line 135 of file CallExplorerPlugin.cc.

135 {
136}

Member Function Documentation

◆ createContents()

wxSizer * CallExplorerPluginWindow::createContents ( wxWindow *  parent,
bool  call_fit,
bool  set_sizer 
)
private

Creates the dialog window contents.

This method was generated with wxDesigner, thus the ugly code and too long lines.

Returns
Main sizer of the created contents.
Parameters
parentThe dialog window.
call_fitIf true, fits the contents inside the dialog.
set_sizerIf true, sets the main sizer as dialog contents.

Definition at line 380 of file CallExplorerPlugin.cc.

383 {
384
385 wxBoxSizer *item0 = new wxBoxSizer( wxVERTICAL );
386
387 wxFlexGridSizer *item1 = new wxFlexGridSizer( 2, 0, 0 );
388 item1->AddGrowableCol( 1 );
389
390 wxStaticText *item2 = new wxStaticText( parent, ID_TEXT, wxT("Explorer Plugin:"), wxDefaultPosition, wxDefaultSize, 0 );
391 item1->Add( item2, 0, wxFIXED_MINSIZE|wxALL, 5 );
392
393 wxString *strs3 = (wxString*) NULL;
394 wxComboBox *item3 = new wxComboBox( parent, ID_PLUGIN_CHOOSER, wxT(""), wxDefaultPosition, wxDefaultSize, 0, strs3, wxCB_DROPDOWN );
395 item1->Add( item3, 0, wxGROW|wxALL, 5 );
396
397 wxStaticText *item4 = new wxStaticText( parent, ID_TEXT, wxT("Plugin Description:"), wxDefaultPosition, wxDefaultSize, 0 );
398 item1->Add( item4, 0, wxFIXED_MINSIZE|wxALL, 5 );
399
400 wxTextCtrl *item5 = new wxTextCtrl( parent, ID_DESCRIPTION_FIELD, wxT(""), wxDefaultPosition, wxSize(240,150), wxTE_MULTILINE|wxTE_READONLY );
401 item1->Add( item5, 0, wxGROW|wxALL, 5 );
402
403 item0->Add( item1, 0, wxGROW|wxALL, 5 );
404
405 wxStaticText *item6 = new wxStaticText( parent, ID_TEXT, wxT("Plugin Parameters:"), wxDefaultPosition, wxDefaultSize, 0 );
406 item0->Add( item6, 0, wxALL, 5 );
407
408 wxListCtrl *item7 = new wxListCtrl( parent, ID_PARAM_LIST, wxDefaultPosition, wxSize(400,200), wxLC_REPORT|wxSUNKEN_BORDER );
409 item0->Add( item7, 0, wxALIGN_CENTER|wxALL, 5 );
410
411 wxGridSizer *item8 = new wxGridSizer( 3, 0, 0 );
412
413 item0->Add( item8, 0, wxGROW, 5 );
414
415 wxGridSizer *item9 = new wxGridSizer( 3, 0, 0 );
416
417 wxButton *item10 = new wxButton( parent, ID_EDIT, wxT("&Edit Parameter..."), wxDefaultPosition, wxDefaultSize, 0 );
418 item9->Add( item10, 0, wxALL, 5 );
419
420 wxButton *item11 = new wxButton( parent, ID_RUN, wxT("&Run Plugin"), wxDefaultPosition, wxDefaultSize, 0 );
421 item9->Add( item11, 0, wxALIGN_RIGHT|wxALL, 5 );
422
423 wxBoxSizer *item12 = new wxBoxSizer( wxHORIZONTAL );
424
425 wxButton *item13 = new wxButton( parent, wxID_CLOSE, wxT("&Close"), wxDefaultPosition, wxDefaultSize, 0 );
426 item12->Add( item13, 0, wxALIGN_CENTER|wxALL, 5 );
427
428 item9->Add( item12, 0, wxALL, 5 );
429
430 item0->Add( item9, 0, wxGROW, 5 );
431
432 if (set_sizer)
433 {
434 parent->SetSizer( item0 );
435 if (call_fit)
436 item0->SetSizeHints( parent );
437 }
438
439 return item0;
440}

References ID_DESCRIPTION_FIELD, ID_EDIT, ID_PARAM_LIST, ID_PLUGIN_CHOOSER, ID_RUN, and ID_TEXT.

◆ doEdit()

void CallExplorerPluginWindow::doEdit ( )
private

Starts parameter editor

Definition at line 310 of file CallExplorerPlugin.cc.

310 {
311 if (selectedParam_ == -1) {
312 return;
313 }
314
316 EditParameterDialog diag(this, &param);
317 diag.ShowModal();
318 selectedPlugin_->giveParameter(param.name(), param.value());
320}
ExplorerPluginParameter getParam(int paramNum)
virtual void giveParameter(const std::string &name, const std::string &value)

References getParam(), DesignSpaceExplorerPlugin::giveParameter(), ExplorerPluginParameter::name(), selectedParam_, selectedPlugin_, updateParameterList(), and ExplorerPluginParameter::value().

Referenced by onEdit(), and onParamActivate().

Here is the call graph for this function:

◆ getParam()

ExplorerPluginParameter CallExplorerPluginWindow::getParam ( int  paramNum)
private

Gets param from param index

Definition at line 354 of file CallExplorerPlugin.cc.

354 {
356 DesignSpaceExplorerPlugin::ParameterMap::iterator it = params.begin();
357
358 for (int i =0; it != params.end(); ++it, ++i) {
359 if (i == paramNum) {
360 return it->second;
361 }
362 }
363
364 return ExplorerPluginParameter("", INT, false, "");
365}
#define INT(OPERAND)
Definition OSAL.hh:312
std::map< std::string, ExplorerPluginParameter > ParameterMap

References INT, DesignSpaceExplorerPlugin::parameters(), and selectedPlugin_.

Referenced by doEdit().

Here is the call graph for this function:

◆ onClose()

void CallExplorerPluginWindow::onClose ( wxCommandEvent &  event)
private

Validates input in the controls, and updates the AddressSpace.

Definition at line 189 of file CallExplorerPlugin.cc.

189 {
190 EndModal(wxID_CANCEL);
191}

◆ onEdit()

void CallExplorerPluginWindow::onEdit ( wxCommandEvent &  )
private

Editing selected parameter

Definition at line 197 of file CallExplorerPlugin.cc.

197 {
198 doEdit();
199}

References doEdit().

Here is the call graph for this function:

◆ onParamActivate()

void CallExplorerPluginWindow::onParamActivate ( wxListEvent &  event)
private

Parameter was doubleclicked

Definition at line 258 of file CallExplorerPlugin.cc.

258 {
259 selectedParam_ = event.GetIndex();
260 doEdit();
261}

References doEdit(), and selectedParam_.

Here is the call graph for this function:

◆ onParamDeSelect()

void CallExplorerPluginWindow::onParamDeSelect ( wxListEvent &  event)
private

Parameter was deselected

Definition at line 275 of file CallExplorerPlugin.cc.

275 {
276 selectedParam_ = -1;
277}

References selectedParam_.

◆ onParamSelect()

void CallExplorerPluginWindow::onParamSelect ( wxListEvent &  event)
private

Parameter was selected

Definition at line 267 of file CallExplorerPlugin.cc.

267 {
268 selectedParam_ = event.GetIndex();
269}

References selectedParam_.

◆ onRun()

void CallExplorerPluginWindow::onRun ( wxCommandEvent &  event)
private

Runs the plugin

Definition at line 206 of file CallExplorerPlugin.cc.

206 {
207
208 // no plugin selected?
209 if (selectedPlugin_ == 0) {
210 return;
211 }
212
213 // open up a temporary dsdb
214 const string dsdbFile = "tmp.dsdb";
216 DSDBManager* dsdb = DSDBManager::createNew(dsdbFile);
217 RowID archID = dsdb->addArchitecture(machine_);
218
219 // no implementation?
221 RowID confID = dsdb->addConfiguration(confIn);
222
223 // run the plugin
224 try {
225 selectedPlugin_->setDSDB(*dsdb);
226 std::vector<RowID> result = selectedPlugin_->explore(confID, 0);
227
228 // store the new machine
230 *dsdb->architecture(confID+result.size());
232 } catch (KeyNotFound& e) {
233 // no new adf created by the plugin. just exit
236 diag.ShowModal();
238 EndModal(wxID_CANCEL);
239 return;
240 } catch (Exception& e) {
241 // error in parameters
244 diag.ShowModal();
246 return;
247 }
248
250 EndModal(wxID_OK);
251}
int RowID
Type definition of row ID in relational databases.
Definition DBTypes.hh:37
#define ILLEGAL_ROW_ID
RowID addArchitecture(const TTAMachine::Machine &mom)
TTAMachine::Machine * architecture(RowID id) const
static DSDBManager * createNew(const std::string &file)
RowID addConfiguration(const MachineConfiguration &conf)
virtual std::vector< RowID > explore(const RowID &startPointConfigurationID, const unsigned int &maxIter=0)
virtual void setDSDB(DSDBManager &dsdb)
std::string errorMessage() const
Definition Exception.cc:123
static bool removeFileOrDirectory(const std::string &path)
TTAMachine::Machine * getMachine()
Definition Model.cc:88
virtual void copyFromMachine(Machine &machine)
Definition Machine.cc:884
static wxString toWxString(const std::string &source)

References DSDBManager::addArchitecture(), DSDBManager::addConfiguration(), DSDBManager::architecture(), TTAMachine::Machine::copyFromMachine(), DSDBManager::createNew(), Exception::errorMessage(), DesignSpaceExplorerPlugin::explore(), Model::getMachine(), ILLEGAL_ROW_ID, machine, machine_, model_, FileSystem::removeFileOrDirectory(), selectedPlugin_, DesignSpaceExplorer::setDSDB(), and WxConversion::toWxString().

Here is the call graph for this function:

◆ onSelectPlugin()

void CallExplorerPluginWindow::onSelectPlugin ( wxCommandEvent &  event)
private

A plugin was selected

Definition at line 284 of file CallExplorerPlugin.cc.

284 {
285
286 string pluginName =
288
289 // get current plugin
290 for (size_t i = 0; i < plugins_.size(); i++) {
291 if (plugins_.at(i)->name() == pluginName) {
293 break;
294 }
295 }
296
297 // set description field
298 pluginDescription_->Clear();
301
303}
virtual std::string description() const
static std::string toString(const wxString &source)

References DesignSpaceExplorerPlugin::description(), pluginDescription_, pluginNames_, plugins_, selectedPlugin_, WxConversion::toString(), WxConversion::toWxString(), and updateParameterList().

Here is the call graph for this function:

◆ setTexts()

void CallExplorerPluginWindow::setTexts ( )
private

Sets texts for widgets.

Definition at line 143 of file CallExplorerPlugin.cc.

143 {
145
146 // Dialog title
147 format fmt = prodeTexts->text(
149 SetTitle(WxConversion::toWxString(fmt.str()));
150
151 // Get explorer plugin names into combo box
152 for (size_t i = 0; i < plugins_.size(); ++i) {
153 wxString pluginName = WxConversion::toWxString(plugins_.at(i)->name());
154 pluginNames_->Append(pluginName);
155 }
156
157 // Set parameter list column titles
158 fmt = prodeTexts->text(ProDeTextGenerator::TXT_COLUMN_NAME);
159 parameterList_->InsertColumn(0, WxConversion::toWxString(fmt.str()),
160 wxLIST_FORMAT_CENTER, 160);
161 //fmt = prodeTexts->text(ProDeTextGenerator::TXT_COLUMN_COMPULSORY);
162 //parameterList_->InsertColumn(1, WxConversion::toWxString(fmt.str()),
163 // wxLIST_FORMAT_LEFT, 100);
164 fmt = prodeTexts->text(ProDeTextGenerator::TXT_COLUMN_TYPE);
165 parameterList_->InsertColumn(2, WxConversion::toWxString(fmt.str()),
166 wxLIST_FORMAT_LEFT, 100);
168 parameterList_->InsertColumn(3, WxConversion::toWxString(fmt.str()),
169 wxLIST_FORMAT_LEFT, 160);
170}
static ProDeTextGenerator * instance()
@ TXT_COLUMN_TYPE
Label for type column in a list.
@ TXT_CALL_EXPLORER_PLUGIN_TITLE
Call Explorer plugin title.
@ TXT_COLUMN_NAME
Label for name column in a list.
@ TXT_COLUMN_VALUE
Label for value column in a list.
virtual boost::format text(int textId)

References ProDeTextGenerator::instance(), parameterList_, pluginNames_, plugins_, Texts::TextGenerator::text(), WxConversion::toWxString(), ProDeTextGenerator::TXT_CALL_EXPLORER_PLUGIN_TITLE, ProDeTextGenerator::TXT_COLUMN_NAME, ProDeTextGenerator::TXT_COLUMN_TYPE, and ProDeTextGenerator::TXT_COLUMN_VALUE.

Here is the call graph for this function:

◆ TransferDataToWindow()

bool CallExplorerPluginWindow::TransferDataToWindow ( )
privatevirtual

Transfers data from the AddressSpace object to the dialog widgets.

Returns
false, if an error occured in the transfer, true otherwise.

Definition at line 179 of file CallExplorerPlugin.cc.

179 {
180
181 return wxWindow::TransferDataToWindow();
182}

◆ updateParameterList()

void CallExplorerPluginWindow::updateParameterList ( )
private

Updates parameter list

Definition at line 327 of file CallExplorerPlugin.cc.

327 {
328
329 parameterList_->DeleteAllItems();
330
332 DesignSpaceExplorerPlugin::ParameterMap::iterator it = params.begin();
333
334 for (int i =0; it != params.end(); ++it, ++i) {
335 ExplorerPluginParameter parameter = it->second;
336
337 string name = parameter.name();
338 string type = parameter.typeAsString();
339 string value = parameter.value();
340 //string compulsory = parameter.isCompulsory() ? "x" : "";
341
342 parameterList_->InsertItem(i, WxConversion::toWxString(name), 0);
343 //parameterList_->SetItem(i, 1, WxConversion::toWxString(compulsory));
344 parameterList_->SetItem(i, 1, WxConversion::toWxString(type));
345 parameterList_->SetItem(i, 2, WxConversion::toWxString(value));
346 }
347}

References ExplorerPluginParameter::name(), parameterList_, DesignSpaceExplorerPlugin::parameters(), selectedPlugin_, WxConversion::toWxString(), ExplorerPluginParameter::typeAsString(), and ExplorerPluginParameter::value().

Referenced by doEdit(), and onSelectPlugin().

Here is the call graph for this function:

Member Data Documentation

◆ editButton

wxButton* CallExplorerPluginWindow::editButton
private

Edit button.

Definition at line 91 of file CallExplorerPlugin.hh.

◆ explorer_

DesignSpaceExplorer CallExplorerPluginWindow::explorer_
private

Definition at line 107 of file CallExplorerPlugin.hh.

◆ machine_

TTAMachine::Machine& CallExplorerPluginWindow::machine_
private

Machine that is being modified.

Definition at line 80 of file CallExplorerPlugin.hh.

Referenced by onRun().

◆ model_

Model& CallExplorerPluginWindow::model_
private

The model.

Definition at line 82 of file CallExplorerPlugin.hh.

Referenced by onRun().

◆ parameterList_

wxListCtrl* CallExplorerPluginWindow::parameterList_
private

Parameter list;.

Definition at line 89 of file CallExplorerPlugin.hh.

Referenced by setTexts(), and updateParameterList().

◆ pluginDescription_

wxTextCtrl* CallExplorerPluginWindow::pluginDescription_
private

description text field

Definition at line 87 of file CallExplorerPlugin.hh.

Referenced by onSelectPlugin().

◆ pluginNames_

wxComboBox* CallExplorerPluginWindow::pluginNames_
private

Plugin names combo box.

Definition at line 85 of file CallExplorerPlugin.hh.

Referenced by onSelectPlugin(), and setTexts().

◆ plugins_

std::vector<DesignSpaceExplorerPlugin*> CallExplorerPluginWindow::plugins_
private

Definition at line 108 of file CallExplorerPlugin.hh.

Referenced by onSelectPlugin(), and setTexts().

◆ runButton

wxButton* CallExplorerPluginWindow::runButton
private

Run button.

Definition at line 93 of file CallExplorerPlugin.hh.

◆ selectedParam_

int CallExplorerPluginWindow::selectedParam_
private

Selected parameter, or -1.

Definition at line 95 of file CallExplorerPlugin.hh.

Referenced by doEdit(), onParamActivate(), onParamDeSelect(), and onParamSelect().

◆ selectedPlugin_

DesignSpaceExplorerPlugin* CallExplorerPluginWindow::selectedPlugin_
private

Definition at line 109 of file CallExplorerPlugin.hh.

Referenced by doEdit(), getParam(), onRun(), onSelectPlugin(), and updateParameterList().


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