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

#include <CostFunctionPluginDialog.hh>

Inheritance diagram for CostFunctionPluginDialog:
Inheritance graph
Collaboration diagram for CostFunctionPluginDialog:
Collaboration graph

Public Member Functions

 CostFunctionPluginDialog (wxWindow *parent, wxWindowID id, HDB::HDBManager &hdb, int pluginID)
 
virtual ~CostFunctionPluginDialog ()
 

Private Types

enum  {
  ID_LIST = 10000 , ID_NAME , ID_PATH , ID_TYPE ,
  ID_BROWSE , ID_DESCRIPTION , ID_ADD , ID_MODIFY ,
  ID_DELETE , ID_TEXT , ID_LINE
}
 Widget ids. More...
 

Private Member Functions

virtual bool TransferDataToWindow ()
 
void onBrowse (wxCommandEvent &event)
 
void onAdd (wxCommandEvent &event)
 
void onModify (wxCommandEvent &event)
 
void onDelete (wxCommandEvent &event)
 
void onOK (wxCommandEvent &event)
 
void onDataSelection (wxListEvent &event)
 
int selectedData ()
 
wxSizer * createContents (wxWindow *parent, bool call_fit, bool set_sizer)
 

Private Attributes

wxListCtrl * list_
 Pointer to the data list widget.
 
HDB::HDBManagerhdb_
 HDB containing the plugin.
 
int id_
 Plugin id in the HDB.
 
wxString name_
 Plugin name.
 
wxString path_
 Plugin file path.
 
wxString description_
 Plugin description string.
 
wxChoice * typeChoice_
 Pointer to the type choice widget.
 

Static Private Attributes

static const wxString TYPE_COST_FU
 FU Cost estimator string for the type choicer widget.
 
static const wxString TYPE_COST_RF
 RF Cost estimator string for the type choicer widget.
 
static const wxString TYPE_COST_DECOMP
 Decompressor cost estimator string for the type choicer widget.
 
static const wxString TYPE_COST_ICDEC
 IC&decoder Cost estimator string for the type choicer widget.
 

Detailed Description

Dialog for modifying CostFunctionPlugins.

Definition at line 46 of file CostFunctionPluginDialog.hh.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
private

Constructor & Destructor Documentation

◆ CostFunctionPluginDialog()

CostFunctionPluginDialog::CostFunctionPluginDialog ( wxWindow *  parent,
wxWindowID  id,
HDB::HDBManager hdb,
int  pluginID 
)

The Constructor.

Parameters
parentParent window of the dialog.
idDialog window ID.
hdbHDB containing the cost function plugin.
pluginIDRow ID of the plugin in the HDB.

Definition at line 79 of file CostFunctionPluginDialog.cc.

