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

#include <TemplateSlotDialog.hh>

Inheritance diagram for TemplateSlotDialog:
Inheritance graph
Collaboration diagram for TemplateSlotDialog:
Collaboration graph

Public Member Functions

 TemplateSlotDialog (wxWindow *parent, TTAMachine::InstructionTemplate *it, TTAMachine::TemplateSlot *slot=NULL)
 
virtual ~TemplateSlotDialog ()
 

Private Types

enum  {
  ID_LABEL_SLOT = 10000, ID_SLOT, ID_LABEL_WIDTH, ID_WIDTH,
  ID_LABEL_DESTINATION, ID_DESTINATION, ID_LINE, ID_HELP
}
 

Private Member Functions

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

Private Attributes

TTAMachine::TemplateSlotslot_
 Instruction template slot to edit. More...
 
TTAMachine::InstructionTemplateit_
 Parent instruction template of the slot. More...
 
wxChoice * slotChoice_
 Choice control for the slot. More...
 
wxChoice * destinationChoice_
 Choice control fot the destination IU. More...
 
wxSpinCtrl * widthCtrl_
 Spin control for the width. More...
 
int width_
 Bit width of the slot. More...
 
TTAMachine::ImmediateUnitdestination_
 Destination immediate unit. More...
 

Detailed Description

Dialog for editing telplate slot properties.

Definition at line 49 of file TemplateSlotDialog.hh.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
private
Enumerator
ID_LABEL_SLOT 
ID_SLOT 
ID_LABEL_WIDTH 
ID_WIDTH 
ID_LABEL_DESTINATION 
ID_DESTINATION 
ID_LINE 
ID_HELP 

Definition at line 80 of file TemplateSlotDialog.hh.

80  {
81  ID_LABEL_SLOT = 10000,
82  ID_SLOT,
84  ID_WIDTH,
87  ID_LINE,
88  ID_HELP
89  };

Constructor & Destructor Documentation

◆ TemplateSlotDialog()

TemplateSlotDialog::TemplateSlotDialog ( wxWindow *  parent,
TTAMachine::InstructionTemplate it,
TTAMachine::TemplateSlot slot = NULL 
)

The Constructor.

Parameters
parentParent window of the dialog.
tempInstructionTemplate to edit.
slotSlot to edit, NULL if a new slot is being added.

Definition at line 69 of file TemplateSlotDialog.cc.

72  :
73  wxDialog(parent, -1, _T(""), wxDefaultPosition),
74  slot_(slot),
75  it_(it),
77  destination_(NULL) {
78 
79  createContents(this, true, true);
80 
81  slotChoice_ = dynamic_cast<wxChoice*>(FindWindow(ID_SLOT));
82  destinationChoice_ = dynamic_cast<wxChoice*>(FindWindow(ID_DESTINATION));
83  widthCtrl_ = dynamic_cast<wxSpinCtrl*>(FindWindow(ID_WIDTH));
84 
85  widthCtrl_->SetValidator(wxGenericValidator(&width_));
86 
87  // Read slot attributes.
88  if (slot_ != NULL) {
92  for (int i = 0; i < navigator.count(); i++) {
94  slot_->slot(), *navigator.item(i))) {
95  destination_ = navigator.item(i);
96  }
97  }
98  }
99 
100  // set widget texts
101  setTexts();
102 }

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

Here is the call graph for this function:

◆ ~TemplateSlotDialog()

TemplateSlotDialog::~TemplateSlotDialog ( )
virtual

The Destructor.

Definition at line 108 of file TemplateSlotDialog.cc.

108  {
109 }

Member Function Documentation

◆ createContents()

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

Creates the dialog window contents.

This method was generated with wxDesigner.

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 264 of file TemplateSlotDialog.cc.

