OpenASIP 2.2
Loading...
Searching...
No Matches
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
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 "FUImplementation.hh"
42#include "FUEntry.hh"
43#include "FUArchitecture.hh"
44#include "ErrorDialog.hh"
45#include "FunctionUnit.hh"
46#include "FUPort.hh"
48
49
50/**
51 * The Constructor.
52 */
54 GUICommand(HDBEditorConstants::COMMAND_NAME_ADD_FU_IMPLEMENTATION, NULL) {
55}
56
57
58/**
59 * The Destructor.
60 */
63
64/**
65 * Executes the command.
66 */
67bool
69
70 HDB::HDBManager* manager = wxGetApp().mainFrame().hdbManager();
71 if (manager == NULL) {
72 return false;
73 }
74
75 HDBBrowserWindow* browser = wxGetApp().mainFrame().browser();
76
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++) {
97 "", arch.port(i)->name(), "", "", "", *implementation);
98 }
99
101
102 if (dialog.ShowModal() == wxID_OK) {
103 try {
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 */
133std::string
135 return "";
136}
137
138/**
139 * Returns the command id.
140 *
141 * @return Command identifier.
142 */
143int
147
148
149/**
150 * Creates a new instance of this command.
151 *
152 * @return Newly created instance of this command.
153 */
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 */
165bool
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}
IDF::MachineImplementation * implementation
the implementation definition of the estimated processor
virtual std::string icon() const
virtual AddFUImplementationCmd * create() const
std::string fileName() const
std::string errorMessage() const
Definition Exception.cc:123
int lineNum() const
wxWindow * parentWindow() const
Definition GUICommand.cc:75
TTAMachine::FunctionUnit & architecture() const
void setImplementation(FUImplementation *implementation)
Definition FUEntry.cc:103
virtual bool hasImplementation() const
Definition FUEntry.cc:74
FUArchitecture & architecture() const
Definition FUEntry.cc:129
virtual bool hasArchitecture() const
Definition FUEntry.cc:117
FUEntry * fuByEntryID(RowID id) const
RowID addFUEntry() const
RowID addFUImplementation(const FUEntry &entry) const
void setArchitectureForFU(RowID fuID, RowID archID) const
virtual BaseFUPort * port(const std::string &name) const
virtual std::string name() const
Definition Port.cc:141
virtual int portCount() const
Definition Unit.cc:135
static wxString toWxString(const std::string &source)