80 :
81 wxDialog(parent, id, _T("Cost Function Plugin")),
82 hdb_(hdb), id_(pluginID) {
83
84 createContents(this, true, true);
85
86 list_ = dynamic_cast<wxListCtrl*>(FindWindow(ID_LIST));
87 typeChoice_ = dynamic_cast<wxChoice*>(FindWindow(ID_TYPE));
88
89 list_->InsertColumn(0, _T("Type"), wxLIST_FORMAT_LEFT, 50);
90 list_->InsertColumn(1, _T("ID"), wxLIST_FORMAT_LEFT, 50);
91 list_->InsertColumn(2, _T("Name"), wxLIST_FORMAT_LEFT, 200);
92 list_->InsertColumn(3, _T("Data"), wxLIST_FORMAT_RIGHT, 200);
93
98
99 FindWindow(ID_NAME)->SetValidator(wxGenericValidator(&name_));
100 FindWindow(ID_PATH)->SetValidator(wxGenericValidator(&path_));
102 ID_DESCRIPTION)->SetValidator(wxGenericValidator(&description_));
103
105
109
110 if (plugin->type() == CostFunctionPlugin::COST_FU) {
111 typeChoice_->SetStringSelection(TYPE_COST_FU);
112 } else if (plugin->type() == CostFunctionPlugin::COST_RF) {
113 typeChoice_->SetStringSelection(TYPE_COST_RF);
114 } else if (plugin->type() == CostFunctionPlugin::COST_DECOMP) {
115 typeChoice_->SetStringSelection(TYPE_COST_DECOMP);
116 } else if (plugin->type() == CostFunctionPlugin::COST_ICDEC) {
117 typeChoice_->SetStringSelection(TYPE_COST_ICDEC);
118 }
119 delete plugin;
120
121 FindWindow(ID_DELETE)->Disable();
122 FindWindow(ID_MODIFY)->Disable();
123}
wxSizer * createContents(wxWindow *parent, bool call_fit, bool set_sizer)
static const wxString TYPE_COST_DECOMP
Decompressor cost estimator string for the type choicer widget.
wxListCtrl * list_
Pointer to the data list widget.
wxChoice * typeChoice_
Pointer to the type choice widget.
static const wxString TYPE_COST_FU
FU Cost estimator string for the type choicer widget.
wxString path_
Plugin file path.
static const wxString TYPE_COST_RF
RF Cost estimator string for the type choicer widget.
static const wxString TYPE_COST_ICDEC
IC&decoder Cost estimator string for the type choicer widget.
HDB::HDBManager & hdb_
HDB containing the plugin.
wxString description_
Plugin description string.
@ COST_RF
register file cost estimator
@ COST_ICDEC
interconnection network & decoder cost estimator
@ COST_FU
function unit cost estimator
@ COST_DECOMP
decompressor cost estimator
CostFunctionPluginType type() const
std::string description() const
std::string pluginFilePath() const
CostFunctionPlugin * costFunctionPluginByID(RowID pluginID) const
static wxString toWxString(const std::string &source)

References HDB::CostFunctionPlugin::COST_DECOMP, HDB::CostFunctionPlugin::COST_FU, HDB::CostFunctionPlugin::COST_ICDEC, HDB::CostFunctionPlugin::COST_RF, HDB::CostFunctionPlugin::description(), HDB::CostFunctionPlugin::name(), HDB::CostFunctionPlugin::pluginFilePath(), WxConversion::toWxString(), and HDB::CostFunctionPlugin::type().

Here is the call graph for this function:

◆ ~CostFunctionPluginDialog()

CostFunctionPluginDialog::~CostFunctionPluginDialog ( )
virtual

y * The Destructor.

Definition at line 128 of file CostFunctionPluginDialog.cc.

128 {
129}

Member Function Documentation

◆ createContents()

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

Creates the dialog widgets.

Parameters
parentParent window of the dialog widgets.

Definition at line 302 of file CostFunctionPluginDialog.cc.