265  {
266 
267  wxBoxSizer *item0 = new wxBoxSizer( wxVERTICAL );
268 
269  wxFlexGridSizer *item1 = new wxFlexGridSizer( 2, 0, 0 );
270 
271  wxStaticText *item2 = new wxStaticText( parent, ID_LABEL_SLOT, wxT("Slot:"), wxDefaultPosition, wxDefaultSize, 0 );
272  item1->Add( item2, 0, wxALIGN_RIGHT|wxALL, 5 );
273 
274  wxString *strs3 = (wxString*) NULL;
275  wxChoice *item3 = new wxChoice( parent, ID_SLOT, wxDefaultPosition, wxSize(150,-1), 0, strs3, 0 );
276  item1->Add( item3, 0, wxGROW|wxALL, 5 );
277 
278  wxStaticText *item4 = new wxStaticText( parent, ID_LABEL_DESTINATION, wxT("Destination:"), wxDefaultPosition, wxDefaultSize, 0 );
279  item1->Add( item4, 0, wxALIGN_RIGHT|wxALL, 5 );
280 
281  wxString *strs5 = (wxString*) NULL;
282  wxChoice *item5 = new wxChoice( parent, ID_DESTINATION, wxDefaultPosition, wxSize(100,-1), 0, strs5, 0 );
283  item1->Add( item5, 0, wxGROW|wxALL, 5 );
284 
285  wxStaticText *item6 = new wxStaticText( parent, ID_LABEL_WIDTH, wxT("Width:"), wxDefaultPosition, wxDefaultSize, 0 );
286  item1->Add( item6, 0, wxALIGN_RIGHT|wxALL, 5 );
287 
288  wxSpinCtrl *item7 = new wxSpinCtrl( parent, ID_WIDTH, wxT("1"), wxDefaultPosition, wxSize(-1,-1), 0, 1, 10000, 1 );
289  item1->Add( item7, 0, wxALL, 5 );
290 
291  item0->Add( item1, 0, wxGROW|wxALL, 5 );
292 
293  wxStaticLine *item8 = new wxStaticLine( parent, ID_LINE, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );
294  item0->Add( item8, 0, wxGROW|wxALL, 5 );
295 
296  wxFlexGridSizer *item9 = new wxFlexGridSizer( 2, 0, 0 );
297 
298  wxButton *item10 = new wxButton( parent, ID_HELP, wxT("&Help"), wxDefaultPosition, wxDefaultSize, 0 );
299  item9->Add( item10, 0, wxALL, 5 );
300 
301  wxBoxSizer *item11 = new wxBoxSizer( wxHORIZONTAL );
302 
303  wxButton *item12 = new wxButton( parent, wxID_OK, wxT("&OK"), wxDefaultPosition, wxDefaultSize, 0 );
304  item11->Add( item12, 0, wxALIGN_CENTER|wxALL, 5 );
305 
306  wxButton *item13 = new wxButton( parent, wxID_CANCEL, wxT("&Cancel"), wxDefaultPosition, wxDefaultSize, 0 );
307  item11->Add( item13, 0, wxALIGN_CENTER|wxALL, 5 );
308 
309  item9->Add( item11, 0, 0, 5 );
310 
311  item0->Add( item9, 0, wxGROW|wxALL, 5 );
312 
313  if (set_sizer)
314  {
315  parent->SetSizer( item0 );
316  if (call_fit)
317  item0->SetSizeHints( parent );
318  }
319 
320  return item0;
321 }

◆ onOK()

void TemplateSlotDialog::onOK ( wxCommandEvent &  event)
private

Creates a new tempalte slot based on the dialog widget values.

Definition at line 220 of file TemplateSlotDialog.cc.

220  {
221 
222  string slotName = WxConversion::toString(slotChoice_->GetStringSelection());
223 
224  // Commit edit as new slot. Delete old slot.
225  if (slot_ != NULL) {
226  it_->removeSlot(slotName);
227  }
228  TransferDataFromWindow();
229 
230  const Machine::BusNavigator busNavigator = it_->machine()->busNavigator();
231  const Machine::ImmediateSlotNavigator immsNavigator =
233 
235  WxConversion::toString(destinationChoice_->GetStringSelection()));
236 
237  if (busNavigator.hasItem(slotName)) {
238  Bus* slot = it_->machine()->busNavigator().item(slotName);
239  // create the new slot
240  it_->addSlot(slot->name(), width_, *destination_);
241  } else if (immsNavigator.hasItem(slotName)) {
242  ImmediateSlot* slot = immsNavigator.item(slotName);
243  // create the new slot
244  it_->addSlot(slot->name(), width_, *destination_);
245  } else {
246  assert(false);
247  }
248 
249  EndModal(wxID_OK);
250 }

