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

#include <AddressSpaceDialog.hh>

Inheritance diagram for AddressSpaceDialog:
Inheritance graph
Collaboration diagram for AddressSpaceDialog:
Collaboration graph

Public Member Functions

 AddressSpaceDialog (wxWindow *parent, TTAMachine::Machine *machine, TTAMachine::AddressSpace *addressSpace)
 
 ~AddressSpaceDialog ()
 

Private Types

enum  {
  ID_NAME = 10000 , ID_WIDTH , ID_MIN_ADDRESS , ID_MAX_ADDRESS ,
  ID_BIT_WIDTH , ID_ID_LIST , ID_SPIN_ID , ID_ADD_ID ,
  ID_DELETE_ID , ID_RADIO_MIN_DEC , ID_RADIO_MIN_HEX , ID_RADIO_MAX_DEC ,
  ID_RADIO_MAX_HEX , ID_TEXT , ID_LINE , ID_HELP
}
 

Private Member Functions

wxSizer * createContents (wxWindow *parent, bool call_fit, bool set_sizer)
 
virtual bool TransferDataToWindow ()
 
void onName (wxCommandEvent &event)
 
void onOK (wxCommandEvent &event)
 
void onHelp (wxCommandEvent &event)
 
void onMinAddress (wxCommandEvent &event)
 
void onMinHex (wxCommandEvent &event)
 
void onMaxAddress (wxCommandEvent &event)
 
void onMaxHex (wxCommandEvent &event)
 
void onMinToDec (wxCommandEvent &event)
 
void onMinToHex (wxCommandEvent &event)
 
void onMaxToDec (wxCommandEvent &event)
 
void onMaxToHex (wxCommandEvent &event)
 
void onBitWidth (wxSpinEvent &event)
 
void onBitWidthText (wxCommandEvent &event)
 
void onAddId (wxCommandEvent &event)
 
void onDeleteId (wxCommandEvent &event)
 
void onSpinId (wxSpinEvent &event)
 
void onIdListSelection (wxListEvent &event)
 
void updateIdLists ()
 
bool isFreeId (unsigned id) const
 
void setTexts ()
 

Private Attributes

TTAMachine::Machinemachine_
 Machine containing all the address spaces.
 
TTAMachine::AddressSpaceas_
 Address space to modify with the dialog.
 
wxString name_
 Name of the address space.
 
int width_
 The bit width of the minimum addressable word.
 
wxString minAddress_
 The lowest address in the address space.
 
wxString maxAddress_
 The highest address in the address space.
 
NumberControlminControl_
 Widget for the lowest address hex value.
 
NumberControlmaxControl_
 Widget for the highest address hex value.
 
wxStaticBoxSizer * nameSizer_
 Boxsizer containing the name widget.
 
wxStaticBoxSizer * minAddressSizer_
 Boxsizer containing the min-address widget.
 
wxStaticBoxSizer * maxAddressSizer_
 Boxsizer containing the max-address widget.
 
wxStaticBoxSizer * widthSizer_
 Boxsizer containing the width widget.
 
wxSpinCtrl * bitWidthSpinCtrl_
 SpinCtrl containing the bit width of the max-address.
 
wxStaticBoxSizer * idSizer_
 Boxsizer containing the address space id widget.
 
wxListCtrl * idListCtrl_
 List control containing the address space ids.
 
wxSpinCtrl * idSpinCtrl_
 SpinCtrl containing an address space id.
 
std::set< unsigned > idNumbers_
 Container for unique id numbers.
 

Detailed Description

Dialog for editing address space properties.

Definition at line 50 of file AddressSpaceDialog.hh.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
private
Enumerator
ID_NAME 
ID_WIDTH 
ID_MIN_ADDRESS 
ID_MAX_ADDRESS 
ID_BIT_WIDTH 
ID_ID_LIST 
ID_SPIN_ID 
ID_ADD_ID 
ID_DELETE_ID 
ID_RADIO_MIN_DEC 
ID_RADIO_MIN_HEX 
ID_RADIO_MAX_DEC 
ID_RADIO_MAX_HEX 
ID_TEXT 
ID_LINE 
ID_HELP 

Definition at line 123 of file AddressSpaceDialog.hh.

123 {
124 ID_NAME = 10000,
125 ID_WIDTH,
129
132 ID_ADD_ID,
134
139 ID_TEXT,
140 ID_LINE,
141 ID_HELP
142 };

Constructor & Destructor Documentation

◆ AddressSpaceDialog()

AddressSpaceDialog::AddressSpaceDialog ( wxWindow *  parent,
TTAMachine::Machine machine,
TTAMachine::AddressSpace addressSpace 
)

The Constructor.