303 {
304
305 wxBoxSizer *item0 = new wxBoxSizer( wxVERTICAL );
306
307 wxFlexGridSizer *item1 = new wxFlexGridSizer( 3, 0, 0 );
308
309 wxStaticText *item2 = new wxStaticText( parent, ID_TEXT, wxT("Name:"), wxDefaultPosition, wxDefaultSize, 0 );
310 item1->Add( item2, 0, wxALIGN_RIGHT|wxALL, 5 );
311
312 wxTextCtrl *item3 = new wxTextCtrl( parent, ID_NAME, wxT(""), wxDefaultPosition, wxSize(300,-1), 0 );
313 item1->Add( item3, 0, wxALIGN_CENTER|wxALL, 5 );
314
315 item1->Add( 20, 20, 0, wxALIGN_CENTER|wxALL, 5 );
316
317 wxStaticText *item4 = new wxStaticText( parent, ID_TEXT, wxT("Plugin file path:"), wxDefaultPosition, wxDefaultSize, 0 );
318 item1->Add( item4, 0, wxALIGN_RIGHT|wxALL, 5 );
319
320 wxTextCtrl *item5 = new wxTextCtrl( parent, ID_PATH, wxT(""), wxDefaultPosition, wxSize(80,-1), 0 );
321 item1->Add( item5, 0, wxGROW|wxALL, 5 );
322
323 wxButton *item6 = new wxButton( parent, ID_BROWSE, wxT("Browse..."), wxDefaultPosition, wxDefaultSize, 0 );
324 item1->Add( item6, 0, wxALIGN_CENTER|wxALL, 5 );
325
326 wxStaticText *item7 = new wxStaticText( parent, ID_TEXT, wxT("Plugin type:"), wxDefaultPosition, wxDefaultSize, 0 );
327 item1->Add( item7, 0, wxALIGN_RIGHT|wxALL, 5 );
328
329 wxString *strs8 = (wxString*) NULL;
330 wxChoice *item8 = new wxChoice( parent, ID_TYPE, wxDefaultPosition, wxSize(100,-1), 0, strs8, 0 );
331 item1->Add( item8, 0, wxGROW|wxALL, 5 );
332
333 item1->Add( 20, 20, 0, wxALIGN_CENTER|wxALL, 5 );
334
335 wxStaticText *item9 = new wxStaticText( parent, ID_TEXT, wxT("Description:"), wxDefaultPosition, wxDefaultSize, 0 );
336 item1->Add( item9, 0, wxALIGN_RIGHT|wxALL, 5 );
337
338 wxTextCtrl *item10 = new wxTextCtrl( parent, ID_DESCRIPTION, wxT(""), wxDefaultPosition, wxSize(200,60), wxTE_MULTILINE );
339 item1->Add( item10, 0, wxGROW|wxALL, 5 );
340
341 item0->Add( item1, 0, wxGROW|wxALL, 5 );
342
343 wxStaticBox *item12 = new wxStaticBox( parent, -1, wxT("Plugin data:") );
344 wxStaticBoxSizer *item11 = new wxStaticBoxSizer( item12, wxVERTICAL );
345
346 wxListCtrl *item13 = new wxListCtrl( parent, ID_LIST, wxDefaultPosition, wxSize(500,300), wxLC_REPORT|wxSUNKEN_BORDER );
347 item11->Add( item13, 0, wxGROW|wxALL, 5 );
348
349 item0->Add( item11, 0, wxGROW|wxALL, 5 );
350
351 wxBoxSizer *item14 = new wxBoxSizer( wxHORIZONTAL );
352
353 wxButton *item15 = new wxButton( parent, ID_ADD, wxT("Add..."), wxDefaultPosition, wxDefaultSize, 0 );
354 item14->Add( item15, 0, wxALIGN_CENTER|wxALL, 5 );
355
356 wxButton *item16 = new wxButton( parent, ID_MODIFY, wxT("Modify..."), wxDefaultPosition, wxDefaultSize, 0 );
357 item14->Add( item16, 0, wxALIGN_CENTER|wxALL, 5 );
358
359 wxButton *item17 = new wxButton( parent, ID_DELETE, wxT("Delete"), wxDefaultPosition, wxDefaultSize, 0 );
360 item14->Add( item17, 0, wxALIGN_CENTER|wxALL, 5 );
361
362 item0->Add( item14, 0, wxALIGN_CENTER, 5 );
363
364 wxStaticLine *item18 = new wxStaticLine( parent, ID_LINE, wxDefaultPosition, wxSize(20,-1), wxLI_HORIZONTAL );
365 item0->Add( item18, 0, wxGROW|wxALL, 5 );
366
367 wxBoxSizer *item19 = new wxBoxSizer( wxHORIZONTAL );
368
369 wxButton *item20 = new wxButton( parent, wxID_CANCEL, wxT("&Cancel"), wxDefaultPosition, wxDefaultSize, 0 );
370 item19->Add( item20, 0, wxALIGN_CENTER|wxALL, 5 );
371
372 wxButton *item21 = new wxButton( parent, wxID_OK, wxT("&OK"), wxDefaultPosition, wxDefaultSize, 0 );
373 item19->Add( item21, 0, wxALL, 5 );
374
375 item0->Add( item19, 0, 0, 5 );
376
377 if (set_sizer)
378 {
379 parent->SetSizer( item0 );
380 if (call_fit)
381 item0->SetSizeHints( parent );
382 }
383
384 return item0;
385}

