OpenASIP 2.2
Loading...
Searching...
No Matches
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
34#include "WxConversion.hh"
35#include "HDBEditorConstants.hh"
36#include "HDBEditor.hh"
37#include "HDBEditorMainFrame.hh"
38#include "HDBBrowserWindow.hh"
39#include "HDBManager.hh"
41#include "RFImplementation.hh"
42#include "RFEntry.hh"
43#include "ErrorDialog.hh"
44
45
46/**
47 * The Constructor.
48 */
50 GUICommand(HDBEditorConstants::COMMAND_NAME_ADD_RF_IMPLEMENTATION, NULL) {
51}
52
53
54/**
55 * The Destructor.
56 */
59
60/**
61 * Executes the command.
62 */
63bool
65
66 HDB::HDBManager* manager = wxGetApp().mainFrame().hdbManager();
67 if (manager == NULL) {
68 return false;
69 }
70
71 HDBBrowserWindow* browser = wxGetApp().mainFrame().browser();
72
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
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 */
122std::string
124 return "";
125}
126
127/**
128 * Returns the command id.
129 *
130 * @return Command identifier.
131 */
132int
136
137
138/**
139 * Creates a new instance of this command.
140 *
141 * @return Newly created instance of this command.
142 */
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 */
154bool
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}
IDF::MachineImplementation * implementation
the implementation definition of the estimated processor
virtual std::string icon() const
virtual AddRFImplementationCmd * create() const
std::string fileName() const
std::string errorMessage() const
Definition Exception.cc:123
int lineNum() const
wxWindow * parentWindow() const
Definition GUICommand.cc:75
RowID id() const
Definition HDBEntry.cc:85
RowID addRFEntry() const
void setArchitectureForRF(RowID rfID, RowID archID) const
RowID addRFImplementation(const RFImplementation &implementation, RowID rfEntryID)
RFEntry * rfByEntryID(RowID id) const
virtual bool hasImplementation() const
Definition RFEntry.cc:74
virtual bool hasArchitecture() const
Definition RFEntry.cc:117
static wxString toWxString(const std::string &source)