Parameters
parentParent window of the dialog.
addressSpaceThe address space to be modified with the dialog.

Definition at line 82 of file AddressSpaceDialog.cc.

85 :
86 wxDialog(parent, -1, _T(""), wxDefaultPosition),
88 as_(addressSpace),
89 name_(_T("")),
91 nameSizer_(NULL),
92 minAddressSizer_(NULL),
93 maxAddressSizer_(NULL),
94 widthSizer_(NULL) {
95
96 createContents(this, true, true);
97
98 // disable conditional buttons initially
99 FindWindow(wxID_OK)->Disable();
100 FindWindow(ID_DELETE_ID)->Disable();
101
102 // set validators for dialog controls
103 FindWindow(ID_NAME)->SetValidator(
104 wxTextValidator(wxFILTER_ASCII, &name_));
105 FindWindow(ID_WIDTH)->SetValidator(
106 wxGenericValidator(&width_));
107
108 // set min and max adress spin button ranges
111
112 bitWidthSpinCtrl_ = dynamic_cast<wxSpinCtrl*>(FindWindow(ID_BIT_WIDTH));
113
114 // set widget texts
115 setTexts();
116
118
119 FindWindow(ID_NAME)->SetFocus();
120}
TTAMachine::Machine * machine
the architecture definition of the estimated processor
wxString name_
Name of the address space.
wxStaticBoxSizer * maxAddressSizer_
Boxsizer containing the max-address widget.
wxSpinCtrl * bitWidthSpinCtrl_
SpinCtrl containing the bit width of the max-address.
NumberControl * maxControl_
Widget for the highest address hex value.
TTAMachine::Machine * machine_
Machine containing all the address spaces.
wxSizer * createContents(wxWindow *parent, bool call_fit, bool set_sizer)
virtual bool TransferDataToWindow()
wxStaticBoxSizer * nameSizer_
Boxsizer containing the name widget.
TTAMachine::AddressSpace * as_
Address space to modify with the dialog.
wxStaticBoxSizer * minAddressSizer_
Boxsizer containing the min-address widget.
NumberControl * minControl_
Widget for the lowest address hex value.
wxStaticBoxSizer * widthSizer_
Boxsizer containing the width widget.
int width_
The bit width of the minimum addressable word.
static const int DEFAULT_WIDTH
Default bit width.

◆ ~AddressSpaceDialog()

AddressSpaceDialog::~AddressSpaceDialog ( )

The Destructor.

Definition at line 126 of file AddressSpaceDialog.cc.

126 {
127}

Member Function Documentation

◆ createContents()

wxSizer * AddressSpaceDialog::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 494 of file AddressSpaceDialog.cc.

