OpenASIP  2.0
FUArchitectureDialog.cc
Go to the documentation of this file.
1 /*
2  Copyright (c) 2002-2009 Tampere University.
3 
4  This file is part of TTA-Based Codesign Environment (TCE).
5 
6  Permission is hereby granted, free of charge, to any person obtaining a
7  copy of this software and associated documentation files (the "Software"),
8  to deal in the Software without restriction, including without limitation
9  the rights to use, copy, modify, merge, publish, distribute, sublicense,
10  and/or sell copies of the Software, and to permit persons to whom the
11  Software is furnished to do so, subject to the following conditions:
12 
13  The above copyright notice and this permission notice shall be included in
14  all copies or substantial portions of the Software.
15 
16  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19  THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22  DEALINGS IN THE SOFTWARE.
23  */
24 /**
25  * @file FUArchParamatersDialog.cc
26  *
27  * Implementation of FUArchitectureDialog class.
28  *
29  * @author Veli-Pekka Jääskeläinen 2006 (vjaaskel-no.spam-cs.tut.fi)
30  * @note rating: red
31  */
32 
33 #include <wx/statline.h>
34 #include "FUArchitectureDialog.hh"
35 #include "FUArchitecture.hh"
36 #include "FunctionUnit.hh"
37 #include "FUPort.hh"
38 #include "WxConversion.hh"
39 
40 BEGIN_EVENT_TABLE(FUArchitectureDialog, wxDialog)
43 
44 /**
45  * The Constructor.
46  *
47  * @param parent Parent window of the dialog.
48  * @param id Window identifier for the dialog.
49  * @param fu Function unit to parametrize.
50  */
52  wxWindow* parent, wxWindowID id, HDB::FUArchitecture& arch) :
53  wxDialog(parent, id, _T("Function unit architecture.")),
54  arch_(arch) {
55 
56  createContents(this, true, true);
57 
58 
59  paramWidthList_ =
60  dynamic_cast<wxCheckListBox*>(FindWindow(ID_PARAM_WIDTH_LIST));
61  guardSupportList_ =
62  dynamic_cast<wxCheckListBox*>(FindWindow(ID_GUARD_SUPPORT_LIST));
63 
64  update();
65 }
66 
67 /**
68  * The Destructor.
69  */
71 }
72 
73 
74 /**
75  * Updates the dialog list widgets.
76  */
77 void
79  paramWidthList_->Clear();
80  guardSupportList_->Clear();
82  for (int i = 0; i < fu.portCount(); i++) {
83  std::string port = fu.port(i)->name();
86  if (arch_.hasParameterizedWidth(port)) {
87  paramWidthList_->Check(i);
88  }
89  if (arch_.hasGuardSupport(port)) {
90  guardSupportList_->Check(i);
91  }
92  }
93 }
94 
95 /**
96  * Event handler for the dialog OK-button.
97  */
98 void
99 FUArchitectureDialog::onOK(wxCommandEvent&) {
101  for (int i = 0; i < fu.portCount(); i++) {
102  std::string port = fu.port(i)->name();
103  if (paramWidthList_->IsChecked(i)) {
105  }
106  if (guardSupportList_->IsChecked(i)) {
107  arch_.setGuardSupport(port);
108  }
109  }
110 
111  EndModal(wxID_OK);
112 }
113 
114 /**
115  * Creates the dialog widgets.
116  */
117 wxSizer*
119  wxWindow *parent, bool call_fit, bool set_sizer) {
120 
121  wxBoxSizer *item0 = new wxBoxSizer( wxVERTICAL );
122 
123  wxBoxSizer *item1 = new wxBoxSizer( wxHORIZONTAL );
124 
125  wxStaticBox *item3 = new wxStaticBox( parent, -1, wxT("Parametrized width:") );
126  wxStaticBoxSizer *item2 = new wxStaticBoxSizer( item3, wxVERTICAL );
127 
128  wxWindow *item4 = new wxCheckListBox(parent, ID_PARAM_WIDTH_LIST, wxDefaultPosition, wxSize(200, 240));
129  wxASSERT( item4 );
130  item2->Add( item4, 0, wxALIGN_CENTER|wxALL, 5 );
131 
132  item1->Add( item2, 0, wxALIGN_CENTER|wxALL, 5 );
133 
134  wxStaticBox *item6 = new wxStaticBox( parent, -1, wxT("Guard support:") );
135  wxStaticBoxSizer *item5 = new wxStaticBoxSizer( item6, wxVERTICAL );
136 
137  wxWindow *item7 = new wxCheckListBox(parent, ID_GUARD_SUPPORT_LIST, wxDefaultPosition, wxSize(200, 240));
138  wxASSERT( item7 );
139  item5->Add( item7, 0, wxALIGN_CENTER|wxALL, 5 );
140 
141  item1->Add( item5, 0, wxALIGN_CENTER|wxALL, 5 );
142 
143  item0->Add( item1, 0, wxALIGN_CENTER|wxALL, 5 );
144 
145  wxStaticLine *item8 = new wxStaticLine( parent, ID_LINE, wxDefaultPosition, wxSize(20,-1), wxLI_HORIZONTAL );
146  item0->Add( item8, 0, wxGROW|wxALL, 5 );
147 
148  wxBoxSizer *item9 = new wxBoxSizer( wxHORIZONTAL );
149 
150  wxButton *item10 = new wxButton( parent, wxID_OK, wxT("&OK"), wxDefaultPosition, wxDefaultSize, 0 );
151  item9->Add( item10, 0, wxALIGN_CENTER|wxALL, 5 );
152 
153  wxButton *item11 = new wxButton( parent, wxID_CANCEL, wxT("&Cancel"), wxDefaultPosition, wxDefaultSize, 0 );
154  item9->Add( item11, 0, wxALIGN_CENTER|wxALL, 5 );
155 
156  item0->Add( item9, 0, wxALIGN_CENTER|wxALL, 5 );
157 
158  if (set_sizer)
159  {
160  parent->SetSizer( item0 );
161  if (call_fit)
162  item0->SetSizeHints( parent );
163  }
164 
165  return item0;
166 }
FUArchitectureDialog::ID_GUARD_SUPPORT_LIST
@ ID_GUARD_SUPPORT_LIST
Definition: FUArchitectureDialog.hh:60
WxConversion::toWxString
static wxString toWxString(const std::string &source)
HDB::FUArchitecture::hasParameterizedWidth
bool hasParameterizedWidth(const std::string &port) const
Definition: FUArchitecture.cc:86
HDB
Definition: CostDatabase.hh:49
FUArchitecture.hh
FUArchitectureDialog::ID_LINE
@ ID_LINE
Definition: FUArchitectureDialog.hh:61
HDB::FUArchitecture::architecture
TTAMachine::FunctionUnit & architecture() const
Definition: FUArchitecture.cc:131
FUArchitectureDialog.hh
TTAMachine::FunctionUnit::port
virtual BaseFUPort * port(const std::string &name) const
Definition: FunctionUnit.cc:145
FindWindow
Definition: FindWindow.hh:49
FUArchitectureDialog::paramWidthList_
wxCheckListBox * paramWidthList_
Definition: FUArchitectureDialog.hh:66
TTAMachine::FunctionUnit
Definition: FunctionUnit.hh:55
HDB::FUArchitecture::setParameterizedWidth
void setParameterizedWidth(const std::string &port)
Definition: FUArchitecture.cc:97
HDB::FUArchitecture::hasGuardSupport
bool hasGuardSupport(const std::string &port) const
Definition: FUArchitecture.cc:109
FUArchitectureDialog::arch_
HDB::FUArchitecture & arch_
Definition: FUArchitectureDialog.hh:64
FUArchitectureDialog::guardSupportList_
wxCheckListBox * guardSupportList_
Definition: FUArchitectureDialog.hh:67
FUArchitectureDialog::onOK
void onOK(wxCommandEvent &event)
Definition: FUArchitectureDialog.cc:99
HDB::FUArchitecture::setGuardSupport
void setGuardSupport(const std::string &port)
Definition: FUArchitecture.cc:120
TTAMachine::Unit::portCount
virtual int portCount() const
Definition: Unit.cc:135
FUArchitectureDialog
Definition: FUArchitectureDialog.hh:46
FUArchitectureDialog::createContents
wxSizer * createContents(wxWindow *parent, bool call_fit, bool set_sizer)
Definition: FUArchitectureDialog.cc:118
FUArchitectureDialog::~FUArchitectureDialog
virtual ~FUArchitectureDialog()
Definition: FUArchitectureDialog.cc:70
EVT_BUTTON
EVT_BUTTON(ID_EDIT_ARCH_PORT, FUImplementationDialog::onEditArchitecturePort) EVT_BUTTON(ID_ADD_EXTERNAL_PORT
TTAMachine::Port::name
virtual std::string name() const
Definition: Port.cc:141
FUPort.hh
WxConversion.hh
FUArchitectureDialog::ID_PARAM_WIDTH_LIST
@ ID_PARAM_WIDTH_LIST
Definition: FUArchitectureDialog.hh:59
END_EVENT_TABLE
END_EVENT_TABLE() using namespace IDF
FUArchitectureDialog::update
void update()
Definition: FUArchitectureDialog.cc:78
FunctionUnit.hh