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

#include <FUGuardDialog.hh>

Inheritance diagram for FUGuardDialog:
Inheritance graph
Collaboration diagram for FUGuardDialog:
Collaboration graph

Public Member Functions

 FUGuardDialog (wxWindow *parent, TTAMachine::Bus *bus, TTAMachine::PortGuard *guard=NULL)
 
virtual ~FUGuardDialog ()
 
virtual bool TransferDataToWindow ()
 

Private Types

enum  {
  ID_LABEL_NAME = 10000 , ID_LABEL_PORT , ID_FU_NAME , ID_FU_PORT ,
  ID_INVERTED , ID_HELP , ID_LINE
}
 

Private Member Functions

wxSizer * createContents (wxWindow *parent, bool call_fit, bool set_sizer)
 
void onFUChoice (wxCommandEvent &event)
 
void onOK (wxCommandEvent &event)
 
void onCancel (wxCommandEvent &event)
 
TTAMachine::FunctionUnitselectedFU () const
 
TTAMachine::FUPortselectedPort () const
 
void setTexts ()
 

Private Attributes

wxChoice * nameChoice_
 Choice widget for the function unit selection.
 
wxChoice * portChoice_
 Choice widget for the port selection.
 
wxCheckBox * invertedBox_
 Checkbox widget for the inverted flag.
 
bool inverted_
 Inverted flag for the guard.
 
bool newInverted_
 Modified inverted flag.
 
TTAMachine::FUPortport_
 Port of the guard.
 
TTAMachine::Busbus_
 Parent bus of the guard.
 
bool adding_
 True if a new guard is being added, false otherwise.
 

Detailed Description

Dialog for editing function unit port guard properties.

Definition at line 47 of file FUGuardDialog.hh.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
private
Enumerator
ID_LABEL_NAME 
ID_LABEL_PORT 
ID_FU_NAME 
ID_FU_PORT 
ID_INVERTED 
ID_HELP 
ID_LINE 

Definition at line 84 of file FUGuardDialog.hh.

Constructor & Destructor Documentation

◆ FUGuardDialog()

FUGuardDialog::FUGuardDialog ( wxWindow *  parent,
TTAMachine::Bus bus,
TTAMachine::PortGuard guard = NULL 
)

The Constructor.

Parameters
parentParent window of the dialog.
guardPort guard to edit.

Definition at line 65 of file FUGuardDialog.cc.

68 :
69 wxDialog(parent, -1, _T(""), wxDefaultPosition),
70 inverted_(false),
71 newInverted_(false),
72 port_(NULL),
73 bus_(bus),
74 adding_(false) {
75
76
77 if (guard == NULL) {
78 // adding a new guard
79 adding_ = true;
80
83
84 for (int i = 0; i < navigator.count(); i++) {
85 if (navigator.item(i)->operationPortCount() > 0) {
86 port_ = navigator.item(i)->operationPort(0);
87 break;
88 }
89 }
90
91 assert(port_ != NULL);
92
93 } else {
94 // editing an old guard
95 port_ = guard->port();
96 inverted_ = guard->isInverted();
98 bus_ = guard->parentBus();
99
100 // The guard is temporarily deleted to simplify legality checks.
101 delete guard;
102 guard = NULL;
103 }
104
105 createContents(this, true, true);
106
107 // set pointers to the dialog widgets
108 nameChoice_ = dynamic_cast<wxChoice*>(FindWindow(ID_FU_NAME));
109 portChoice_ = dynamic_cast<wxChoice*>(FindWindow(ID_FU_PORT));
110 invertedBox_ = dynamic_cast<wxCheckBox*>(FindWindow(ID_INVERTED));
111
112 invertedBox_->SetValidator(wxGenericValidator(&newInverted_));
113
114 // set widget texts.
115 setTexts();
116}
#define assert(condition)
bool adding_
True if a new guard is being added, false otherwise.
wxCheckBox * invertedBox_
Checkbox widget for the inverted flag.
wxSizer * createContents(wxWindow *parent, bool call_fit, bool set_sizer)
bool inverted_
Inverted flag for the guard.
wxChoice * portChoice_
Choice widget for the port selection.
wxChoice * nameChoice_
Choice widget for the function unit selection.
bool newInverted_
Modified inverted flag.
TTAMachine::Bus * bus_
Parent bus of the guard.
TTAMachine::FUPort * port_
Port of the guard.
virtual Machine * machine() const
virtual bool isInverted() const
virtual Bus * parentBus() const
ComponentType * item(int index) const
virtual FunctionUnitNavigator functionUnitNavigator() const
Definition Machine.cc:380
FUPort * port() const

References assert, TTAMachine::Machine::Navigator< ComponentType >::count(), and TTAMachine::Machine::Navigator< ComponentType >::item().

