OpenASIP
2.0
src
procgen
HDBEditor
AddFUImplementationCmd.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 AddFUImplementationCmd.cc
26
*
27
* Implementation of AddFUImplementationCmd class.
28
*
29
* @author Veli-Pekka Jääskeläinen 2006 (vjaaskel-no.spam-cs.tut.fi)
30
* @note rating: red
31
*/
32
33
#include "
AddFUImplementationCmd.hh
"
34
#include "
WxConversion.hh
"
35
#include "
HDBEditorConstants.hh
"
36
#include "
HDBEditor.hh
"
37
#include "
HDBEditorMainFrame.hh
"
38
#include "
HDBBrowserWindow.hh
"
39
#include "
HDBManager.hh
"
40
#include "
FUImplementationDialog.hh
"
41
#include "
FUImplementation.hh
"
42
#include "
FUEntry.hh
"
43
#include "
FUArchitecture.hh
"
44
#include "
ErrorDialog.hh
"
45
#include "
FunctionUnit.hh
"
46
#include "
FUPort.hh
"
47
#include "
FUPortImplementation.hh
"
48
49
50
/**
51
* The Constructor.
52
*/
53
AddFUImplementationCmd::AddFUImplementationCmd
() :
54
GUICommand
(
HDBEditorConstants
::COMMAND_NAME_ADD_FU_IMPLEMENTATION, NULL) {
55
}
56
57
58
/**
59
* The Destructor.
60
*/
61
AddFUImplementationCmd::~AddFUImplementationCmd
() {
62
}
63
64
/**
65
* Executes the command.
66
*/
67
bool
68
AddFUImplementationCmd::Do
() {
69
70
HDB::HDBManager
* manager = wxGetApp().mainFrame().hdbManager();
71
if
(manager == NULL) {
72
return
false
;
73
}
74
75
HDBBrowserWindow
* browser = wxGetApp().mainFrame().browser();
76
77
HDB::FUImplementation
*
implementation
=
78
new
HDB::FUImplementation
(
""
,
""
,
""
,
""
,
""
,
""
);
79
80
HDB::FUEntry
* entry = NULL;
81
82
if
(browser->
isFUEntrySelected
()) {
83
entry = manager->
fuByEntryID
(browser->
selectedFUEntry
());
84
}
else
if
(browser->
isFUArchitectureSelected
()) {
85
int
id
= manager->
addFUEntry
();
86
manager->
setArchitectureForFU
(
id
, browser->
selectedFUArchitecture
());
87
entry = manager->
fuByEntryID
(
id
);
88
}
else
{
89
return
false
;
90
}
91
92
const
TTAMachine::FunctionUnit
& arch =
93
entry->
architecture
().
architecture
();
94
95
for
(
int
i = 0; i < arch.
portCount
(); i++) {
96
new
HDB::FUPortImplementation
(
97
""
, arch.
port
(i)->
name
(),
""
,
""
,
""
, *
implementation
);
98
}
99
100
FUImplementationDialog
dialog(
parentWindow
(), -1, *
implementation
, arch);
101
102
if
(dialog.ShowModal() == wxID_OK) {
103
try
{
104
entry->
setImplementation
(
implementation
);
105
int
id
= manager->
addFUImplementation
(*entry);
106
wxGetApp().mainFrame().update();
107
wxGetApp().mainFrame().browser()->selectFUImplementation(
id
);
108
}
catch
(
Exception
& e) {
109
wxString message = _T(
"Error:\n"
);
110
message.Append(
WxConversion::toWxString
(e.
errorMessage
()));
111
message.Append(_T(
"\n"
));
112
message.Append(
WxConversion::toWxString
(e.
lineNum
()));
113
message.Append(_T(
": "
));
114
message.Append(
WxConversion::toWxString
(e.
fileName
()));
115
ErrorDialog
dialog(
parentWindow
(), message);
116
dialog.ShowModal();
117
delete
entry;
118
delete
implementation
;
119
return
false
;
120
}
121
}
else
{
122
delete
implementation
;
123
}
124
delete
entry;
125
return
true
;
126
}
127
128
/**
129
* Returns name of the command icon file.
130
*
131
* @return Command icon file name.
132
*/
133
std::string
134
AddFUImplementationCmd::icon
()
const
{
135
return
""
;
136
}
137
138
/**
139
* Returns the command id.
140
*
141
* @return Command identifier.
142
*/
143
int
144
AddFUImplementationCmd::id
()
const
{
145
return
HDBEditorConstants::COMMAND_ADD_FU_IMPLEMENTATION
;
146
}
147
148
149
/**
150
* Creates a new instance of this command.
151
*
152
* @return Newly created instance of this command.
153
*/
154
AddFUImplementationCmd
*
155
AddFUImplementationCmd::create
()
const
{
156
return
new
AddFUImplementationCmd
();
157
}
158
159
160
/**
161
* Returns true if the command should be enabled in the tool/menubar.
162
*
163
* @return True if the command is enabled, false if not.
164
*/
165
bool
166
AddFUImplementationCmd::isEnabled
() {
167
HDB::HDBManager
* manager = wxGetApp().mainFrame().hdbManager();
168
169
if
(manager == NULL) {
170
return
false
;
171
}
172
173
HDBBrowserWindow
* browser = wxGetApp().mainFrame().browser();
174
175
if
(browser->
isFUArchitectureSelected
()) {
176
return
true
;
177
}
else
if
(browser->
isFUEntrySelected
()) {
178
HDB::FUEntry
* entry = manager->
fuByEntryID
(browser->
selectedFUEntry
());
179
if
(entry->
hasArchitecture
() && !entry->
hasImplementation
()) {
180
delete
entry;
181
return
true
;
182
}
183
delete
entry;
184
}
185
return
false
;
186
}
HDB::FUEntry
Definition:
FUEntry.hh:49
AddFUImplementationCmd::Do
virtual bool Do()
Definition:
AddFUImplementationCmd.cc:68
AddFUImplementationCmd::isEnabled
virtual bool isEnabled()
Definition:
AddFUImplementationCmd.cc:166
HDB::HDBManager::addFUImplementation
RowID addFUImplementation(const FUEntry &entry) const
Definition:
HDBManager.cc:1112
Exception::lineNum
int lineNum() const
WxConversion::toWxString
static wxString toWxString(const std::string &source)
HDBBrowserWindow.hh
HDBBrowserWindow
Definition:
HDBBrowserWindow.hh:59
HDBEditor.hh
implementation
IDF::MachineImplementation * implementation
the implementation definition of the estimated processor
Definition:
EstimatorCmdLineUI.cc:61
FUImplementationDialog
Definition:
FUImplementationDialog.hh:52
FUArchitecture.hh
HDB::FUPortImplementation
Definition:
FUPortImplementation.hh:46
HDBEditorConstants.hh
HDB::FUArchitecture::architecture
TTAMachine::FunctionUnit & architecture() const
Definition:
FUArchitecture.cc:131
TTAMachine::FunctionUnit::port
virtual BaseFUPort * port(const std::string &name) const
Definition:
FunctionUnit.cc:145
AddFUImplementationCmd::~AddFUImplementationCmd
virtual ~AddFUImplementationCmd()
Definition:
AddFUImplementationCmd.cc:61
FUPortImplementation.hh
AddFUImplementationCmd.hh
Exception::fileName
std::string fileName() const
AddFUImplementationCmd
Definition:
AddFUImplementationCmd.hh:41
TTAMachine::FunctionUnit
Definition:
FunctionUnit.hh:55
GUICommand
Definition:
GUICommand.hh:43
HDB::FUEntry::hasArchitecture
virtual bool hasArchitecture() const
Definition:
FUEntry.cc:117
ErrorDialog
Definition:
ErrorDialog.hh:42
FUImplementationDialog.hh
HDBBrowserWindow::isFUEntrySelected
bool isFUEntrySelected()
Definition:
HDBBrowserWindow.cc:387
ErrorDialog.hh
HDBEditorMainFrame.hh
HDBBrowserWindow::selectedFUArchitecture
RowID selectedFUArchitecture()
Definition:
HDBBrowserWindow.cc:466
AddFUImplementationCmd::id
virtual int id() const
Definition:
AddFUImplementationCmd.cc:144
HDBEditorConstants::COMMAND_ADD_FU_IMPLEMENTATION
@ COMMAND_ADD_FU_IMPLEMENTATION
Definition:
HDBEditorConstants.hh:51
HDB::FUEntry::architecture
FUArchitecture & architecture() const
Definition:
FUEntry.cc:129
FUEntry.hh
AddFUImplementationCmd::icon
virtual std::string icon() const
Definition:
AddFUImplementationCmd.cc:134
AddFUImplementationCmd::create
virtual AddFUImplementationCmd * create() const
Definition:
AddFUImplementationCmd.cc:155
HDB::HDBManager
Definition:
HDBManager.hh:82
Exception
Definition:
Exception.hh:54
FUImplementation.hh
TTAMachine::Unit::portCount
virtual int portCount() const
Definition:
Unit.cc:135
Exception::errorMessage
std::string errorMessage() const
Definition:
Exception.cc:123
HDB::HDBManager::addFUEntry
RowID addFUEntry() const
Definition:
HDBManager.cc:1014
HDB::FUImplementation
Definition:
FUImplementation.hh:53
TTAMachine::Port::name
virtual std::string name() const
Definition:
Port.cc:141
FUPort.hh
HDBEditorConstants
Definition:
HDBEditorConstants.hh:42
HDB::FUEntry::setImplementation
void setImplementation(FUImplementation *implementation)
Definition:
FUEntry.cc:103
HDBBrowserWindow::isFUArchitectureSelected
bool isFUArchitectureSelected()
Definition:
HDBBrowserWindow.cc:343
WxConversion.hh
AddFUImplementationCmd::AddFUImplementationCmd
AddFUImplementationCmd()
Definition:
AddFUImplementationCmd.cc:53
HDB::FUEntry::hasImplementation
virtual bool hasImplementation() const
Definition:
FUEntry.cc:74
HDBManager.hh
HDB::HDBManager::fuByEntryID
FUEntry * fuByEntryID(RowID id) const
Definition:
HDBManager.cc:2828
GUICommand::parentWindow
wxWindow * parentWindow() const
Definition:
GUICommand.cc:75
HDBBrowserWindow::selectedFUEntry
RowID selectedFUEntry()
Definition:
HDBBrowserWindow.cc:533
FunctionUnit.hh
HDB::HDBManager::setArchitectureForFU
void setArchitectureForFU(RowID fuID, RowID archID) const
Definition:
HDBManager.cc:1401
Generated by
1.8.17