OpenASIP  2.0
Public Member Functions | Private Types | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
CostEstimationDataDialog Class Reference

#include <CostEstimationDataDialog.hh>

Inheritance diagram for CostEstimationDataDialog:
Inheritance graph
Collaboration diagram for CostEstimationDataDialog:
Collaboration graph

Public Member Functions

 CostEstimationDataDialog (wxWindow *parent, wxWindowID id, HDB::HDBManager &hdb, RowID pluginID, RowID dataID)
 
virtual ~CostEstimationDataDialog ()
 

Private Types

enum  {
  ID_ENTRY_TYPE = 10000, ID_ENTRY_ID, ID_NAME, ID_VALUE,
  ID_TEXT, ID_LINE
}
 widget IDs More...
 

Private Member Functions

virtual bool TransferDataToWindow ()
 
void onOK (wxCommandEvent &event)
 
void onEntryTypeSelection (wxCommandEvent &event)
 
wxSizer * createContents (wxWindow *parent, bool call_fit, bool set_sizer)
 

Private Attributes

HDB::HDBManagerhdb_
 HDB Containing the data. More...
 
RowID pluginID_
 ID of the data's parent plugin. More...
 
RowID dataID_
 ID of the data to modify, or -1 if new data is being added. More...
 
wxChoice * typeChoice_
 Entry reference type choice widget. More...
 
wxChoice * idChoice_
 Entry reference id choice widget. More...
 
wxString name_
 Name of the data. More...
 
wxString value_
 Value of the data. More...
 

Static Private Attributes

static const wxString ENTRY_TYPE_NONE = _T("None")
 
static const wxString ENTRY_TYPE_FU = _T("FU")
 
static const wxString ENTRY_TYPE_RF = _T("RF")
 
static const wxString ENTRY_TYPE_BUS = _T("Bus")
 
static const wxString ENTRY_TYPE_SOCKET = _T("Socket")
 

Detailed Description

Dialog for adding and modifying cost function plugin data.

Definition at line 46 of file CostEstimationDataDialog.hh.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
private

widget IDs

Enumerator
ID_ENTRY_TYPE 
ID_ENTRY_ID 
ID_NAME 
ID_VALUE 
ID_TEXT 
ID_LINE 

Definition at line 62 of file CostEstimationDataDialog.hh.

62  {
63  ID_ENTRY_TYPE = 10000,
65  ID_NAME,
66  ID_VALUE,
67  ID_TEXT,
68  ID_LINE
69  };

Constructor & Destructor Documentation

◆ CostEstimationDataDialog()

CostEstimationDataDialog::CostEstimationDataDialog ( wxWindow *  parent,
wxWindowID  id,
HDB::HDBManager hdb,
RowID  pluginID,
RowID  dataID 
)

The Constructor.

Parameters
parentParent window of the dialog.
idWindow identifier for the dialog.
hdbHDBManager where the data is added/modified.
dataIDID of the cost data to modify or -1 if a new data is being added.

Definition at line 63 of file CostEstimationDataDialog.cc.

65  :
66  wxDialog(parent, id, _T("Cost Estimation Data")),
67  hdb_(hdb), pluginID_(pluginID), dataID_(dataID) {
68 
69  createContents(this, true, true);
70 
71  typeChoice_ = dynamic_cast<wxChoice*>(FindWindow(ID_ENTRY_TYPE));
72  idChoice_ = dynamic_cast<wxChoice*>(FindWindow(ID_ENTRY_ID));
73 
75  typeChoice_->Append(ENTRY_TYPE_FU);
76  typeChoice_->Append(ENTRY_TYPE_RF);
77  typeChoice_->Append(ENTRY_TYPE_BUS);
79 
80  FindWindow(ID_NAME)->SetValidator(wxGenericValidator(&name_));
81  FindWindow(ID_VALUE)->SetValidator(wxGenericValidator(&value_));
82 
83  if (dataID_ >= 0) {
84  typeChoice_->Disable();
85  idChoice_->Disable();
86  }
87 
88 }

◆ ~CostEstimationDataDialog()

CostEstimationDataDialog::~CostEstimationDataDialog ( )
virtual

The Destructor.

Definition at line 93 of file CostEstimationDataDialog.cc.

93  {
94 }

Member Function Documentation

◆ createContents()

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

Creates the dialog widgets.

Definition at line 239 of file CostEstimationDataDialog.cc.