References ID_ADD, ID_BROWSE, ID_DELETE, ID_DESCRIPTION, ID_LINE, ID_LIST, ID_MODIFY, ID_NAME, ID_PATH, ID_TEXT, and ID_TYPE.

◆ onAdd()

void CostFunctionPluginDialog::onAdd ( wxCommandEvent &  event)
private

Event handler for the add button.

Definition at line 224 of file CostFunctionPluginDialog.cc.

224 {
225 TransferDataFromWindow();
226 CostEstimationDataDialog dialog(this, -1, hdb_, id_, -1);
227 dialog.ShowModal();
228 TransferDataFromWindow();
230
231}

References hdb_, id_, and TransferDataToWindow().

Here is the call graph for this function:

◆ onBrowse()

void CostFunctionPluginDialog::onBrowse ( wxCommandEvent &  event)
private

Event handler for the browse plugin file path button.

Definition at line 210 of file CostFunctionPluginDialog.cc.

210 {
211 wxFileDialog dialog(
212 this, _T("Choose a plugin file."), _T(""), _T(""),
213 _T("Plugin files (*.so)|*.so|All Files|*.*"),
214 wxOPEN | wxFILE_MUST_EXIST);
215 if (dialog.ShowModal() == wxID_OK) {
216 dynamic_cast<wxTextCtrl*>(
217 FindWindow(ID_PATH))->SetValue(dialog.GetPath());
218 }
219}

References ID_PATH.

◆ onDataSelection()

void CostFunctionPluginDialog::onDataSelection ( wxListEvent &  event)
private

Event handler for the plugin data list selection changes.

Updates the delete and modify button enabled/disabled states.

Definition at line 196 of file CostFunctionPluginDialog.cc.

196 {
197 if (selectedData() == -1) {
198 FindWindow(ID_DELETE)->Disable();
199 FindWindow(ID_MODIFY)->Disable();
200 } else {
201 FindWindow(ID_DELETE)->Enable();
202 FindWindow(ID_MODIFY)->Enable();
203 }
204}

References ID_DELETE, ID_MODIFY, and selectedData().

Here is the call graph for this function:

◆ onDelete()

void CostFunctionPluginDialog::onDelete ( wxCommandEvent &  event)
private

Event handler for the Delete button.

Definition at line 251 of file CostFunctionPluginDialog.cc.

251 {
252 TransferDataFromWindow();
253 int selected = selectedData();
254 if (selected >= 0) {
257 }
258}
virtual void removeCostEstimationData(RowID id) const

References hdb_, HDB::HDBManager::removeCostEstimationData(), selectedData(), and TransferDataToWindow().

Here is the call graph for this function:

◆ onModify()

void CostFunctionPluginDialog::onModify ( wxCommandEvent &  event)
private

Event handler for the modify button.

Definition at line 237 of file CostFunctionPluginDialog.cc.

237 {
238 TransferDataFromWindow();
239 int selected = selectedData();
240 if (selected >= 0) {
241 CostEstimationDataDialog dialog(this, -1, hdb_, id_, selected);
242 dialog.ShowModal();
244 }
245}

References hdb_, id_, selectedData(), and TransferDataToWindow().

Here is the call graph for this function:

◆ onOK()

void CostFunctionPluginDialog::onOK ( wxCommandEvent &  event)
private

Event handler for the Close button.