Here is the call graph for this function:

◆ ~FUGuardDialog()

FUGuardDialog::~FUGuardDialog ( )
virtual

The Destructor.

Definition at line 122 of file FUGuardDialog.cc.

122 {
123}

Member Function Documentation

◆ createContents()

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

Creates contents of the dialog window.

Code generated with wxDesigner.

Parameters
parentParent dialog of the contents.
call_fitIf true, fits sizer in dialog window.
set_sizerIf true, sets sizer as dialog's sizer.
Returns
Top level sizer of the contents.

Definition at line 320 of file FUGuardDialog.cc.

321 {
322
323 wxBoxSizer *item0 = new wxBoxSizer( wxVERTICAL );
324
325 wxGridSizer *item1 = new wxGridSizer( 2, 0, 0 );
326
327 wxStaticText *item2 = new wxStaticText( parent, ID_LABEL_NAME, wxT("Function Unit Name:"), wxDefaultPosition, wxDefaultSize, 0 );
328 item1->Add( item2, 0, wxALL, 5 );
329
330 wxString *strs3 = (wxString*) NULL;
331 wxChoice *item3 = new wxChoice( parent, ID_FU_NAME, wxDefaultPosition, wxSize(100,-1), 0, strs3, 0 );
332 item1->Add( item3, 0, wxGROW|wxALL, 5 );
333
334 wxStaticText *item4 = new wxStaticText( parent, ID_LABEL_PORT, wxT("Port Name:"), wxDefaultPosition, wxDefaultSize, 0 );
335 item1->Add( item4, 0, wxALL, 5 );
336
337 wxString *strs5 = (wxString*) NULL;
338 wxChoice *item5 = new wxChoice( parent, ID_FU_PORT, wxDefaultPosition, wxSize(100,-1), 0, strs5, 0 );
339 item1->Add( item5, 0, wxGROW|wxALL, 5 );
340
341 item0->Add( item1, 0, wxALIGN_CENTER|wxALL, 5 );
342
343 wxCheckBox *item6 = new wxCheckBox( parent, ID_INVERTED, wxT("Inverted"), wxDefaultPosition, wxDefaultSize, 0 );
344 item0->Add( item6, 0, wxALL, 5 );
345
346 wxStaticLine *item7 = new wxStaticLine( parent, ID_LINE, wxDefaultPosition, wxSize(20,-1), wxLI_HORIZONTAL );
347 item0->Add( item7, 0, wxGROW|wxALL, 5 );
348
349 wxBoxSizer *item8 = new wxBoxSizer( wxHORIZONTAL );
350
351 wxButton *item9 = new wxButton( parent, ID_HELP, wxT("&Help"), wxDefaultPosition, wxDefaultSize, 0 );
352 item8->Add( item9, 0, wxALIGN_CENTER|wxALL, 5 );
353
354 wxButton *item10 = new wxButton( parent, wxID_OK, wxT("&OK"), wxDefaultPosition, wxDefaultSize, 0 );
355 item8->Add( item10, 0, wxALIGN_CENTER|wxALL, 5 );
356
357 wxButton *item11 = new wxButton( parent, wxID_CANCEL, wxT("&Cancel"), wxDefaultPosition, wxDefaultSize, 0 );
358 item8->Add( item11, 0, wxALIGN_CENTER|wxALL, 5 );
359
360 item0->Add( item8, 0, wxALIGN_CENTER|wxALL, 5 );
361
362 if (set_sizer)
363 {
364 parent->SetSizer( item0 );
365 if (call_fit)
366 item0->SetSizeHints( parent );
367 }
368
369 return item0;
370}

References ID_FU_NAME, ID_FU_PORT, ID_HELP, ID_INVERTED, ID_LABEL_NAME, ID_LABEL_PORT, and ID_LINE.

◆ onCancel()

void FUGuardDialog::onCancel ( wxCommandEvent &  event)
private

Cancels the dialog effects by creating the original port guard.

Closes the Dialog.

Definition at line 301 of file FUGuardDialog.cc.

301 {
302 if (adding_ == false) {
303 new PortGuard(inverted_, *port_, *bus_);
304 }
305 EndModal(wxID_CANCEL);
306}

References adding_, bus_, inverted_, and port_.

◆ onFUChoice()

void FUGuardDialog::onFUChoice ( wxCommandEvent &  event)
private

Updates the port choice when the function unit selection is changed.

Definition at line 208 of file FUGuardDialog.cc.

