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

#include <AddressSpacesDialog.hh>

Inheritance diagram for AddressSpacesDialog:
Inheritance graph
Collaboration diagram for AddressSpacesDialog:
Collaboration graph

Public Member Functions

 AddressSpacesDialog (wxWindow *parent, TTAMachine::Machine *machine)
 
 ~AddressSpacesDialog ()
 

Private Types

enum  {
  ID_ADD = 10000, ID_EDIT, ID_HELP, ID_DELETE,
  ID_LIST, ID_LINE
}
 

Private Member Functions

wxSizer * createContents (wxWindow *parent, bool call_fit, bool set_sizer)
 
TTAMachine::AddressSpaceselectedAS ()
 
void updateASList ()
 
void onAdd (wxCommandEvent &event)
 
void onActivateAS (wxListEvent &event)
 
void onEdit (wxCommandEvent &event)
 
void onDelete (wxCommandEvent &event)
 
void onASSelection (wxListEvent &event)
 
void onASRightClick (wxListEvent &event)
 
void setTexts ()
 

Private Attributes

TTAMachine::Machinemachine_
 Machine containing the address spaces to list. More...
 
wxListCtrl * asList_
 List control for listing the address spaces. More...
 

Detailed Description

Dialog for listing and editing address spaces of the machine.

Definition at line 48 of file AddressSpacesDialog.hh.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
private
Enumerator
ID_ADD 
ID_EDIT 
ID_HELP 
ID_DELETE 
ID_LIST 
ID_LINE 

Definition at line 71 of file AddressSpacesDialog.hh.

71  {
72  ID_ADD = 10000,
73  ID_EDIT,
74  ID_HELP,
75  ID_DELETE,
76  ID_LIST,
77  ID_LINE
78  };

Constructor & Destructor Documentation

◆ AddressSpacesDialog()

AddressSpacesDialog::AddressSpacesDialog ( wxWindow *  parent,
TTAMachine::Machine machine 
)

The Constructor.

Parameters
parentParent window of the dialog.
machineMachine containing the address spaces.

Definition at line 81 of file AddressSpacesDialog.cc.

83  :
84  wxDialog(parent, -1, _T(""), wxDefaultPosition, wxSize(400,300)),
85  machine_(machine) {
86 
87  createContents(this, true, true);
88 
89  asList_ = dynamic_cast<wxListCtrl*>(FindWindow(ID_LIST));
90 
91  FindWindow(ID_EDIT)->Disable();
92  FindWindow(ID_DELETE)->Disable();
93 
94  // set texts to widgets
95  setTexts();
96 
97  updateASList();
98 }

◆ ~AddressSpacesDialog()

AddressSpacesDialog::~AddressSpacesDialog ( )

The Destructor.

Definition at line 104 of file AddressSpacesDialog.cc.

104  {
105 }

Member Function Documentation

◆ createContents()

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

Creates the dialog window contents.

This method was generated with wxDesigner, thus the ugly code and too long lines.

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 352 of file AddressSpacesDialog.cc.

353 {
354  wxBoxSizer *item0 = new wxBoxSizer( wxVERTICAL );
355 
356  wxListCtrl *item1 = new wxListCtrl( parent, ID_LIST, wxDefaultPosition, wxSize(400,200), wxLC_REPORT|wxLC_SINGLE_SEL );
357  item0->Add( item1, 0, wxALIGN_CENTER|wxALL, 5 );
358 
359  wxGridSizer *item2 = new wxGridSizer( 3, 0, 0 );
360 
361  wxButton *item3 = new wxButton( parent, ID_ADD, wxT("&Add..."), wxDefaultPosition, wxDefaultSize, 0 );
362  item2->Add( item3, 0, wxALIGN_CENTER|wxALL, 5 );
363 
364  wxButton *item4 = new wxButton( parent, ID_EDIT, wxT("&Edit..."), wxDefaultPosition, wxDefaultSize, 0 );
365  item2->Add( item4, 0, wxALIGN_CENTER|wxALL, 5 );
366 
367  wxButton *item5 = new wxButton( parent, ID_DELETE, wxT("&Delete"), wxDefaultPosition, wxDefaultSize, 0 );
368  item2->Add( item5, 0, wxALIGN_CENTER|wxALL, 5 );
369 
370  item0->Add( item2, 0, wxGROW, 5 );
371 
372  wxStaticLine *item6 = new wxStaticLine( parent, ID_LINE, wxDefaultPosition, wxSize(20,-1), wxLI_HORIZONTAL );
373  item0->Add( item6, 0, wxGROW|wxALL, 5 );
374 
375  wxGridSizer *item7 = new wxGridSizer( 2, 0, 0 );
376 
377  wxButton *item8 = new wxButton( parent, ID_HELP, wxT("&Help"), wxDefaultPosition, wxDefaultSize, 0 );
378  item7->Add( item8, 0, wxALL, 5 );
379 
380  wxBoxSizer *item9 = new wxBoxSizer( wxHORIZONTAL );
381 
382  wxButton *item10 = new wxButton( parent, wxID_OK, wxT("&OK"), wxDefaultPosition, wxDefaultSize, 0 );
383  item9->Add( item10, 0, wxALIGN_CENTER|wxALL, 5 );
384 
385  wxButton *item11 = new wxButton( parent, wxID_CANCEL, wxT("&Cancel"), wxDefaultPosition, wxDefaultSize, 0 );
386  item9->Add( item11, 0, wxALIGN_CENTER|wxALL, 5 );
387 
388  item7->Add( item9, 0, wxALL, 5 );
389 
390  item0->Add( item7, 0, wxGROW, 5 );
391 
392  if (set_sizer)
393  {
394  parent->SetSizer( item0 );
395  if (call_fit)
396  item0->SetSizeHints( parent );
397  }
398 
399  return item0;
400 }