495 {
496
497 wxBoxSizer *item0 = new wxBoxSizer( wxVERTICAL );
498
499 wxFlexGridSizer *item1 = new wxFlexGridSizer( 2, 0, 0 );
500
501 wxStaticBox *item3 = new wxStaticBox( parent, -1, wxT("Name:") );
502 wxStaticBoxSizer *item2 = new wxStaticBoxSizer( item3, wxVERTICAL );
503 nameSizer_ = item2;
504
505 wxTextCtrl *item4 = new wxTextCtrl(parent, ID_NAME, wxT(""), wxDefaultPosition, wxSize(160,-1), 0);
506 item2->Add( item4, 0, wxGROW|wxALL, 5 );
507
508 item1->Add( item2, 0, wxGROW|wxALL, 5 );
509
510 wxStaticBox *item6 = new wxStaticBox( parent, -1, wxT("Min-Address") );
511 wxStaticBoxSizer *item5 = new wxStaticBoxSizer( item6, wxVERTICAL );
512 minAddressSizer_ = item5;
513
514 NumberControl* item7 = new NumberControl(parent, ID_MIN_ADDRESS, wxDefaultPosition, wxSize(180, -1), (NumberControl::MODE_UNSIGNED | NumberControl::MODE_HEXADECIMAL));
515 wxASSERT( item7 );
516 item5->Add( item7, 0, wxALIGN_CENTER|wxALL, 5 );
517
518 item1->Add( item5, 0, wxGROW|wxALL, 5 );
519
520 wxStaticBox *item9 = new wxStaticBox( parent, -1, wxT("Width:") );
521 wxStaticBoxSizer *item8 = new wxStaticBoxSizer( item9, wxVERTICAL );
522 widthSizer_ = item8;
523
524 wxSpinCtrl *item10 = new wxSpinCtrl(parent, ID_WIDTH, wxT("1"), wxDefaultPosition, wxSize(-1,-1), 0, 1, 10000, 1, wxT("Spin"));
525 item8->Add( item10, 0, wxGROW|wxALL, 5 );
526
527 item1->Add( item8, 0, wxGROW|wxALL, 5 );
528
529 wxStaticBox *item12 = new wxStaticBox( parent, -1, wxT("Max-Address") );
530 wxStaticBoxSizer *item11 = new wxStaticBoxSizer( item12, wxVERTICAL );
531 maxAddressSizer_ = item11;
532
533 NumberControl* item13 = new NumberControl(parent, ID_MAX_ADDRESS, wxDefaultPosition, wxSize(180, -1), (NumberControl::MODE_UNSIGNED | NumberControl::MODE_HEXADECIMAL));
534 wxASSERT( item13 );
535 item11->Add( item13, 0, wxALIGN_CENTER|wxALL, 5 );
536
537 wxBoxSizer *bitSizer = new wxBoxSizer(wxHORIZONTAL);
538
539 wxStaticText *bitText = new wxStaticText(parent, -1, wxT("Bits:"));
540 bitSizer->Add( bitText, 0, wxGROW|wxALL, 5 );
541
542 wxSpinCtrl *bitWidth = new wxSpinCtrl( parent, ID_BIT_WIDTH, wxT("1"), wxDefaultPosition, wxSize(-1,-1), 0, 1, 10000, 1);
543 bitSizer->Add( bitWidth, 0, wxGROW|wxALL, 5 );
544
545 item11->Add( bitSizer, 0, wxGROW|wxALL, 5 );
546
547 item1->Add( item11, 0, wxGROW|wxALL, 5 );
548
549 // address space id box
550 wxStaticBox *itemIdBox = new wxStaticBox(parent, -1, wxT("ID number:"));
551 wxStaticBoxSizer *itemIdSizer = new wxStaticBoxSizer(itemIdBox,
552 wxHORIZONTAL);
553 idSizer_ = itemIdSizer;
554
555 wxListCtrl *itemIdListCtrl = new wxListCtrl( parent, ID_ID_LIST,
556 wxDefaultPosition,
557 wxSize(100,120),
558 wxLC_REPORT|wxSUNKEN_BORDER );
559 idSizer_->Add( itemIdListCtrl, 0, wxALIGN_CENTER|wxALL, 5 );
560 idListCtrl_ = itemIdListCtrl;
561 idListCtrl_->InsertColumn(0, _("ID"));
562
563 wxBoxSizer *sizerOnRight = new wxBoxSizer(wxVERTICAL);
564
565 wxSpinCtrl *itemIdSpinCtrl = new wxSpinCtrl( parent, ID_SPIN_ID, wxT("0"), wxDefaultPosition, wxSize(-1,-1), 0, 0, 2147483647, 1, wxT("Spin") );
566 sizerOnRight->Add( itemIdSpinCtrl, 0, wxGROW|wxALL, 5 );
567 idSpinCtrl_ = itemIdSpinCtrl;
568
569 wxButton *addButton = new wxButton( parent, ID_ADD_ID, wxT("Add"), wxDefaultPosition, wxDefaultSize, 0 );
570 sizerOnRight->Add( addButton, 0, wxALIGN_CENTER|wxALL, 5 );
571
572 wxButton *deleteButton = new wxButton( parent, ID_DELETE_ID, wxT("Delete"), wxDefaultPosition, wxDefaultSize, 0 );
573 sizerOnRight->Add( deleteButton, 0, wxALIGN_CENTER|wxALL, 5 );
574
575 idSizer_->Add( sizerOnRight, 0, wxALIGN_CENTER|wxALL, 5 );
576 item1->Add( idSizer_, 0, wxGROW|wxALL, 5 );
577
578 assert (idSizer_ != NULL);
579 assert (idListCtrl_ != NULL);
580 assert (idSpinCtrl_ != NULL);
581 // end of address space id box
582
583 item0->Add( item1, 0, wxALIGN_CENTER|wxALL, 5 );
584
585 wxStaticLine *item14 = new wxStaticLine( parent, ID_LINE, wxDefaultPosition, wxSize(20,-1), wxLI_HORIZONTAL );
586 item0->Add( item14, 0, wxGROW|wxALL, 5 );
587
588 wxGridSizer *item15 = new wxGridSizer( 2, 0, 0 );
589
590 wxButton *item16 = new wxButton( parent, ID_HELP, wxT("&Help"), wxDefaultPosition, wxDefaultSize, 0 );
591 item15->Add( item16, 0, wxALL, 5 );
592
593 wxBoxSizer *item17 = new wxBoxSizer( wxHORIZONTAL );
594
595 wxButton *item18 = new wxButton( parent, wxID_OK, wxT("&OK"), wxDefaultPosition, wxDefaultSize, 0 );
596 item17->Add( item18, 0, wxALIGN_CENTER, 5 );
597
598 wxButton *item19 = new wxButton( parent, wxID_CANCEL, wxT("&Cancel"), wxDefaultPosition, wxDefaultSize, 0 );
599 item17->Add( item19, 0, wxALIGN_CENTER|wxALL, 5 );
600
601 item15->Add( item17, 0, wxALL, 5 );
602
603 item0->Add( item15, 0, wxGROW, 5 );
604
605 if (set_sizer)
606 {
607 parent->SetSizer( item0 );
608 if (call_fit)
609 item0->SetSizeHints( parent );
610 }
611
612 return item0;
613}
#define assert(condition)
wxListCtrl * idListCtrl_
List control containing the address space ids.
wxStaticBoxSizer * idSizer_
Boxsizer containing the address space id widget.
wxSpinCtrl * idSpinCtrl_
SpinCtrl containing an address space id.
static const long MODE_UNSIGNED
Style flag for unsigned integer mode availability.
static const long MODE_HEXADECIMAL
Style flag for hexadecimal mode availability.