240  {
241 
242  wxBoxSizer *item0 = new wxBoxSizer( wxVERTICAL );
243 
244  wxFlexGridSizer *item1 = new wxFlexGridSizer( 2, 0, 0 );
245 
246  wxStaticText *item2 = new wxStaticText( parent, ID_TEXT, wxT("Entry type:"), wxDefaultPosition, wxDefaultSize, 0 );
247  item1->Add( item2, 0, wxALIGN_RIGHT|wxALL, 5 );
248 
249  wxString *strs3 = (wxString*) NULL;
250  wxChoice *item3 = new wxChoice( parent, ID_ENTRY_TYPE, wxDefaultPosition, wxSize(100,-1), 0, strs3, 0 );
251  item1->Add( item3, 0, wxGROW|wxALL, 5 );
252 
253  wxStaticText *item4 = new wxStaticText( parent, ID_TEXT, wxT("Entry ID:"), wxDefaultPosition, wxDefaultSize, 0 );
254  item1->Add( item4, 0, wxALIGN_RIGHT|wxALL, 5 );
255 
256  wxString *strs5 = (wxString*) NULL;
257  wxChoice *item5 = new wxChoice( parent, ID_ENTRY_ID, wxDefaultPosition, wxSize(100,-1), 0, strs5, 0 );
258  item1->Add( item5, 0, wxGROW|wxALL, 5 );
259 
260  wxStaticText *item6 = new wxStaticText( parent, ID_TEXT, wxT("Name:"), wxDefaultPosition, wxDefaultSize, 0 );
261  item1->Add( item6, 0, wxALIGN_RIGHT|wxALL, 5 );
262 
263  wxTextCtrl *item7 = new wxTextCtrl( parent, ID_NAME, wxT(""), wxDefaultPosition, wxSize(200,-1), 0 );
264  item1->Add( item7, 0, wxALIGN_CENTER|wxALL, 5 );
265 
266  wxStaticText *item8 = new wxStaticText( parent, ID_TEXT, wxT("Value:"), wxDefaultPosition, wxDefaultSize, 0 );
267  item1->Add( item8, 0, wxALIGN_RIGHT|wxALL, 5 );
268 
269  wxTextCtrl *item9 = new wxTextCtrl( parent, ID_VALUE, wxT(""), wxDefaultPosition, wxSize(200,-1), 0 );
270  item1->Add( item9, 0, wxALIGN_CENTER|wxALL, 5 );
271 
272  item0->Add( item1, 0, wxALIGN_CENTER|wxALL, 5 );
273 
274  wxStaticLine *item10 = new wxStaticLine( parent, ID_LINE, wxDefaultPosition, wxSize(20,-1), wxLI_HORIZONTAL );
275  item0->Add( item10, 0, wxGROW|wxALL, 5 );
276 
277  wxBoxSizer *item11 = new wxBoxSizer( wxHORIZONTAL );
278 
279  wxButton *item12 = new wxButton( parent, wxID_OK, wxT("&OK"), wxDefaultPosition, wxDefaultSize, 0 );
280  item11->Add( item12, 0, wxALIGN_CENTER|wxALL, 5 );
281 
282  wxButton *item13 = new wxButton( parent, wxID_CANCEL, wxT("&Cancel"), wxDefaultPosition, wxDefaultSize, 0 );
283  item11->Add( item13, 0, wxALIGN_CENTER|wxALL, 5 );
284 
285  item0->Add( item11, 0, wxALL, 5 );
286 
287  if (set_sizer)
288  {
289  parent->SetSizer( item0 );
290  if (call_fit)
291  item0->SetSizeHints( parent );
292  }
293 
294  return item0;
295 }

◆ onEntryTypeSelection()

void CostEstimationDataDialog::onEntryTypeSelection ( wxCommandEvent &  event)
private

Event handler for the entry type choicer selections.

Definition at line 137 of file CostEstimationDataDialog.cc.