◆ onActivateAS()

void AddressSpacesDialog::onActivateAS ( wxListEvent &  event)
private

Handles left mouse button double click on the address space list.

Opens the clicked address space in an AddressSpaceDialog.

Definition at line 233 of file AddressSpacesDialog.cc.

233  {
234  wxCommandEvent dummy;
235  onEdit(dummy);
236 }

References dummy.

◆ onAdd()

void AddressSpacesDialog::onAdd ( wxCommandEvent &  event)
private

Creates and shows an address space dialog with default values set for adding an address space.

Definition at line 194 of file AddressSpacesDialog.cc.

194  {
195 
196  // Generate name for the new AS.
199  int i = 1;
200  string newName = ProDeConstants::COMP_NEW_NAME_PREFIX_AS +
202  while (navigator.hasItem(newName)) {
205  i++;
206  }
207 
208  AddressSpace* newAS =
209  new AddressSpace(newName,
213  *machine_);
214 
215  AddressSpaceDialog dialog(this, machine_, newAS);
216 
217  if (dialog.ShowModal() == wxID_OK) {
218  updateASList();
219  } else {
220  // The dialog was cancelled.
221  delete newAS;
222  }
223 }

References ProDeConstants::COMP_NEW_NAME_PREFIX_AS, ModelConstants::DEFAULT_AS_MAU_WIDTH, ModelConstants::DEFAULT_AS_MAX_ADDRESS, ModelConstants::DEFAULT_AS_MIN_ADDRESS, TTAMachine::Machine::Navigator< ComponentType >::hasItem(), and Conversion::toString().

Here is the call graph for this function:

◆ onASRightClick()

void AddressSpacesDialog::onASRightClick ( wxListEvent &  event)
private

Opens a pop-up menu when right mouse button is pressed on the list.

Parameters
eventInformation about right mouse click event.

Definition at line 320 of file AddressSpacesDialog.cc.

