OpenASIP 2.2
Loading...
Searching...
No Matches
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.
 
RowID pluginID_
 ID of the data's parent plugin.
 
RowID dataID_
 ID of the data to modify, or -1 if new data is being added.
 
wxChoice * typeChoice_
 Entry reference type choice widget.
 
wxChoice * idChoice_
 Entry reference id choice widget.
 
wxString name_
 Name of the data.
 
wxString value_
 Value of the data.
 

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

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
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}
wxChoice * typeChoice_
Entry reference type choice widget.
static const wxString ENTRY_TYPE_SOCKET
wxSizer * createContents(wxWindow *parent, bool call_fit, bool set_sizer)
static const wxString ENTRY_TYPE_NONE
static const wxString ENTRY_TYPE_BUS
static const wxString ENTRY_TYPE_FU
RowID dataID_
ID of the data to modify, or -1 if new data is being added.
HDB::HDBManager & hdb_
HDB Containing the data.
wxString value_
Value of the data.
RowID pluginID_
ID of the data's parent plugin.
wxChoice * idChoice_
Entry reference id choice widget.
static const wxString ENTRY_TYPE_RF
wxString name_
Name of the data.

◆ ~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}

References ID_ENTRY_ID, ID_ENTRY_TYPE, ID_LINE, ID_NAME, ID_TEXT, and ID_VALUE.

◆ 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}
std::set< RowID > socketEntryIDs() const
std::set< RowID > rfEntryIDs() const
std::set< RowID > busEntryIDs() const
std::set< RowID > fuEntryIDs() const
static wxString toWxString(const std::string &source)

References HDB::HDBManager::busEntryIDs(), ENTRY_TYPE_BUS, ENTRY_TYPE_FU, ENTRY_TYPE_RF, ENTRY_TYPE_SOCKET, HDB::HDBManager::fuEntryIDs(), hdb_, idChoice_, HDB::HDBManager::rfEntryIDs(), HDB::HDBManager::socketEntryIDs(), WxConversion::toWxString(), and typeChoice_.

Referenced by TransferDataToWindow().

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
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}
int RowID
Type definition of row ID in relational databases.
Definition DBTypes.hh:37
static int toInt(const T &source)
void setBusReference(RowID busEntryID)
void setValue(const DataObject &value)
void setPluginID(RowID pluginID)
void setRFReference(RowID rfEntryID)
void setSocketReference(RowID socketEntryID)
void setFUReference(RowID fuEntryID)
void setName(const std::string &name)
virtual void modifyCostEstimationData(RowID id, const CostEstimationData &data)
RowID addCostEstimationData(const CostEstimationData &data) const
static std::string toString(const wxString &source)

References HDB::HDBManager::addCostEstimationData(), dataID_, ENTRY_TYPE_BUS, ENTRY_TYPE_FU, ENTRY_TYPE_NONE, ENTRY_TYPE_RF, ENTRY_TYPE_SOCKET, hdb_, idChoice_, HDB::HDBManager::modifyCostEstimationData(), name_, pluginID_, CostEstimationData::setBusReference(), CostEstimationData::setFUReference(), CostEstimationData::setName(), CostEstimationData::setPluginID(), CostEstimationData::setRFReference(), CostEstimationData::setSocketReference(), CostEstimationData::setValue(), Conversion::toInt(), WxConversion::toString(), typeChoice_, and value_.

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}
SimValue dummy(32)
a dummy simvalue which is given for operands that are not bound
void onEntryTypeSelection(wxCommandEvent &event)
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
CostEstimationData costEstimationData(RowID id) const

References CostEstimationData::busReference(), HDB::HDBManager::costEstimationData(), dataID_, dummy, ENTRY_TYPE_BUS, ENTRY_TYPE_FU, ENTRY_TYPE_RF, ENTRY_TYPE_SOCKET, CostEstimationData::fuReference(), CostEstimationData::hasBusReference(), CostEstimationData::hasFUReference(), CostEstimationData::hasRFReference(), CostEstimationData::hasSocketReference(), hdb_, idChoice_, CostEstimationData::name(), name_, onEntryTypeSelection(), CostEstimationData::rfReference(), CostEstimationData::socketReference(), DataObject::stringValue(), WxConversion::toWxString(), typeChoice_, CostEstimationData::value(), and 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.

Referenced by onOK(), and TransferDataToWindow().

◆ ENTRY_TYPE_BUS

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

Definition at line 89 of file CostEstimationDataDialog.hh.

Referenced by onEntryTypeSelection(), onOK(), and TransferDataToWindow().

◆ ENTRY_TYPE_FU

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

Definition at line 87 of file CostEstimationDataDialog.hh.

Referenced by onEntryTypeSelection(), onOK(), and TransferDataToWindow().

◆ ENTRY_TYPE_NONE

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

Definition at line 86 of file CostEstimationDataDialog.hh.

Referenced by onOK().

◆ ENTRY_TYPE_RF

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

Definition at line 88 of file CostEstimationDataDialog.hh.

Referenced by onEntryTypeSelection(), onOK(), and TransferDataToWindow().

◆ ENTRY_TYPE_SOCKET

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

Definition at line 90 of file CostEstimationDataDialog.hh.

Referenced by onEntryTypeSelection(), onOK(), and TransferDataToWindow().

◆ hdb_

HDB::HDBManager& CostEstimationDataDialog::hdb_
private

HDB Containing the data.

Definition at line 72 of file CostEstimationDataDialog.hh.

Referenced by onEntryTypeSelection(), onOK(), and TransferDataToWindow().

◆ idChoice_

wxChoice* CostEstimationDataDialog::idChoice_
private

Entry reference id choice widget.

Definition at line 80 of file CostEstimationDataDialog.hh.

Referenced by onEntryTypeSelection(), onOK(), and TransferDataToWindow().

◆ name_

wxString CostEstimationDataDialog::name_
private

Name of the data.

Definition at line 82 of file CostEstimationDataDialog.hh.

Referenced by onOK(), and TransferDataToWindow().

◆ pluginID_

RowID CostEstimationDataDialog::pluginID_
private

ID of the data's parent plugin.

Definition at line 74 of file CostEstimationDataDialog.hh.

Referenced by onOK().

◆ typeChoice_

wxChoice* CostEstimationDataDialog::typeChoice_
private

Entry reference type choice widget.

Definition at line 78 of file CostEstimationDataDialog.hh.

Referenced by onEntryTypeSelection(), onOK(), and TransferDataToWindow().

◆ value_

wxString CostEstimationDataDialog::value_
private

Value of the data.

Definition at line 84 of file CostEstimationDataDialog.hh.

Referenced by onOK(), and TransferDataToWindow().


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