Definition at line 264 of file CostFunctionPluginDialog.cc.

264 {
265
266 TransferDataFromWindow();
267
268 if (name_.IsEmpty()) {
269 wxString message(_T("Plugin name not set."));
270 ErrorDialog dialog(this, message);
271 dialog.ShowModal();
272 return;
273 }
274
277
278 if (typeChoice_->GetStringSelection() == TYPE_COST_RF) {
280 } else if (typeChoice_->GetStringSelection() == TYPE_COST_DECOMP) {
282 } else if (typeChoice_->GetStringSelection() == TYPE_COST_ICDEC) {
284 } else {
285 assert(typeChoice_->GetStringSelection() == TYPE_COST_FU);
286 }
287
288 std::string description = WxConversion::toString(description_);
289 std::string name = WxConversion::toString(name_);
290 std::string path = WxConversion::toString(path_);
291 CostFunctionPlugin modified(-1, description, name, path, type);
293 EndModal(wxID_OK);
294}
#define assert(condition)
CostFunctionPluginType
all supported cost function plugin types
virtual void modifyCostFunctionPlugin(RowID id, const CostFunctionPlugin &plugin)
static std::string toString(const wxString &source)

References assert, HDB::CostFunctionPlugin::COST_DECOMP, HDB::CostFunctionPlugin::COST_FU, HDB::CostFunctionPlugin::COST_ICDEC, HDB::CostFunctionPlugin::COST_RF, description_, hdb_, id_, HDB::HDBManager::modifyCostFunctionPlugin(), name_, path_, WxConversion::toString(), TYPE_COST_DECOMP, TYPE_COST_FU, TYPE_COST_ICDEC, TYPE_COST_RF, and typeChoice_.

Here is the call graph for this function:

◆ selectedData()

int CostFunctionPluginDialog::selectedData ( )
private

Returns RowID of the cost estimation data selected in the list.

Returns -1 if no data is selected.

Returns
RowID of the selected cost estiamtion data.

Definition at line 180 of file CostFunctionPluginDialog.cc.

180 {
181 int item = list_->GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
182
183 if (item < 0) {
184 return -1;
185 }
186
187 return list_->GetItemData(item);
188}

References list_.

Referenced by onDataSelection(), onDelete(), and onModify().

◆ TransferDataToWindow()

bool CostFunctionPluginDialog::TransferDataToWindow ( )
privatevirtual

Transfers data to the dilaog widgets.

Definition at line 135 of file CostFunctionPluginDialog.cc.