137  {
138 
139  idChoice_->Clear();
140 
141  if (typeChoice_->GetStringSelection() == ENTRY_TYPE_FU) {
142  // Append FU entry IDs to the entry id choicer
143  const std::set<RowID> fuIDs = hdb_.fuEntryIDs();
144  std::set<RowID>::const_iterator iter = fuIDs.begin();
145  for (; iter != fuIDs.end(); iter++) {
146  idChoice_->Append(WxConversion::toWxString(*iter));
147  }
148  } else if (typeChoice_->GetStringSelection() == ENTRY_TYPE_RF) {
149  // Append RF entry IDs to the entry id choicer
150  const std::set<RowID> rfIDs = hdb_.rfEntryIDs();
151  std::set<RowID>::const_iterator iter = rfIDs.begin();
152  for (; iter != rfIDs.end(); iter++) {
153  idChoice_->Append(WxConversion::toWxString(*iter));
154  }
155  } else if (typeChoice_->GetStringSelection() == ENTRY_TYPE_BUS) {
156  // Append FU entry IDs to the entry id choicer
157  const std::set<RowID> busIDs = hdb_.busEntryIDs();
158  std::set<RowID>::const_iterator iter = busIDs.begin();
159  for (; iter != busIDs.end(); iter++) {
160  idChoice_->Append(WxConversion::toWxString(*iter));
161  }
162 
163  } else if (typeChoice_->GetStringSelection() == ENTRY_TYPE_SOCKET) {
164  // Append FU entry IDs to the entry id choicer
165  const std::set<RowID> socketIDs = hdb_.socketEntryIDs();
166  std::set<RowID>::const_iterator iter = socketIDs.begin();
167  for (; iter != socketIDs.end(); iter++) {
168  idChoice_->Append(WxConversion::toWxString(*iter));
169  }
170  } else {
171  idChoice_->Disable();
172  return;
173  }
174 
175  idChoice_->Enable();
176  idChoice_->SetSelection(0);
177 }

References WxConversion::toWxString().

Here is the call graph for this function:

◆ onOK()

void CostEstimationDataDialog::onOK ( wxCommandEvent &  event)
private

Event handler for the ok-button.

Definition at line 183 of file CostEstimationDataDialog.cc.

183  {
184 
185  TransferDataFromWindow();
186 
187  if (name_.IsEmpty()) {
188  wxString message(_T("Data name not set."));
189  ErrorDialog dialog(this, message);
190  dialog.ShowModal();
191  return;
192  }
193 
194  CostEstimationData data;
195  data.setPluginID(pluginID_);
198  data.setValue(value);
199 
200 
201  std::string idStr =
202  WxConversion::toString(idChoice_->GetStringSelection());
203 
204  if (typeChoice_->GetStringSelection() != ENTRY_TYPE_NONE) {
205 
206  if (idStr == "") {
207  wxString message(_T("Invalid entry reference."));
208  ErrorDialog dialog(this, message);
209  dialog.ShowModal();
210  return;
211  }
212 
213  RowID id = Conversion::toInt(idStr);
214 
215  if (typeChoice_->GetStringSelection() == ENTRY_TYPE_FU) {
216  data.setFUReference(id);
217  } else if (typeChoice_->GetStringSelection() == ENTRY_TYPE_RF) {
218  data.setRFReference(id);
219  } else if (typeChoice_->GetStringSelection() == ENTRY_TYPE_BUS) {
220  data.setBusReference(id);
221  } else if (typeChoice_->GetStringSelection() == ENTRY_TYPE_SOCKET) {
222  data.setSocketReference(id);
223  }
224  }
225 
226  if (dataID_ >= 0) {
228  } else {
230  }
231 
232  EndModal(wxID_OK);
233 }

References CostEstimationData::setBusReference(), CostEstimationData::setFUReference(), CostEstimationData::setName(), CostEstimationData::setPluginID(), CostEstimationData::setRFReference(), CostEstimationData::setSocketReference(), CostEstimationData::setValue(), Conversion::toInt(), and WxConversion::toString().

Here is the call graph for this function:

◆ TransferDataToWindow()

bool CostEstimationDataDialog::TransferDataToWindow ( )
privatevirtual

Transfers data to the dialog widgets.

Returns
True, if the data was succesfully transferred.

Definition at line 102 of file CostEstimationDataDialog.cc.