320  {
321 
322  asList_->SetItemState(event.GetIndex(), wxLIST_STATE_SELECTED,
323  wxLIST_STATE_SELECTED);
324 
325  wxMenu* contextMenu = new wxMenu();
326 
328  format button = prodeTexts->text(
330  contextMenu->Append(
331  ID_EDIT, WxConversion::toWxString(button.str()));
332  button = prodeTexts->text(
334  contextMenu->Append(
335  ID_DELETE, WxConversion::toWxString(button.str()));
336  asList_->PopupMenu(contextMenu, event.GetPoint());
337 }

References ProDeTextGenerator::instance(), Texts::TextGenerator::text(), WxConversion::toWxString(), ProDeTextGenerator::TXT_LABEL_BUTTON_DELETE, and ProDeTextGenerator::TXT_LABEL_BUTTON_EDIT.

Here is the call graph for this function:

◆ onASSelection()

void AddressSpacesDialog::onASSelection ( wxListEvent &  event)
private

Disables and enables Edit and Delete buttons under the address space list.

If an address space is selected, buttons are enabled. If no address space is selected the buttons will be disabled.

Definition at line 280 of file AddressSpacesDialog.cc.

280  {
281  if (asList_->GetSelectedItemCount() != 1) {
282  FindWindow(ID_DELETE)->Disable();
283  FindWindow(ID_EDIT)->Disable();
284  return;
285  }
286  FindWindow(ID_DELETE)->Enable();
287  FindWindow(ID_EDIT)->Enable();
288 }

◆ onDelete()

void AddressSpacesDialog::onDelete ( wxCommandEvent &  event)
private

Handles the 'Delete' button event.

Deletes the selected address space.

Definition at line 267 of file AddressSpacesDialog.cc.

267  {
268  delete selectedAS();
269  updateASList();
270 }

◆ onEdit()

void AddressSpacesDialog::onEdit ( wxCommandEvent &  event)
private

Handles the 'Edit' button event.

Opens an AddressSpaceDialog with the selected address space's attributes set.

Definition at line 246 of file AddressSpacesDialog.cc.

246  {
247 
248  AddressSpace* selected = selectedAS();
249  if (selected == NULL) {
250  // No address space selected.
251  return;
252  }
253 
254  AddressSpaceDialog dialog(this, machine_, selectedAS());
255 
256  dialog.ShowModal();
257  updateASList();
258 }

◆ selectedAS()

AddressSpace * AddressSpacesDialog::selectedAS ( )
private

Returns pointer to the AddressSpace, which is selected on the list.

Returns
The selected address space, or NULL if no address space is selected.

Definition at line 166 of file AddressSpacesDialog.cc.

166  {
167 
168  long item = -1;
169  item = asList_->GetNextItem(
170  item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
171 
172  if (item == -1) {
173  return NULL;
174  }
175 
176  string asName = WxConversion::toString(asList_->GetItemText(item));
179 
180  if (!navigator.hasItem(asName)) {
181  return NULL;
182  }
183 
184  return navigator.item(asName);
185 
186 }

References TTAMachine::Machine::Navigator< ComponentType >::hasItem(), TTAMachine::Machine::Navigator< ComponentType >::item(), and WxConversion::toString().

Here is the call graph for this function:

◆ setTexts()

void AddressSpacesDialog::setTexts ( )
private

Sets texts for widgets.

Definition at line 112 of file AddressSpacesDialog.cc.

112  {
115 
116  // Dialog title
117  format fmt = prodeTexts->text(
119  SetTitle(WxConversion::toWxString(fmt.str()));
120 
121  // buttons
122  WidgetTools::setLabel(generator, FindWindow(wxID_OK),
124 
125  WidgetTools::setLabel(generator, FindWindow(wxID_CANCEL),
127 
130 
133 
136 
139 
140  // Create address space list column.
141  wxListCtrl* portList =
142  dynamic_cast<wxListCtrl*>(FindWindow(ID_LIST));
143  fmt = prodeTexts->text(ProDeTextGenerator::TXT_COLUMN_NAME);
144  portList->InsertColumn(0, WxConversion::toWxString(fmt.str()),
145  wxLIST_FORMAT_LEFT, 100);
146  fmt = prodeTexts->text(ProDeTextGenerator::TXT_COLUMN_MAU);
147  portList->InsertColumn(1, WxConversion::toWxString(fmt.str()),
148  wxLIST_FORMAT_LEFT, 40);
150  portList->InsertColumn(2, WxConversion::toWxString(fmt.str()),
151  wxLIST_FORMAT_LEFT, 90);
153  portList->InsertColumn(3, WxConversion::toWxString(fmt.str()),
154  wxLIST_FORMAT_LEFT, 90);
156  portList->InsertColumn(4, WxConversion::toWxString(fmt.str()),
157  wxLIST_FORMAT_LEFT, 80);
158 }

References GUITextGenerator::instance(), ProDeTextGenerator::instance(), WidgetTools::setLabel(), Texts::TextGenerator::text(), WxConversion::toWxString(), ProDeTextGenerator::TXT_ADDRESS_SPACES_DIALOG_TITLE, GUITextGenerator::TXT_BUTTON_ADD_DIALOG, GUITextGenerator::TXT_BUTTON_CANCEL, GUITextGenerator::TXT_BUTTON_DELETE, GUITextGenerator::TXT_BUTTON_EDIT_DIALOG, GUITextGenerator::TXT_BUTTON_HELP, GUITextGenerator::TXT_BUTTON_OK, ProDeTextGenerator::TXT_COLUMN_BIT_WIDTH, ProDeTextGenerator::TXT_COLUMN_MAU, ProDeTextGenerator::TXT_COLUMN_MAX_ADDRESS, ProDeTextGenerator::TXT_COLUMN_MIN_ADDRESS, and ProDeTextGenerator::TXT_COLUMN_NAME.

Here is the call graph for this function:

◆ updateASList()

void AddressSpacesDialog::updateASList ( )
private

Updates the address space list.

Definition at line 295 of file AddressSpacesDialog.cc.

295  {
296 
297  Machine::AddressSpaceNavigator asNavigator =
299 
300  asList_->DeleteAllItems();
301 
302  for (int i = 0; i < asNavigator.count(); i++) {
303  AddressSpace* as = asNavigator.item(i);
304  int bitWidth = MathTools::requiredBits(as->end());
305  asList_->InsertItem(i, WxConversion::toWxString(as->name()));
306  asList_->SetItem(i, 1, WxConversion::toWxString(as->width()));
307  asList_->SetItem(i, 2, WxConversion::toWxString(as->start()));
308  asList_->SetItem(i, 3, WxConversion::toWxString(as->end()));
309  asList_->SetItem(i, 4, WxConversion::toWxString(bitWidth));
310  }
311 }

References TTAMachine::Machine::Navigator< ComponentType >::count(), TTAMachine::AddressSpace::end(), TTAMachine::Machine::Navigator< ComponentType >::item(), TTAMachine::Component::name(), MathTools::requiredBits(), TTAMachine::AddressSpace::start(), WxConversion::toWxString(), and TTAMachine::AddressSpace::width().

Here is the call graph for this function:

Member Data Documentation

◆ asList_

wxListCtrl* AddressSpacesDialog::asList_
private

List control for listing the address spaces.

Definition at line 68 of file AddressSpacesDialog.hh.

◆ machine_

TTAMachine::Machine* AddressSpacesDialog::machine_
private

Machine containing the address spaces to list.

Definition at line 66 of file AddressSpacesDialog.hh.


The documentation for this class was generated from the following files:
AddressSpacesDialog::ID_LIST
@ ID_LIST
Definition: AddressSpacesDialog.hh:76
AddressSpacesDialog::ID_DELETE
@ ID_DELETE
Definition: AddressSpacesDialog.hh:75
WxConversion::toWxString
static wxString toWxString(const std::string &source)
TTAMachine::Component::name
virtual TCEString name() const
Definition: MachinePart.cc:125
ProDeTextGenerator::TXT_LABEL_BUTTON_DELETE
@ TXT_LABEL_BUTTON_DELETE
Label for &Delete button.
Definition: ProDeTextGenerator.hh:95
ModelConstants::DEFAULT_AS_MAU_WIDTH
static const int DEFAULT_AS_MAU_WIDTH
Default address space width.
Definition: ModelConstants.hh:66
machine
TTAMachine::Machine * machine
the architecture definition of the estimated processor
Definition: EstimatorCmdLineUI.cc:59
AddressSpacesDialog::setTexts
void setTexts()
Definition: AddressSpacesDialog.cc:112
TTAMachine::AddressSpace
Definition: AddressSpace.hh:51
WidgetTools::setLabel
static void setLabel(Texts::TextGenerator *generator, wxWindow *widget, int textID)
Definition: WidgetTools.cc:92
ProDeConstants::COMP_NEW_NAME_PREFIX_AS
static const std::string COMP_NEW_NAME_PREFIX_AS
Prefix for new address space names.
Definition: ProDeConstants.hh:379
GUITextGenerator::instance
static GUITextGenerator * instance()
Definition: GUITextGenerator.cc:67
GUITextGenerator
Definition: GUITextGenerator.hh:46
GUITextGenerator::TXT_BUTTON_HELP
@ TXT_BUTTON_HELP
Label for help button.
Definition: GUITextGenerator.hh:60
FindWindow
Definition: FindWindow.hh:49
ModelConstants::DEFAULT_AS_MIN_ADDRESS
static const int DEFAULT_AS_MIN_ADDRESS
Default address space min address.
Definition: ModelConstants.hh:68
AddressSpacesDialog::machine_
TTAMachine::Machine * machine_
Machine containing the address spaces to list.
Definition: AddressSpacesDialog.hh:66
TTAMachine::Machine::Navigator::count
int count() const
Texts::TextGenerator::text
virtual boost::format text(int textId)
Definition: TextGenerator.cc:94
AddressSpaceDialog
Definition: AddressSpaceDialog.hh:50
AddressSpacesDialog::ID_EDIT
@ ID_EDIT
Definition: AddressSpacesDialog.hh:73
Conversion::toString
static std::string toString(const T &source)
ProDeTextGenerator::TXT_LABEL_BUTTON_EDIT
@ TXT_LABEL_BUTTON_EDIT
Label for &Edit... button.
Definition: ProDeTextGenerator.hh:96
ProDeTextGenerator
Definition: ProDeTextGenerator.hh:49
ProDeTextGenerator::TXT_COLUMN_MIN_ADDRESS
@ TXT_COLUMN_MIN_ADDRESS
Label for min-address column.
Definition: ProDeTextGenerator.hh:124
ModelConstants::DEFAULT_AS_MAX_ADDRESS
static const int DEFAULT_AS_MAX_ADDRESS
Default address space max address.
Definition: ModelConstants.hh:70
GUITextGenerator::TXT_BUTTON_CANCEL
@ TXT_BUTTON_CANCEL
Label for cancel button.
Definition: GUITextGenerator.hh:55
AddressSpacesDialog::ID_LINE
@ ID_LINE
Definition: AddressSpacesDialog.hh:77
ProDeTextGenerator::TXT_COLUMN_BIT_WIDTH
@ TXT_COLUMN_BIT_WIDTH
Label for bit width column in a list.
Definition: ProDeTextGenerator.hh:111
ProDeTextGenerator::TXT_ADDRESS_SPACES_DIALOG_TITLE
@ TXT_ADDRESS_SPACES_DIALOG_TITLE
Address spaces dialog title.
Definition: ProDeTextGenerator.hh:210
dummy
SimValue dummy(32)
a dummy simvalue which is given for operands that are not bound
TTAMachine::Machine::Navigator::hasItem
bool hasItem(const std::string &name) const
ProDeTextGenerator::TXT_COLUMN_MAX_ADDRESS
@ TXT_COLUMN_MAX_ADDRESS
Label for max-address column.
Definition: ProDeTextGenerator.hh:125
MathTools::requiredBits
static int requiredBits(unsigned long int number)
TTAMachine::Machine::addressSpaceNavigator
virtual AddressSpaceNavigator addressSpaceNavigator() const
Definition: Machine.cc:392
GUITextGenerator::TXT_BUTTON_DELETE
@ TXT_BUTTON_DELETE
Label for delete button.
Definition: GUITextGenerator.hh:56
AddressSpacesDialog::asList_
wxListCtrl * asList_
List control for listing the address spaces.
Definition: AddressSpacesDialog.hh:68
TTAMachine::AddressSpace::width
virtual int width() const
Definition: AddressSpace.cc:155
ProDeTextGenerator::instance
static ProDeTextGenerator * instance()
Definition: ProDeTextGenerator.cc:382
AddressSpacesDialog::selectedAS
TTAMachine::AddressSpace * selectedAS()
Definition: AddressSpacesDialog.cc:166
GUITextGenerator::TXT_BUTTON_ADD_DIALOG
@ TXT_BUTTON_ADD_DIALOG
Label for add button (with trailing ...).
Definition: GUITextGenerator.hh:54
GUITextGenerator::TXT_BUTTON_EDIT_DIALOG
@ TXT_BUTTON_EDIT_DIALOG
Label for edit button (with trailing ...).
Definition: GUITextGenerator.hh:58
ProDeTextGenerator::TXT_COLUMN_MAU
@ TXT_COLUMN_MAU
Label for MAU column in a list.
Definition: ProDeTextGenerator.hh:110
AddressSpacesDialog::ID_ADD
@ ID_ADD
Definition: AddressSpacesDialog.hh:72
TTAMachine::Machine::Navigator::item
ComponentType * item(int index) const
AddressSpacesDialog::ID_HELP
@ ID_HELP
Definition: AddressSpacesDialog.hh:74
WxConversion::toString
static std::string toString(const wxString &source)
TTAMachine::AddressSpace::start
virtual ULongWord start() const
Definition: AddressSpace.cc:166
ProDeTextGenerator::TXT_COLUMN_NAME
@ TXT_COLUMN_NAME
Label for name column in a list.
Definition: ProDeTextGenerator.hh:105
TTAMachine::Machine::Navigator
Definition: Machine.hh:186
TTAMachine::AddressSpace::end
virtual ULongWord end() const
Definition: AddressSpace.cc:177
AddressSpacesDialog::updateASList
void updateASList()
Definition: AddressSpacesDialog.cc:295
AddressSpacesDialog::onEdit
void onEdit(wxCommandEvent &event)
Definition: AddressSpacesDialog.cc:246
AddressSpacesDialog::createContents
wxSizer * createContents(wxWindow *parent, bool call_fit, bool set_sizer)
Definition: AddressSpacesDialog.cc:352
GUITextGenerator::TXT_BUTTON_OK
@ TXT_BUTTON_OK
Label for OK button.
Definition: GUITextGenerator.hh:59