135 {
136
137 list_->DeleteAllItems();
138
139 // Plugin cost estimation data.
140 const std::set<RowID> pluginDataIDs = hdb_.costFunctionPluginDataIDs(id_);
141 std::set<RowID>::const_iterator iter = pluginDataIDs.begin();
142 for (; iter != pluginDataIDs.end(); iter++) {
143 const CostEstimationData data = hdb_.costEstimationData(*iter);
144 if (data.hasFUReference()) {
145 list_->InsertItem(0, _T("FU"));
146 list_->SetItem(0, 1, WxConversion::toWxString(data.fuReference()));
147 } else if (data.hasRFReference()) {
148 list_->InsertItem(0, _T("RF"));
149 list_->SetItem(0, 1, WxConversion::toWxString(data.rfReference()));
150 } else if (data.hasBusReference()) {
151 list_->InsertItem(0, _T("Bus"));
152 list_->SetItem(
154 } else if (data.hasSocketReference()) {
155 list_->InsertItem(0, _T("Socket"));
156 list_->SetItem(
158 } else {
159 list_->InsertItem(0, _T("-"));
160 list_->SetItem(0, 1, _T("-"));
161 }
162
163 list_->SetItem(0, 2, WxConversion::toWxString(data.name()));
164 list_->SetItem(
166 list_->SetItemData(0, *iter);
167 }
168
169 return wxDialog::TransferDataToWindow();
170}
DataObject value() const
bool hasBusReference() const
bool hasFUReference() const
std::string name() const
RowID socketReference() const
bool hasSocketReference() const
bool hasRFReference() const
virtual std::string stringValue() const
std::set< RowID > costFunctionPluginDataIDs(RowID pluginID) const
CostEstimationData costEstimationData(RowID id) const

References CostEstimationData::busReference(), HDB::HDBManager::costEstimationData(), HDB::HDBManager::costFunctionPluginDataIDs(), CostEstimationData::fuReference(), CostEstimationData::hasBusReference(), CostEstimationData::hasFUReference(), CostEstimationData::hasRFReference(), CostEstimationData::hasSocketReference(), hdb_, id_, list_, CostEstimationData::name(), CostEstimationData::rfReference(), CostEstimationData::socketReference(), DataObject::stringValue(), WxConversion::toWxString(), and CostEstimationData::value().

Referenced by onAdd(), onDelete(), and onModify().

Here is the call graph for this function:

Member Data Documentation

◆ description_

wxString CostFunctionPluginDialog::description_
private

Plugin description string.

Definition at line 77 of file CostFunctionPluginDialog.hh.

Referenced by onOK().

◆ hdb_

HDB::HDBManager& CostFunctionPluginDialog::hdb_
private

HDB containing the plugin.

Definition at line 69 of file CostFunctionPluginDialog.hh.

Referenced by onAdd(), onDelete(), onModify(), onOK(), and TransferDataToWindow().

◆ id_

int CostFunctionPluginDialog::id_
private

Plugin id in the HDB.

Definition at line 71 of file CostFunctionPluginDialog.hh.

Referenced by onAdd(), onModify(), onOK(), and TransferDataToWindow().

◆ list_

wxListCtrl* CostFunctionPluginDialog::list_
private

Pointer to the data list widget.

Definition at line 66 of file CostFunctionPluginDialog.hh.

Referenced by selectedData(), and TransferDataToWindow().

◆ name_

wxString CostFunctionPluginDialog::name_
private

Plugin name.

Definition at line 73 of file CostFunctionPluginDialog.hh.

Referenced by onOK().

◆ path_

wxString CostFunctionPluginDialog::path_
private

Plugin file path.

Definition at line 75 of file CostFunctionPluginDialog.hh.

Referenced by onOK().

◆ TYPE_COST_DECOMP

const wxString CostFunctionPluginDialog::TYPE_COST_DECOMP
staticprivate
Initial value:
=
_T("Decompressor Cost Estimator")

Decompressor cost estimator string for the type choicer widget.

Definition at line 87 of file CostFunctionPluginDialog.hh.

Referenced by onOK().

◆ TYPE_COST_FU

const wxString CostFunctionPluginDialog::TYPE_COST_FU
staticprivate
Initial value:
=
_T("FU Cost Estimator")

FU Cost estimator string for the type choicer widget.

Definition at line 83 of file CostFunctionPluginDialog.hh.

Referenced by onOK().

◆ TYPE_COST_ICDEC

const wxString CostFunctionPluginDialog::TYPE_COST_ICDEC
staticprivate
Initial value:
=
_T("IC & Decoder Cost Estimator")

IC&decoder Cost estimator string for the type choicer widget.

Definition at line 89 of file CostFunctionPluginDialog.hh.

Referenced by onOK().

◆ TYPE_COST_RF

const wxString CostFunctionPluginDialog::TYPE_COST_RF
staticprivate
Initial value:
=
_T("RF Cost Estimator")

RF Cost estimator string for the type choicer widget.

Definition at line 85 of file CostFunctionPluginDialog.hh.

Referenced by onOK().

◆ typeChoice_

wxChoice* CostFunctionPluginDialog::typeChoice_
private

Pointer to the type choice widget.

Definition at line 80 of file CostFunctionPluginDialog.hh.

Referenced by onOK().


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