References assert, ID_ADD_ID, ID_BIT_WIDTH, ID_DELETE_ID, ID_HELP, ID_ID_LIST, ID_LINE, ID_MAX_ADDRESS, ID_MIN_ADDRESS, ID_NAME, ID_SPIN_ID, ID_WIDTH, idListCtrl_, idSizer_, idSpinCtrl_, maxAddressSizer_, minAddressSizer_, NumberControl::MODE_HEXADECIMAL, NumberControl::MODE_UNSIGNED, nameSizer_, and widthSizer_.

◆ isFreeId()

bool AddressSpaceDialog::isFreeId ( unsigned  id) const
private

Checks if given id is already reserved by some address space

Parameters
idNumber that should be checked against reserved ids

Definition at line 450 of file AddressSpaceDialog.cc.

450 {
451 assert (machine_ != NULL);
452 std::set<unsigned>::iterator it;
453
454 // check id numbers reserved by this address space
455 it = idNumbers_.find(id);
456 if (it != idNumbers_.end()) {
457 return false;
458 }
459
462
463 // check other address spaces
464 for (int i = 0; i < asNavigator.count(); i++) {
465 AddressSpace* as = asNavigator.item(i);
466
467 // ignore address space owned by this because data might be old
468 if (as != as_) {
469 std::set<unsigned> ids = as->numericalIds();
470 it = ids.find(id);
471 if (it != ids.end()) {
472 return false;
473 }
474 }
475 }
476
477 // the id is free
478 return true;
479}
std::set< unsigned > idNumbers_
Container for unique id numbers.
std::set< unsigned > numericalIds() const
ComponentType * item(int index) const
virtual AddressSpaceNavigator addressSpaceNavigator() const
Definition Machine.cc:392

References TTAMachine::Machine::addressSpaceNavigator(), as_, assert, TTAMachine::Machine::Navigator< ComponentType >::count(), idNumbers_, TTAMachine::Machine::Navigator< ComponentType >::item(), machine_, and TTAMachine::AddressSpace::numericalIds().

Referenced by onAddId(), and onSpinId().

Here is the call graph for this function:

◆ onAddId()

void AddressSpaceDialog::onAddId ( wxCommandEvent &  event)
private

Adds a new id number for the address space.

Definition at line 366 of file AddressSpaceDialog.cc.

366 {
367 // current number in spin field
368 unsigned spinId = static_cast<unsigned>(idSpinCtrl_->GetValue());
369
370 // existing entry found from some address space
371 if (!isFreeId(spinId)) {
372 return;
373 }
374
375 // no conflict, make a new entry for the current value in the spin field
376 idNumbers_.insert(spinId);
378
379 // disable add button for added id number
380 FindWindow(ID_ADD_ID)->Disable();
381}
bool isFreeId(unsigned id) const

References ID_ADD_ID, idNumbers_, idSpinCtrl_, isFreeId(), and updateIdLists().

Here is the call graph for this function:

◆ onBitWidth()

void AddressSpaceDialog::onBitWidth ( wxSpinEvent &  event)
private

Reads the range from bitWidth spin-button and updates min- and max ranges.

Definition at line 351 of file AddressSpaceDialog.cc.

351 {
352
353 unsigned maxAddress = static_cast<unsigned>(
354 pow(2, bitWidthSpinCtrl_->GetValue()) - 1u);
355 maxControl_->setValue(maxAddress);
356
357 wxCommandEvent dummy;
360}
SimValue dummy(32)
a dummy simvalue which is given for operands that are not bound
void onMaxAddress(wxCommandEvent &event)
void onMinAddress(wxCommandEvent &event)
void setValue(const ULongWord value)