208 {
209
210 wxString selection = portChoice_->GetStringSelection();
211
212 portChoice_->Clear();
213
214 FunctionUnit* fu = selectedFU();
215 for (int i = 0; i < fu->portCount(); i++) {
216 wxString name = WxConversion::toWxString(fu->port(i)->name());
217 portChoice_->Append(name);
218 }
219
220 if (portChoice_->FindString(selection) >= 0) {
221 portChoice_->SetStringSelection(selection);
222 } else {
223 portChoice_->SetSelection(0);
224 }
225}
TTAMachine::FunctionUnit * selectedFU() const
virtual BaseFUPort * port(const std::string &name) const
virtual std::string name() const
Definition Port.cc:141
virtual int portCount() const
Definition Unit.cc:135
static wxString toWxString(const std::string &source)

References TTAMachine::Port::name(), TTAMachine::FunctionUnit::port(), portChoice_, TTAMachine::Unit::portCount(), selectedFU(), and WxConversion::toWxString().

Here is the call graph for this function:

◆ onOK()

void FUGuardDialog::onOK ( wxCommandEvent &  event)
private

Updates the guard object when the OK-button is pressed.

Closes the dialog.

Definition at line 266 of file FUGuardDialog.cc.

266 {
267 FUPort* port = selectedPort();
268 if (port == NULL) {
270 format message = prodeTexts->text(ProDeTextGenerator::MSG_ERROR);
271 InformationDialog dialog(
273 message.str() + "Select a port.\n"));
274 dialog.ShowModal();
275 return;
276 }
277
278 TransferDataFromWindow();
279
280 try {
281 new PortGuard(newInverted_, *port, *bus_);
282 } catch (ComponentAlreadyExists& e) {
284 format message =
286 InformationDialog dialog(
287 this, WxConversion::toWxString(message.str()));
288 dialog.ShowModal();
289 return;
290 }
291 EndModal(wxID_OK);
292}
TTAMachine::FUPort * selectedPort() const
static ProDeTextGenerator * instance()
@ MSG_ERROR_GUARD_EXISTS
Error: Equal guard exists.
@ MSG_ERROR
Text 'Error' and new line.
virtual boost::format text(int textId)

References bus_, ProDeTextGenerator::instance(), ProDeTextGenerator::MSG_ERROR, ProDeTextGenerator::MSG_ERROR_GUARD_EXISTS, newInverted_, selectedPort(), Texts::TextGenerator::text(), and WxConversion::toWxString().

Here is the call graph for this function:

◆ selectedFU()

FunctionUnit * FUGuardDialog::selectedFU ( ) const
private

Returns a pointer to the selected function unit.

Returns
Pointer to the selected function unit.

Definition at line 234 of file FUGuardDialog.cc.

234 {
235 string name = WxConversion::toString(nameChoice_->GetStringSelection());
238 FunctionUnit* fu = navigator.item(name);
239 return fu;
240}
static std::string toString(const wxString &source)

References bus_, TTAMachine::Machine::functionUnitNavigator(), TTAMachine::Machine::Navigator< ComponentType >::item(), TTAMachine::Component::machine(), nameChoice_, and WxConversion::toString().

Referenced by onFUChoice(), and selectedPort().

Here is the call graph for this function:

◆ selectedPort()

FUPort * FUGuardDialog::selectedPort ( ) const
private

Returns a pointer to the selected function unit port.

Returns
Pointer to the selected function unit port.

Definition at line 249 of file FUGuardDialog.cc.

249 {
250 string name = WxConversion::toString(portChoice_->GetStringSelection());
251
252 if (name == "") {
253 return NULL;
254 }
255
256 FUPort* port = selectedFU()->operationPort(name);
257 return port;
258}
virtual FUPort * operationPort(const std::string &name) const

References TTAMachine::FunctionUnit::operationPort(), portChoice_, selectedFU(), and WxConversion::toString().

Referenced by onOK().

Here is the call graph for this function:

◆ setTexts()

void FUGuardDialog::setTexts ( )
private

Sets texts for widgets.

Definition at line 130 of file FUGuardDialog.cc.