102  {
103 
104  if (dataID_ >= 0) {
108 
109  if (data.hasFUReference()) {
110  typeChoice_->SetStringSelection(ENTRY_TYPE_FU);
112  } else if (data.hasRFReference()) {
113  typeChoice_->SetStringSelection(ENTRY_TYPE_RF);
115  } else if (data.hasBusReference()) {
116  typeChoice_->SetStringSelection(ENTRY_TYPE_BUS);
118  } else if (data.hasSocketReference()) {
119  typeChoice_->SetStringSelection(ENTRY_TYPE_SOCKET);
120  idChoice_->Append(
122  }
123  idChoice_->SetSelection(0);
124  } else {
125  typeChoice_->SetSelection(0);
126  wxCommandEvent dummy;
128  }
129 
130  return wxDialog::TransferDataToWindow();
131 }

References CostEstimationData::busReference(), dummy, CostEstimationData::fuReference(), CostEstimationData::hasBusReference(), CostEstimationData::hasFUReference(), CostEstimationData::hasRFReference(), CostEstimationData::hasSocketReference(), CostEstimationData::name(), CostEstimationData::rfReference(), CostEstimationData::socketReference(), DataObject::stringValue(), WxConversion::toWxString(), and CostEstimationData::value().

Here is the call graph for this function:

Member Data Documentation

◆ dataID_

RowID CostEstimationDataDialog::dataID_
private

ID of the data to modify, or -1 if new data is being added.

Definition at line 76 of file CostEstimationDataDialog.hh.

◆ ENTRY_TYPE_BUS

const wxString CostEstimationDataDialog::ENTRY_TYPE_BUS = _T("Bus")
staticprivate

Definition at line 89 of file CostEstimationDataDialog.hh.

◆ ENTRY_TYPE_FU

const wxString CostEstimationDataDialog::ENTRY_TYPE_FU = _T("FU")
staticprivate

Definition at line 87 of file CostEstimationDataDialog.hh.

◆ ENTRY_TYPE_NONE

const wxString CostEstimationDataDialog::ENTRY_TYPE_NONE = _T("None")
staticprivate

Definition at line 86 of file CostEstimationDataDialog.hh.

◆ ENTRY_TYPE_RF

const wxString CostEstimationDataDialog::ENTRY_TYPE_RF = _T("RF")
staticprivate

Definition at line 88 of file CostEstimationDataDialog.hh.

◆ ENTRY_TYPE_SOCKET

const wxString CostEstimationDataDialog::ENTRY_TYPE_SOCKET = _T("Socket")
staticprivate

Definition at line 90 of file CostEstimationDataDialog.hh.

◆ hdb_

HDB::HDBManager& CostEstimationDataDialog::hdb_
private

HDB Containing the data.

Definition at line 72 of file CostEstimationDataDialog.hh.

◆ idChoice_

wxChoice* CostEstimationDataDialog::idChoice_
private

Entry reference id choice widget.

Definition at line 80 of file CostEstimationDataDialog.hh.

◆ name_

wxString CostEstimationDataDialog::name_
private

Name of the data.

Definition at line 82 of file CostEstimationDataDialog.hh.

◆ pluginID_

RowID CostEstimationDataDialog::pluginID_
private

ID of the data's parent plugin.

Definition at line 74 of file CostEstimationDataDialog.hh.

◆ typeChoice_

wxChoice* CostEstimationDataDialog::typeChoice_
private

Entry reference type choice widget.

Definition at line 78 of file CostEstimationDataDialog.hh.

◆ value_

wxString CostEstimationDataDialog::value_
private

Value of the data.

Definition at line 84 of file CostEstimationDataDialog.hh.


The documentation for this class was generated from the following files:
CostEstimationDataDialog::name_
wxString name_
Name of the data.
Definition: CostEstimationDataDialog.hh:82
CostEstimationData::rfReference
RowID rfReference() const
Definition: CostEstimationData.cc:118
CostEstimationData::setName
void setName(const std::string &name)
CostEstimationDataDialog::ID_NAME
@ ID_NAME
Definition: CostEstimationDataDialog.hh:65
WxConversion::toWxString
static wxString toWxString(const std::string &source)
CostEstimationData::name
std::string name() const
Definition: CostEstimationData.cc:58
CostEstimationDataDialog::hdb_
HDB::HDBManager & hdb_
HDB Containing the data.
Definition: CostEstimationDataDialog.hh:72
CostEstimationDataDialog::ENTRY_TYPE_SOCKET
static const wxString ENTRY_TYPE_SOCKET
Definition: CostEstimationDataDialog.hh:90
DataObject
Definition: DataObject.hh:50
CostEstimationDataDialog::ID_ENTRY_TYPE
@ ID_ENTRY_TYPE
Definition: CostEstimationDataDialog.hh:63
DataObject::stringValue
virtual std::string stringValue() const
Definition: DataObject.cc:344
CostEstimationDataDialog::idChoice_
wxChoice * idChoice_
Entry reference id choice widget.
Definition: CostEstimationDataDialog.hh:80
CostEstimationData::hasSocketReference
bool hasSocketReference() const
CostEstimationDataDialog::pluginID_
RowID pluginID_
ID of the data's parent plugin.
Definition: CostEstimationDataDialog.hh:74
RowID
int RowID
Type definition of row ID in relational databases.
Definition: DBTypes.hh:37
CostEstimationDataDialog::ID_LINE
@ ID_LINE
Definition: CostEstimationDataDialog.hh:68
CostEstimationData::setFUReference
void setFUReference(RowID fuEntryID)
CostEstimationData::setRFReference
void setRFReference(RowID rfEntryID)
CostEstimationDataDialog::ID_TEXT
@ ID_TEXT
Definition: CostEstimationDataDialog.hh:67
CostEstimationData::hasFUReference
bool hasFUReference() const
FindWindow
Definition: FindWindow.hh:49
HDB::HDBManager::costEstimationData
CostEstimationData costEstimationData(RowID id) const
Definition: HDBManager.cc:6323
CostEstimationData::setValue
void setValue(const DataObject &value)
CostEstimationDataDialog::ENTRY_TYPE_NONE
static const wxString ENTRY_TYPE_NONE
Definition: CostEstimationDataDialog.hh:86
CostEstimationDataDialog::onEntryTypeSelection
void onEntryTypeSelection(wxCommandEvent &event)
Definition: CostEstimationDataDialog.cc:137
HDB::HDBManager::modifyCostEstimationData
virtual void modifyCostEstimationData(RowID id, const CostEstimationData &data)
Definition: HDBManager.cc:6999
CostEstimationDataDialog::ENTRY_TYPE_RF
static const wxString ENTRY_TYPE_RF
Definition: CostEstimationDataDialog.hh:88
CostEstimationData::busReference
RowID busReference() const
Definition: CostEstimationData.cc:133
ErrorDialog
Definition: ErrorDialog.hh:42
CostEstimationData::setBusReference
void setBusReference(RowID busEntryID)
HDB::HDBManager::fuEntryIDs
std::set< RowID > fuEntryIDs() const
Definition: HDBManager.cc:2035
dummy
SimValue dummy(32)
a dummy simvalue which is given for operands that are not bound
HDB::HDBManager::socketEntryIDs
std::set< RowID > socketEntryIDs() const
Definition: HDBManager.cc:2131
CostEstimationDataDialog::ENTRY_TYPE_FU
static const wxString ENTRY_TYPE_FU
Definition: CostEstimationDataDialog.hh:87
CostEstimationData::socketReference
RowID socketReference() const
Definition: CostEstimationData.cc:148
CostEstimationData
Definition: CostEstimationData.hh:42
HDB::HDBManager::busEntryIDs
std::set< RowID > busEntryIDs() const
Definition: HDBManager.cc:2099
CostEstimationData::value
DataObject value() const
Definition: CostEstimationData.cc:73
HDB::HDBManager::rfEntryIDs
std::set< RowID > rfEntryIDs() const
Definition: HDBManager.cc:2067
CostEstimationDataDialog::createContents
wxSizer * createContents(wxWindow *parent, bool call_fit, bool set_sizer)
Definition: CostEstimationDataDialog.cc:239
CostEstimationData::hasBusReference
bool hasBusReference() const
CostEstimationDataDialog::dataID_
RowID dataID_
ID of the data to modify, or -1 if new data is being added.
Definition: CostEstimationDataDialog.hh:76
CostEstimationData::fuReference
RowID fuReference() const
Definition: CostEstimationData.cc:103
CostEstimationData::setPluginID
void setPluginID(RowID pluginID)
HDB::HDBManager::addCostEstimationData
RowID addCostEstimationData(const CostEstimationData &data) const
Definition: HDBManager.cc:6694
CostEstimationDataDialog::ID_VALUE
@ ID_VALUE
Definition: CostEstimationDataDialog.hh:66
CostEstimationDataDialog::ENTRY_TYPE_BUS
static const wxString ENTRY_TYPE_BUS
Definition: CostEstimationDataDialog.hh:89
CostEstimationDataDialog::value_
wxString value_
Value of the data.
Definition: CostEstimationDataDialog.hh:84
CostEstimationData::hasRFReference
bool hasRFReference() const
CostEstimationData::setSocketReference
void setSocketReference(RowID socketEntryID)
Conversion::toInt
static int toInt(const T &source)
CostEstimationDataDialog::typeChoice_
wxChoice * typeChoice_
Entry reference type choice widget.
Definition: CostEstimationDataDialog.hh:78
WxConversion::toString
static std::string toString(const wxString &source)
CostEstimationDataDialog::ID_ENTRY_ID
@ ID_ENTRY_ID
Definition: CostEstimationDataDialog.hh:64