References bitWidthSpinCtrl_, dummy, maxControl_, onMaxAddress(), onMinAddress(), and NumberControl::setValue().

Here is the call graph for this function:

◆ onBitWidthText()

void AddressSpaceDialog::onBitWidthText ( wxCommandEvent &  event)
private

Reads the range from bitWidth spin-button and updates min- and max ranges.

Definition at line 342 of file AddressSpaceDialog.cc.

342 {
343 //wxSpinEvent dummy;
344 //onBitWidth(dummy);
345}

◆ onDeleteId()

void AddressSpaceDialog::onDeleteId ( wxCommandEvent &  event)
private

Deletes selected id number(s) from the address space.

Definition at line 387 of file AddressSpaceDialog.cc.

387 {
388 long itemIndex = -1;
389
390 // loop through all selected ids
391 for (int i = 0; i < idListCtrl_->GetSelectedItemCount(); ++i) {
392 itemIndex = idListCtrl_->GetNextItem(
393 itemIndex, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
394
395 // get numerical value of the id and erase it from the address space
396 if (itemIndex >= 0) {
397 wxString idText = idListCtrl_->GetItemText(itemIndex);
398 long id;
399 if (idText.ToLong(&id)) {
400 idNumbers_.erase(id);
401 }
402 }
403 }
404
406
407 wxSpinEvent dummy1;
408 onSpinId(dummy1);
409 wxListEvent dummy2;
410 onIdListSelection(dummy2);
411}
void onSpinId(wxSpinEvent &event)
void onIdListSelection(wxListEvent &event)

References idListCtrl_, idNumbers_, onIdListSelection(), onSpinId(), and updateIdLists().

Here is the call graph for this function:

◆ onHelp()

void AddressSpaceDialog::onHelp ( wxCommandEvent &  event)
private

◆ onIdListSelection()

void AddressSpaceDialog::onIdListSelection ( wxListEvent &  event)
private

Sets state of delete button depending on whether items are selected

Definition at line 436 of file AddressSpaceDialog.cc.

436 {
437 if (idListCtrl_->GetSelectedItemCount() < 1) {
438 FindWindow(ID_DELETE_ID)->Disable();
439 } else {
440 FindWindow(ID_DELETE_ID)->Enable();
441 }
442}

References ID_DELETE_ID, and idListCtrl_.

Referenced by onDeleteId().

◆ onMaxAddress()

void AddressSpaceDialog::onMaxAddress ( wxCommandEvent &  event)
private

Sets the range of the MaxAddress spin-button.

Definition at line 330 of file AddressSpaceDialog.cc.

330 {
333 }
335 bitWidthSpinCtrl_->SetValue(bitWidth);
336}
static int requiredBits(unsigned long int number)
unsigned int unsignedValue() const

References bitWidthSpinCtrl_, maxControl_, minControl_, MathTools::requiredBits(), NumberControl::setValue(), and NumberControl::unsignedValue().

Referenced by onBitWidth(), and TransferDataToWindow().

Here is the call graph for this function:

◆ onMaxHex()

void AddressSpaceDialog::onMaxHex ( wxCommandEvent &  event)
private

◆ onMaxToDec()

void AddressSpaceDialog::onMaxToDec ( wxCommandEvent &  event)
private

◆ onMaxToHex()

void AddressSpaceDialog::onMaxToHex ( wxCommandEvent &  event)
private

◆ onMinAddress()

void AddressSpaceDialog::onMinAddress ( wxCommandEvent &  event)
private

Sets the range of the MaxAddress spin-button.

Definition at line 319 of file AddressSpaceDialog.cc.

References maxControl_, minControl_, NumberControl::setValue(), and NumberControl::unsignedValue().

Referenced by onBitWidth(), and TransferDataToWindow().

Here is the call graph for this function:

◆ onMinHex()

void AddressSpaceDialog::onMinHex ( wxCommandEvent &  event)
private

◆ onMinToDec()

void AddressSpaceDialog::onMinToDec ( wxCommandEvent &  event)
private

◆ onMinToHex()

void AddressSpaceDialog::onMinToHex ( wxCommandEvent &  event)
private

◆ onName()

void AddressSpaceDialog::onName ( wxCommandEvent &  event)
private

Checks whether the name field is empty, and disables OK button of the dialog if it is.

Definition at line 302 of file AddressSpaceDialog.cc.

302 {
303 if (!TransferDataFromWindow()) {
304 assert(false);
305 }
306 wxString trimmedName = name_.Trim(false).Trim(true);
307 if (trimmedName == _T("")) {
308 FindWindow(wxID_OK)->Disable();
309 } else {
310 FindWindow(wxID_OK)->Enable();
311 }
312}