130 {
133
134 // Dialog title
135 format fmt = prodeTexts->text(
137 SetTitle(WxConversion::toWxString(fmt.str()));
138
139 // buttons
140 WidgetTools::setLabel(generator, FindWindow(wxID_OK),
142
143 WidgetTools::setLabel(generator, FindWindow(wxID_CANCEL),
145
148
149 // widget labels
152
155
158}
@ TXT_BUTTON_HELP
Label for help button.
@ TXT_BUTTON_CANCEL
Label for cancel button.
@ TXT_BUTTON_OK
Label for OK button.
static GUITextGenerator * instance()
@ TXT_FU_GUARD_DIALOG_TITLE
Function unit guard dialog title.
@ TXT_LABEL_FU_NAME
Label for function unit name.
@ TXT_LABEL_PORT_NAME
Label for port name.
@ TXT_LABEL_INVERTED
Label for inverted checkbox.
static void setLabel(Texts::TextGenerator *generator, wxWindow *widget, int textID)

References ID_HELP, ID_INVERTED, ID_LABEL_NAME, ID_LABEL_PORT, GUITextGenerator::instance(), ProDeTextGenerator::instance(), WidgetTools::setLabel(), Texts::TextGenerator::text(), WxConversion::toWxString(), GUITextGenerator::TXT_BUTTON_CANCEL, GUITextGenerator::TXT_BUTTON_HELP, GUITextGenerator::TXT_BUTTON_OK, ProDeTextGenerator::TXT_FU_GUARD_DIALOG_TITLE, ProDeTextGenerator::TXT_LABEL_FU_NAME, ProDeTextGenerator::TXT_LABEL_INVERTED, and ProDeTextGenerator::TXT_LABEL_PORT_NAME.

Here is the call graph for this function:

◆ TransferDataToWindow()

bool FUGuardDialog::TransferDataToWindow ( )
virtual

Transfers data from the guard object to the dialog widgets.

Returns
true, if the transfer was succesful, false otherwise.

Definition at line 167 of file FUGuardDialog.cc.

167 {
168 nameChoice_->Clear();
169 portChoice_->Clear();
170
173
174 // add function units and set selection
175 for (int i = 0; i < navigator.count(); i++) {
176 wxString name = WxConversion::toWxString(navigator.item(i)->name());
177 nameChoice_->Append(name);
178 }
179 nameChoice_->SetStringSelection(
181
182 // add function unit ports and set selection
183 for (int i = 0; i < port_->parentUnit()->portCount(); i++) {
184
185 // port must be output port
186 if (port_->parentUnit()->port(i)->outputSocket() == NULL) {
187 continue;
188 }
189
190 wxString name =
192
193 portChoice_->Append(name);
194 }
195 portChoice_->SetStringSelection(WxConversion::toWxString(port_->name()));
196
197 // set inverted checkbox
198 invertedBox_->SetValue(newInverted_);
199
200 return wxDialog::TransferDataToWindow();
201}
FunctionUnit * parentUnit() const
Definition BaseFUPort.cc:96
virtual TCEString name() const
virtual Socket * outputSocket() const
Definition Port.cc:281

References bus_, TTAMachine::Machine::Navigator< ComponentType >::count(), TTAMachine::Machine::functionUnitNavigator(), invertedBox_, TTAMachine::Machine::Navigator< ComponentType >::item(), TTAMachine::Component::machine(), TTAMachine::Component::name(), TTAMachine::Port::name(), nameChoice_, newInverted_, TTAMachine::Port::outputSocket(), TTAMachine::BaseFUPort::parentUnit(), TTAMachine::FunctionUnit::port(), port_, portChoice_, and WxConversion::toWxString().

Here is the call graph for this function:

Member Data Documentation

◆ adding_

bool FUGuardDialog::adding_
private

True if a new guard is being added, false otherwise.

Definition at line 81 of file FUGuardDialog.hh.

Referenced by onCancel().

◆ bus_

TTAMachine::Bus* FUGuardDialog::bus_
private

Parent bus of the guard.

Definition at line 79 of file FUGuardDialog.hh.

Referenced by onCancel(), onOK(), selectedFU(), and TransferDataToWindow().

◆ inverted_

bool FUGuardDialog::inverted_
private

Inverted flag for the guard.

Definition at line 73 of file FUGuardDialog.hh.

Referenced by onCancel().

◆ invertedBox_

wxCheckBox* FUGuardDialog::invertedBox_
private

Checkbox widget for the inverted flag.

Definition at line 70 of file FUGuardDialog.hh.

Referenced by TransferDataToWindow().

◆ nameChoice_

wxChoice* FUGuardDialog::nameChoice_
private

Choice widget for the function unit selection.

Definition at line 66 of file FUGuardDialog.hh.

Referenced by selectedFU(), and TransferDataToWindow().

◆ newInverted_

bool FUGuardDialog::newInverted_
private

Modified inverted flag.

Definition at line 75 of file FUGuardDialog.hh.

Referenced by onOK(), and TransferDataToWindow().

◆ port_

TTAMachine::FUPort* FUGuardDialog::port_
private

Port of the guard.

Definition at line 77 of file FUGuardDialog.hh.

Referenced by onCancel(), and TransferDataToWindow().

◆ portChoice_

wxChoice* FUGuardDialog::portChoice_
private

Choice widget for the port selection.

Definition at line 68 of file FUGuardDialog.hh.

Referenced by onFUChoice(), selectedPort(), and TransferDataToWindow().


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