OpenASIP 2.2
Loading...
Searching...
No Matches
SetFUArchitectureCmd.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 SetFUArchitectureCmd.cc
26 *
27 * Implementation of SetFUArchitectureCmd 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 "HDBManager.hh"
39#include "FUEntry.hh"
40#include "HDBBrowserWindow.hh"
41#include "Conversion.hh"
42
43using namespace HDB;
44
45/**
46 * The Constructor.
47 */
49 GUICommand(HDBEditorConstants::COMMAND_NAME_SET_FU_ARCH, NULL) {
50}
51
52
53/**
54 * The Destructor.
55 */
58
59/**
60 * Executes the command.
61 */
62bool
64 HDBManager* manager = wxGetApp().mainFrame().hdbManager();
65
66 if (manager == NULL) {
67 return false;
68 }
69
70 const FUEntry* entry = manager->fuByID(
71 wxGetApp().mainFrame().browser()->selectedFUEntry());
72
73 wxString fus[1000];
74 const std::set<RowID> fuIDs = manager->fuArchitectureIDs();
75 std::set<RowID>::iterator iter = fuIDs.begin();
76 int i = 0;
77 for (;iter != fuIDs.end(); iter++) {
78 fus[i] = WxConversion::toWxString(*iter);
79 i++;
80 }
81
82 wxSingleChoiceDialog choicer(
83 parentWindow(), _T("Choose Architecture"), _T("Choose Architecture"),
84 i, fus);
85
86 if (choicer.ShowModal() != wxID_OK) {
87 return false;
88 }
89
90
91 std::string archID = WxConversion::toString(choicer.GetStringSelection());
92 RowID rowID = Conversion::toInt(archID);
93 manager->unsetArchitectureForFU(entry->id());
94 manager->setArchitectureForFU(entry->id(), rowID);
95
96 wxGetApp().mainFrame().update();
97 wxGetApp().mainFrame().browser()->selectFUEntry(entry->id());
98
99 return true;
100}
101
102/**
103 * Returns name of the command icon file.
104 *
105 * @return Command icon file name.
106 */
107std::string
109 return "";
110
111}
112
113
114/**
115 * Returns the command id.
116 *
117 * @return Command identifier for this command.
118 */
119int
123
124
125/**
126 * Creates and returns a new instance of the command.
127 *
128 * @return Newly created instance of this command.
129 */
132 return new SetFUArchitectureCmd();
133}
134
135/**
136 * Returns true if the command should be enabled in the menu/toolbar.
137 *
138 * @return True if the command is enabled, false if not.
139 */
140bool
142 HDB::HDBManager* manager = wxGetApp().mainFrame().hdbManager();
143
144 if (manager == NULL) {
145 return false;
146 }
147
148 HDBBrowserWindow* browser = wxGetApp().mainFrame().browser();
149
150 if (!browser->isFUEntrySelected() ||
151 manager->fuByID(browser->selectedFUEntry())->hasArchitecture()) {
152
153 return false;
154 }
155 return true;
156}
157
int RowID
Type definition of row ID in relational databases.
Definition DBTypes.hh:37
static int toInt(const T &source)
wxWindow * parentWindow() const
Definition GUICommand.cc:75
RowID id() const
Definition HDBEntry.cc:85
std::set< RowID > fuArchitectureIDs() const
void setArchitectureForFU(RowID fuID, RowID archID) const
void unsetArchitectureForFU(RowID fuID) const
virtual std::string icon() const
virtual SetFUArchitectureCmd * create() const
static wxString toWxString(const std::string &source)
static std::string toString(const wxString &source)