References assert, and name_.

◆ onOK()

void AddressSpaceDialog::onOK ( wxCommandEvent &  event)
private

Validates input in the controls, and updates the AddressSpace.

Definition at line 226 of file AddressSpaceDialog.cc.

226 {
227
228 if (!Validate()) {
229 return;
230 }
231
232 if (!TransferDataFromWindow()) {
233 return;
234 }
235
236 string trimmedName =
237 WxConversion::toString(name_.Trim(false).Trim(true));
238
239 // Check the name validity.
240 if (!MachineTester::isValidComponentName(trimmedName)) {
242 format message =
244 InformationDialog warning(
245 this, WxConversion::toWxString(message.str()));
246 warning.ShowModal();
247 return;
248 }
249
250 if (trimmedName != as_->name()) {
251
252 // Check that the new address space name is unique among
253 // all address spaces in the machine.
256 for (int i = 0; i < navigator.count(); i++) {
257 string asName = navigator.item(i)->name();
258 if (trimmedName == asName) {
259 ProDeTextGenerator* prodeTexts =
261 format message =
263 format an_as = prodeTexts->text(
265 format machine =
267 format as =
269 message % trimmedName % an_as.str() % machine.str() % as.str();
270 WarningDialog warning(
271 this, WxConversion::toWxString(message.str()));
272 warning.ShowModal();
273 return;
274 }
275 }
276 }
277
278 as_->setName(trimmedName);
280 unsigned int minAddr = minControl_->unsignedValue();
281 unsigned int maxAddr = maxControl_->unsignedValue();
282 as_->setAddressBounds(minAddr, maxAddr);
283
286 format message =
288 InformationDialog dialog(
289 this, WxConversion::toWxString(message.str()));
290 dialog.ShowModal();
291 }
292
293 EndModal(wxID_OK);
294}
static bool isValidComponentName(const std::string &name)
static ProDeTextGenerator * instance()
@ MSG_ERROR_SAME_NAME
Error: Same name exists.
@ MSG_ERROR_ILLEGAL_NAME
Error: Illegal component name.
@ COMP_MACHINE
Text for machine description.
@ MSG_ERROR_ID_EXISTS
Error: Conflicting addr. space ID.
@ COMP_ADDRESS_SPACE
Address space (w/o article).
@ COMP_AN_ADDRESS_SPACE
Address space (w/ article).
virtual void setAddressBounds(ULongWord start, ULongWord end)
virtual void setName(const std::string &name)
bool setNumericalIds(const std::set< unsigned > &ids)
virtual void setWidth(int width)
virtual Machine * machine() const
virtual TCEString name() const
virtual boost::format text(int textId)
static wxString toWxString(const std::string &source)
static std::string toString(const wxString &source)

References TTAMachine::Machine::addressSpaceNavigator(), as_, ProDeTextGenerator::COMP_ADDRESS_SPACE, ProDeTextGenerator::COMP_AN_ADDRESS_SPACE, ProDeTextGenerator::COMP_MACHINE, TTAMachine::Machine::Navigator< ComponentType >::count(), idNumbers_, ProDeTextGenerator::instance(), MachineTester::isValidComponentName(), TTAMachine::Machine::Navigator< ComponentType >::item(), TTAMachine::Component::machine(), machine, maxControl_, minControl_, ProDeTextGenerator::MSG_ERROR_ID_EXISTS, ProDeTextGenerator::MSG_ERROR_ILLEGAL_NAME, ProDeTextGenerator::MSG_ERROR_SAME_NAME, TTAMachine::Component::name(), name_, TTAMachine::AddressSpace::setAddressBounds(), TTAMachine::AddressSpace::setName(), TTAMachine::AddressSpace::setNumericalIds(), TTAMachine::AddressSpace::setWidth(), Texts::TextGenerator::text(), WxConversion::toString(), WxConversion::toWxString(), NumberControl::unsignedValue(), and width_.

Here is the call graph for this function:

◆ onSpinId()

void AddressSpaceDialog::onSpinId ( wxSpinEvent &  event)
private

Sets state of add button depending on whether the number in spin input already exists in some address space

Definition at line 418 of file AddressSpaceDialog.cc.

418 {
419 // current number in spin field
420 unsigned spinId = static_cast<unsigned>(idSpinCtrl_->GetValue());
421
422 // no conflict found, enable add button
423 if (isFreeId(spinId)) {
424 FindWindow(ID_ADD_ID)->Enable();
425 return;
426 }
427
428 // the number is already reserved, disable add button
429 FindWindow(ID_ADD_ID)->Disable();
430}

