OpenASIP
2.2
Loading...
Searching...
No Matches
src
procgen
HDBEditor
AddRFImplementationCmd.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 AddRFImplementationCmd.cc
26
*
27
* Implementation of AddRFImplementationCmd class.
28
*
29
* @author Veli-Pekka Jääskeläinen 2006 (vjaaskel-no.spam-cs.tut.fi)
30
* @note rating: red
31
*/
32
33
#include "
AddRFImplementationCmd.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 "
RFImplementationDialog.hh
"
41
#include "
RFImplementation.hh
"
42
#include "
RFEntry.hh
"
43
#include "
ErrorDialog.hh
"
44
45
46
/**
47
* The Constructor.
48
*/
49
AddRFImplementationCmd::AddRFImplementationCmd
() :
50
GUICommand
(
HDBEditorConstants
::COMMAND_NAME_ADD_RF_IMPLEMENTATION, NULL) {
51
}
52
53
54
/**
55
* The Destructor.
56
*/
57
AddRFImplementationCmd::~AddRFImplementationCmd
() {
58
}
59
60
/**
61
* Executes the command.
62
*/
63
bool
64
AddRFImplementationCmd::Do
() {
65
66
HDB::HDBManager
* manager = wxGetApp().mainFrame().hdbManager();
67
if
(manager == NULL) {
68
return
false
;
69
}
70
71
HDBBrowserWindow
* browser = wxGetApp().mainFrame().browser();
72
73
HDB::RFImplementation
*
implementation
74
=
new
HDB::RFImplementation
(
""
,
""
,
""
,
""
,
""
,
""
,
""
);
75
76
HDB::RFEntry
* entry = NULL;
77
78
if
(browser->
isRFEntrySelected
()) {
79
entry = manager->
rfByEntryID
(browser->
selectedRFEntry
());
80
}
else
if
(browser->
isRFArchitectureSelected
()) {
81
int
id
= manager->
addRFEntry
();
82
manager->
setArchitectureForRF
(
id
, browser->
selectedRFArchitecture
());
83
entry = manager->
rfByEntryID
(
id
);
84
}
else
{
85
return
false
;
86
}
87
88
RFImplementationDialog
dialog(
parentWindow
(), -1, *
implementation
);
89
90
if
(dialog.ShowModal() == wxID_OK) {
91
try
{
92
int
id
=
93
manager->
addRFImplementation
(*
implementation
, entry->
id
());
94
wxGetApp().mainFrame().update();
95
wxGetApp().mainFrame().browser()->selectRFImplementation(
id
);
96
}
catch
(
Exception
& e) {
97
wxString message = _T(
"Error:\n"
);
98
message.Append(
WxConversion::toWxString
(e.
errorMessage
()));
99
message.Append(_T(
"\n"
));
100
message.Append(
WxConversion::toWxString
(e.
lineNum
()));
101
message.Append(_T(
": "
));
102
message.Append(
WxConversion::toWxString
(e.
fileName
()));
103
ErrorDialog
dialog(
parentWindow
(), message);
104
dialog.ShowModal();
105
delete
entry;
106
delete
implementation
;
107
return
false
;
108
}
109
}
else
{
110
delete
implementation
;
111
}
112
113
delete
entry;
114
return
true
;
115
}
116
117
/**
118
* Returns name of the command icon file.
119
*
120
* @return Command icon file name.
121
*/
122
std::string
123
AddRFImplementationCmd::icon
()
const
{
124
return
""
;
125
}
126
127
/**
128
* Returns the command id.
129
*
130
* @return Command identifier.
131
*/
132
int
133
AddRFImplementationCmd::id
()
const
{
134
return
HDBEditorConstants::COMMAND_ADD_RF_IMPLEMENTATION
;
135
}
136
137
138
/**
139
* Creates a new instance of this command.
140
*
141
* @return Newly created instance of this command.
142
*/
143
AddRFImplementationCmd
*
144
AddRFImplementationCmd::create
()
const
{
145
return
new
AddRFImplementationCmd
();
146
}
147
148
149
/**
150
* Returns true if the command should be enabled in the tool/menubar.
151
*
152
* @return True if the command is enabled, false if not.
153
*/
154
bool
155
AddRFImplementationCmd::isEnabled
() {
156
157
HDB::HDBManager
* manager = wxGetApp().mainFrame().hdbManager();
158
159
if
(manager == NULL) {
160
return
false
;
161
}
162
163
HDBBrowserWindow
* browser = wxGetApp().mainFrame().browser();
164
165
166
if
(browser->
isRFArchitectureSelected
()) {
167
return
true
;
168
}
else
if
(browser->
isRFEntrySelected
()) {
169
HDB::RFEntry
* entry = manager->
rfByEntryID
(browser->
selectedRFEntry
());
170
if
(entry->
hasArchitecture
() && !entry->
hasImplementation
()) {
171
delete
entry;
172
return
true
;
173
}
174
delete
entry;
175
}
176
177
return
false
;
178
}
AddRFImplementationCmd.hh
ErrorDialog.hh
implementation
IDF::MachineImplementation * implementation
the implementation definition of the estimated processor
Definition
EstimatorCmdLineUI.cc:61
HDBBrowserWindow.hh
HDBEditorConstants.hh
HDBEditorMainFrame.hh
HDBEditor.hh
HDBManager.hh
RFEntry.hh
RFImplementationDialog.hh
RFImplementation.hh
WxConversion.hh
AddRFImplementationCmd
Definition
AddRFImplementationCmd.hh:41
AddRFImplementationCmd::Do
virtual bool Do()
Definition
AddRFImplementationCmd.cc:64
AddRFImplementationCmd::isEnabled
virtual bool isEnabled()
Definition
AddRFImplementationCmd.cc:155
AddRFImplementationCmd::icon
virtual std::string icon() const
Definition
AddRFImplementationCmd.cc:123
AddRFImplementationCmd::~AddRFImplementationCmd
virtual ~AddRFImplementationCmd()
Definition
AddRFImplementationCmd.cc:57
AddRFImplementationCmd::AddRFImplementationCmd
AddRFImplementationCmd()
Definition
AddRFImplementationCmd.cc:49
AddRFImplementationCmd::id
virtual int id() const
Definition
AddRFImplementationCmd.cc:133
AddRFImplementationCmd::create
virtual AddRFImplementationCmd * create() const
Definition
AddRFImplementationCmd.cc:144
ErrorDialog
Definition
ErrorDialog.hh:42
Exception
Definition
Exception.hh:54
Exception::fileName
std::string fileName() const
Exception::errorMessage
std::string errorMessage() const
Definition
Exception.cc:123
Exception::lineNum
int lineNum() const
GUICommand
Definition
GUICommand.hh:43
GUICommand::parentWindow
wxWindow * parentWindow() const
Definition
GUICommand.cc:75
HDBBrowserWindow
Definition
HDBBrowserWindow.hh:59
HDBBrowserWindow::selectedRFArchitecture
RowID selectedRFArchitecture()
Definition
HDBBrowserWindow.cc:483
HDBBrowserWindow::selectedRFEntry
RowID selectedRFEntry()
Definition
HDBBrowserWindow.cc:549
HDBBrowserWindow::isRFEntrySelected
bool isRFEntrySelected()
Definition
HDBBrowserWindow.cc:397
HDBBrowserWindow::isRFArchitectureSelected
bool isRFArchitectureSelected()
Definition
HDBBrowserWindow.cc:353
HDBEditorConstants
Definition
HDBEditorConstants.hh:42
HDBEditorConstants::COMMAND_ADD_RF_IMPLEMENTATION
@ COMMAND_ADD_RF_IMPLEMENTATION
Definition
HDBEditorConstants.hh:52
HDB::HDBEntry::id
RowID id() const
Definition
HDBEntry.cc:85
HDB::HDBManager
Definition
HDBManager.hh:82
HDB::HDBManager::addRFEntry
RowID addRFEntry() const
Definition
HDBManager.cc:1543
HDB::HDBManager::setArchitectureForRF
void setArchitectureForRF(RowID rfID, RowID archID) const
Definition
HDBManager.cc:1881
HDB::HDBManager::addRFImplementation
RowID addRFImplementation(const RFImplementation &implementation, RowID rfEntryID)
Definition
HDBManager.cc:1626
HDB::HDBManager::rfByEntryID
RFEntry * rfByEntryID(RowID id) const
Definition
HDBManager.cc:2871
HDB::RFEntry
Definition
RFEntry.hh:47
HDB::RFEntry::hasImplementation
virtual bool hasImplementation() const
Definition
RFEntry.cc:74
HDB::RFEntry::hasArchitecture
virtual bool hasArchitecture() const
Definition
RFEntry.cc:117
HDB::RFImplementation
Definition
RFImplementation.hh:50
RFImplementationDialog
Definition
RFImplementationDialog.hh:45
WxConversion::toWxString
static wxString toWxString(const std::string &source)
Generated by
1.9.8