References assert, TTAMachine::Machine::busNavigator(), TTAMachine::Machine::Navigator< ComponentType >::hasItem(), TTAMachine::Machine::Navigator< ComponentType >::item(), TTAMachine::Component::machine(), TTAMachine::Component::name(), and WxConversion::toString().

Here is the call graph for this function:

◆ setTexts()

void TemplateSlotDialog::setTexts ( )
private

Sets texts for widgets.

Definition at line 116 of file TemplateSlotDialog.cc.

116  {
119 
120  // Dialog title
121  format fmt = prodeTexts->text(
123  SetTitle(WxConversion::toWxString(fmt.str()));
124 
125  // buttons
126  WidgetTools::setLabel(generator, FindWindow(wxID_OK),
128 
129  WidgetTools::setLabel(generator, FindWindow(wxID_CANCEL),
131 
134 
135 
136  // widget labels
139 
142 
145 }

References 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_LABEL_DESTINATION, ProDeTextGenerator::TXT_LABEL_SLOT, ProDeTextGenerator::TXT_LABEL_WIDTH, and ProDeTextGenerator::TXT_TEMPLATE_SLOT_DIALOG_TITLE.

Here is the call graph for this function:

◆ TransferDataToWindow()

bool TemplateSlotDialog::TransferDataToWindow ( )
privatevirtual

Transfers data from the InstructionTemplate object to the dialog widgets.

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

Definition at line 154 of file TemplateSlotDialog.cc.

154  {
155 
156  // Set slot choicer.
157  slotChoice_->Clear();
158 
159  if (slot_ == NULL) {
160  // A new slot is being added, set all available busses to the
161  // slot choice.
162  Machine::BusNavigator navigator = it_->machine()->busNavigator();
163  for (int i = 0; i < navigator.count(); i++) {
164  if (!(it_->usesSlot(navigator.item(i)->name()))) {
165  wxString name =
166  WxConversion::toWxString(navigator.item(i)->name());
167  slotChoice_->Append(name);
168  }
169  }
170  // Add immediate slots.
171  Machine::ImmediateSlotNavigator immSlotNavigator =
173  for (int i = 0; i < immSlotNavigator.count(); i++) {
174  if (!(it_->usesSlot(immSlotNavigator.item(i)->name()))) {
175  wxString name =
176  WxConversion::toWxString(immSlotNavigator.item(i)->name());
177  slotChoice_->Append(name);
178  }
179  }
180  } else {
181  // An old slot is being modified, set the slot and disable the control.
183  slotChoice_->Disable();
184  }
185 
186  // Set destination choicer.
187  destinationChoice_->Clear();
190  for (int i = 0; i < navigator.count(); i++) {
191  wxString name =
192  WxConversion::toWxString(navigator.item(i)->name());
193  destinationChoice_->Append(name);
194  }
195  // Set selections for editing slot
196  if(slot_ != NULL) {
197  wxString name = WxConversion::toWxString(slot_->destination()->name());
198  assert(!name.empty());
199  destinationChoice_->SetSelection(destinationChoice_->FindString(name));
200  widthCtrl_->SetValue(slot_->width());
201  }
202 
203 
204  // Set choicer selections.
205  slotChoice_->SetSelection(0);
206  if (destination_ == NULL) {
207  destinationChoice_->SetSelection(0);
208  } else {
209  wxString name = WxConversion::toWxString(destination_->name());
210  destinationChoice_->SetStringSelection(name);
211  }
212  return wxDialog::TransferDataToWindow();
213 }

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

Here is the call graph for this function:

Member Data Documentation

◆ destination_

TTAMachine::ImmediateUnit* TemplateSlotDialog::destination_
private

Destination immediate unit.

Definition at line 77 of file TemplateSlotDialog.hh.

◆ destinationChoice_

wxChoice* TemplateSlotDialog::destinationChoice_
private

Choice control fot the destination IU.

Definition at line 71 of file TemplateSlotDialog.hh.

◆ it_

TTAMachine::InstructionTemplate* TemplateSlotDialog::it_
private

Parent instruction template of the slot.

Definition at line 67 of file TemplateSlotDialog.hh.

◆ slot_

TTAMachine::TemplateSlot* TemplateSlotDialog::slot_
private

Instruction template slot to edit.

Definition at line 65 of file TemplateSlotDialog.hh.

◆ slotChoice_

wxChoice* TemplateSlotDialog::slotChoice_
private

Choice control for the slot.

Definition at line 69 of file TemplateSlotDialog.hh.

◆ width_

int TemplateSlotDialog::width_
private

Bit width of the slot.

Definition at line 75 of file TemplateSlotDialog.hh.

◆ widthCtrl_

wxSpinCtrl* TemplateSlotDialog::widthCtrl_
private

Spin control for the width.

Definition at line 73 of file TemplateSlotDialog.hh.


The documentation for this class was generated from the following files:
TemplateSlotDialog::ID_SLOT
@ ID_SLOT
Definition: TemplateSlotDialog.hh:82
WxConversion::toWxString
static wxString toWxString(const std::string &source)
TTAMachine::Component::name
virtual TCEString name() const
Definition: MachinePart.cc:125
TemplateSlotDialog::it_
TTAMachine::InstructionTemplate * it_
Parent instruction template of the slot.
Definition: TemplateSlotDialog.hh:67
TemplateSlotDialog::ID_LABEL_DESTINATION
@ ID_LABEL_DESTINATION
Definition: TemplateSlotDialog.hh:85
WidgetTools::setLabel
static void setLabel(Texts::TextGenerator *generator, wxWindow *widget, int textID)
Definition: WidgetTools.cc:92
TTAMachine::Bus
Definition: Bus.hh:53
TemplateSlotDialog::ID_HELP
@ ID_HELP
Definition: TemplateSlotDialog.hh:88
GUITextGenerator::instance
static GUITextGenerator * instance()
Definition: GUITextGenerator.cc:67
TTAMachine::InstructionTemplate::addSlot
virtual void addSlot(const std::string &slotName, int width, ImmediateUnit &dstUnit)
Definition: InstructionTemplate.cc:169
TemplateSlotDialog::ID_WIDTH
@ ID_WIDTH
Definition: TemplateSlotDialog.hh:84
GUITextGenerator
Definition: GUITextGenerator.hh:46
GUITextGenerator::TXT_BUTTON_HELP
@ TXT_BUTTON_HELP
Label for help button.
Definition: GUITextGenerator.hh:60
ProDeTextGenerator::TXT_LABEL_SLOT
@ TXT_LABEL_SLOT
Label for slot widget.
Definition: ProDeTextGenerator.hh:71
FindWindow
Definition: FindWindow.hh:49
TTAMachine::Machine::Navigator::count
int count() const
Texts::TextGenerator::text
virtual boost::format text(int textId)
Definition: TextGenerator.cc:94
TemplateSlotDialog::widthCtrl_
wxSpinCtrl * widthCtrl_
Spin control for the width.
Definition: TemplateSlotDialog.hh:73
TemplateSlotDialog::destinationChoice_
wxChoice * destinationChoice_
Choice control fot the destination IU.
Definition: TemplateSlotDialog.hh:71
TemplateSlotDialog::slot_
TTAMachine::TemplateSlot * slot_
Instruction template slot to edit.
Definition: TemplateSlotDialog.hh:65
TemplateSlotDialog::ID_LABEL_SLOT
@ ID_LABEL_SLOT
Definition: TemplateSlotDialog.hh:81
ProDeTextGenerator
Definition: ProDeTextGenerator.hh:49
TemplateSlotDialog::setTexts
void setTexts()
Definition: TemplateSlotDialog.cc:116
ProDeTextGenerator::TXT_LABEL_DESTINATION
@ TXT_LABEL_DESTINATION
Label for destination widget.
Definition: ProDeTextGenerator.hh:73
assert
#define assert(condition)
Definition: Application.hh:86
GUITextGenerator::TXT_BUTTON_CANCEL
@ TXT_BUTTON_CANCEL
Label for cancel button.
Definition: GUITextGenerator.hh:55
ModelConstants::DEFAULT_WIDTH
static const int DEFAULT_WIDTH
Default bit width.
Definition: ModelConstants.hh:46
ProDeTextGenerator::TXT_TEMPLATE_SLOT_DIALOG_TITLE
@ TXT_TEMPLATE_SLOT_DIALOG_TITLE
Template Slot dialog title.
Definition: ProDeTextGenerator.hh:167
TTAMachine::Machine::immediateUnitNavigator
virtual ImmediateUnitNavigator immediateUnitNavigator() const
Definition: Machine.cc:416
TTAMachine::Machine::Navigator::hasItem
bool hasItem(const std::string &name) const
TemplateSlotDialog::slotChoice_
wxChoice * slotChoice_
Choice control for the slot.
Definition: TemplateSlotDialog.hh:69
TTAMachine::TemplateSlot::destination
ImmediateUnit * destination() const
TTAMachine::TemplateSlot::slot
std::string slot() const
TTAMachine::InstructionTemplate::supportedWidth
virtual int supportedWidth() const
Definition: InstructionTemplate.cc:427
TemplateSlotDialog::ID_DESTINATION
@ ID_DESTINATION
Definition: TemplateSlotDialog.hh:86
TTAMachine::Machine::immediateSlotNavigator
virtual ImmediateSlotNavigator immediateSlotNavigator() const
Definition: Machine.cc:462
ProDeTextGenerator::instance
static ProDeTextGenerator * instance()
Definition: ProDeTextGenerator.cc:382
TemplateSlotDialog::createContents
wxSizer * createContents(wxWindow *parent, bool call_fit, bool set_sizer)
Definition: TemplateSlotDialog.cc:264
TTAMachine::Component::machine
virtual Machine * machine() const
TemplateSlotDialog::ID_LINE
@ ID_LINE
Definition: TemplateSlotDialog.hh:87
TTAMachine::Machine::busNavigator
virtual BusNavigator busNavigator() const
Definition: Machine.cc:356
TemplateSlotDialog::ID_LABEL_WIDTH
@ ID_LABEL_WIDTH
Definition: TemplateSlotDialog.hh:83
TTAMachine::Machine::Navigator::item
ComponentType * item(int index) const
TTAMachine::InstructionTemplate::destinationUsesSlot
virtual bool destinationUsesSlot(const std::string &slotName, const ImmediateUnit &dstUnit) const
Definition: InstructionTemplate.cc:280
TTAMachine::TemplateSlot::width
int width() const
TTAMachine::InstructionTemplate::removeSlot
virtual void removeSlot(const std::string &slotName)
Definition: InstructionTemplate.cc:201
ProDeTextGenerator::TXT_LABEL_WIDTH
@ TXT_LABEL_WIDTH
Label for bit width widget.
Definition: ProDeTextGenerator.hh:57
WxConversion::toString
static std::string toString(const wxString &source)
TemplateSlotDialog::destination_
TTAMachine::ImmediateUnit * destination_
Destination immediate unit.
Definition: TemplateSlotDialog.hh:77
TTAMachine::Machine::Navigator
Definition: Machine.hh:186
TTAMachine::ImmediateSlot
Definition: ImmediateSlot.hh:44
TemplateSlotDialog::width_
int width_
Bit width of the slot.
Definition: TemplateSlotDialog.hh:75
TTAMachine::InstructionTemplate::usesSlot
virtual bool usesSlot(const std::string &slotName) const
Definition: InstructionTemplate.cc:265
GUITextGenerator::TXT_BUTTON_OK
@ TXT_BUTTON_OK
Label for OK button.
Definition: GUITextGenerator.hh:59