References ID_ADD_ID, idSpinCtrl_, and isFreeId().

Referenced by onDeleteId(), and TransferDataToWindow().

Here is the call graph for this function:

◆ setTexts()

void AddressSpaceDialog::setTexts ( )
private

Sets texts for widgets.

Definition at line 134 of file AddressSpaceDialog.cc.

134 {
137
138 // Dialog title
139 format fmt = prodeTexts->text(
141 SetTitle(WxConversion::toWxString(fmt.str()));
142
143 // buttons
144 WidgetTools::setLabel(generator, FindWindow(wxID_OK),
146
147 WidgetTools::setLabel(generator, FindWindow(wxID_CANCEL),
149
152
155
158
159 // box sizer label
160 fmt = prodeTexts->text(ProDeTextGenerator::TXT_LABEL_NAME);
162
163 fmt = prodeTexts->text(ProDeTextGenerator::TXT_LABEL_MAU);
165
168
171}
@ TXT_BUTTON_ADD_DIALOG
Label for add button (with trailing ...).
@ TXT_BUTTON_HELP
Label for help button.
@ TXT_BUTTON_DELETE
Label for delete button.
@ TXT_BUTTON_CANCEL
Label for cancel button.
@ TXT_BUTTON_OK
Label for OK button.
static GUITextGenerator * instance()
@ TXT_LABEL_NAME
Label for component name widget.
@ TXT_ADDRESS_SPACE_MIN_ADDRESS
Label for Min-Address box.
@ TXT_LABEL_MAU
Label for min. addressable unit.
@ TXT_ADDRESS_SPACE_DIALOG_TITLE
Address space dialog title.
@ TXT_ADDRESS_SPACE_MAX_ADDRESS
Label for Max-Address box.
static void setWidgetLabel(wxWindow *widget, std::string text)
static void setLabel(Texts::TextGenerator *generator, wxWindow *widget, int textID)

References ID_ADD_ID, ID_DELETE_ID, ID_HELP, GUITextGenerator::instance(), ProDeTextGenerator::instance(), maxAddressSizer_, minAddressSizer_, nameSizer_, WidgetTools::setLabel(), WidgetTools::setWidgetLabel(), Texts::TextGenerator::text(), WxConversion::toWxString(), ProDeTextGenerator::TXT_ADDRESS_SPACE_DIALOG_TITLE, ProDeTextGenerator::TXT_ADDRESS_SPACE_MAX_ADDRESS, ProDeTextGenerator::TXT_ADDRESS_SPACE_MIN_ADDRESS, GUITextGenerator::TXT_BUTTON_ADD_DIALOG, GUITextGenerator::TXT_BUTTON_CANCEL, GUITextGenerator::TXT_BUTTON_DELETE, GUITextGenerator::TXT_BUTTON_HELP, GUITextGenerator::TXT_BUTTON_OK, ProDeTextGenerator::TXT_LABEL_MAU, ProDeTextGenerator::TXT_LABEL_NAME, and widthSizer_.

Here is the call graph for this function:

◆ TransferDataToWindow()

bool AddressSpaceDialog::TransferDataToWindow ( )
privatevirtual

Transfers data from the AddressSpace object to the dialog widgets.

Returns
false, if an error occured in the transfer, true otherwise.

Definition at line 180 of file AddressSpaceDialog.cc.

180 {
181
183 width_ = as_->width();
184
187 //minControl_->setRange(0, as_->end() - 1);
188 //maxControl_->setRange(as_->start() + 1, 0xFFFFFFFF);
189
192
193 // wxWidgets GTK1 version seems to bug with spincontrol validators.
194 // The widget value has to be set manually.
195 dynamic_cast<wxSpinCtrl*>(FindWindow(ID_WIDTH))->SetValue(width_);
196
197 wxCommandEvent dummy;
200
201 wxSpinEvent dummySpin;
202 onSpinId(dummySpin);
203
204 return wxWindow::TransferDataToWindow();
205}
virtual ULongWord end() const
virtual int width() const
virtual ULongWord start() const

References as_, dummy, TTAMachine::AddressSpace::end(), ID_WIDTH, idNumbers_, maxControl_, minControl_, TTAMachine::Component::name(), name_, TTAMachine::AddressSpace::numericalIds(), onMaxAddress(), onMinAddress(), onSpinId(), NumberControl::setValue(), TTAMachine::AddressSpace::start(), WxConversion::toWxString(), updateIdLists(), TTAMachine::AddressSpace::width(), and width_.

Here is the call graph for this function:

◆ updateIdLists()

void AddressSpaceDialog::updateIdLists ( )
private

Updates the id lists.

Definition at line 211 of file AddressSpaceDialog.cc.

211 {
212 assert (idListCtrl_ != NULL);
213 idListCtrl_->DeleteAllItems();
214
215 for (std::set<unsigned>::iterator it = idNumbers_.begin();
216 it != idNumbers_.end(); ++it) {
217 idListCtrl_->InsertItem(
218 static_cast<long>(*it), WxConversion::toWxString(*it));
219 }
220}

References assert, idListCtrl_, idNumbers_, and WxConversion::toWxString().

Referenced by onAddId(), onDeleteId(), and TransferDataToWindow().

Here is the call graph for this function:

Member Data Documentation

◆ as_

TTAMachine::AddressSpace* AddressSpaceDialog::as_
private

Address space to modify with the dialog.

Definition at line 87 of file AddressSpaceDialog.hh.

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

◆ bitWidthSpinCtrl_

wxSpinCtrl* AddressSpaceDialog::bitWidthSpinCtrl_
private

SpinCtrl containing the bit width of the max-address.

Definition at line 110 of file AddressSpaceDialog.hh.

Referenced by onBitWidth(), and onMaxAddress().

◆ idListCtrl_

wxListCtrl* AddressSpaceDialog::idListCtrl_
private

List control containing the address space ids.

Definition at line 115 of file AddressSpaceDialog.hh.

Referenced by createContents(), onDeleteId(), onIdListSelection(), and updateIdLists().

◆ idNumbers_

std::set<unsigned> AddressSpaceDialog::idNumbers_
private

Container for unique id numbers.

Definition at line 120 of file AddressSpaceDialog.hh.

Referenced by isFreeId(), onAddId(), onDeleteId(), onOK(), TransferDataToWindow(), and updateIdLists().

◆ idSizer_

wxStaticBoxSizer* AddressSpaceDialog::idSizer_
private

Boxsizer containing the address space id widget.

Definition at line 113 of file AddressSpaceDialog.hh.

Referenced by createContents().

◆ idSpinCtrl_

wxSpinCtrl* AddressSpaceDialog::idSpinCtrl_
private

SpinCtrl containing an address space id.

Definition at line 117 of file AddressSpaceDialog.hh.

Referenced by createContents(), onAddId(), and onSpinId().

◆ machine_

TTAMachine::Machine* AddressSpaceDialog::machine_
private

Machine containing all the address spaces.

Definition at line 85 of file AddressSpaceDialog.hh.

Referenced by isFreeId().

◆ maxAddress_

wxString AddressSpaceDialog::maxAddress_
private

The highest address in the address space.

Definition at line 95 of file AddressSpaceDialog.hh.

◆ maxAddressSizer_

wxStaticBoxSizer* AddressSpaceDialog::maxAddressSizer_
private

Boxsizer containing the max-address widget.

Definition at line 106 of file AddressSpaceDialog.hh.

Referenced by createContents(), and setTexts().

◆ maxControl_

NumberControl* AddressSpaceDialog::maxControl_
private

Widget for the highest address hex value.

Definition at line 99 of file AddressSpaceDialog.hh.

Referenced by onBitWidth(), onMaxAddress(), onMinAddress(), onOK(), and TransferDataToWindow().

◆ minAddress_

wxString AddressSpaceDialog::minAddress_
private

The lowest address in the address space.

Definition at line 93 of file AddressSpaceDialog.hh.

◆ minAddressSizer_

wxStaticBoxSizer* AddressSpaceDialog::minAddressSizer_
private

Boxsizer containing the min-address widget.

Definition at line 104 of file AddressSpaceDialog.hh.

Referenced by createContents(), and setTexts().

◆ minControl_

NumberControl* AddressSpaceDialog::minControl_
private

Widget for the lowest address hex value.

Definition at line 97 of file AddressSpaceDialog.hh.

Referenced by onMaxAddress(), onMinAddress(), onOK(), and TransferDataToWindow().

◆ name_

wxString AddressSpaceDialog::name_
private

Name of the address space.

Definition at line 89 of file AddressSpaceDialog.hh.

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

◆ nameSizer_

wxStaticBoxSizer* AddressSpaceDialog::nameSizer_
private

Boxsizer containing the name widget.

Definition at line 102 of file AddressSpaceDialog.hh.

Referenced by createContents(), and setTexts().

◆ width_

int AddressSpaceDialog::width_
private

The bit width of the minimum addressable word.

Definition at line 91 of file AddressSpaceDialog.hh.

Referenced by onOK(), and TransferDataToWindow().

◆ widthSizer_

wxStaticBoxSizer* AddressSpaceDialog::widthSizer_
private

Boxsizer containing the width widget.

Definition at line 108 of file AddressSpaceDialog.hh.

Referenced by createContents(), and setTexts().


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