OpenASIP 2.2
Loading...
Searching...
No Matches
SetRFArchitectureCmd.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 SetRFArchitectureCmd.cc
26 *
27 * Implementation of SetRFArchitectureCmd 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 "RFEntry.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_RF_ARCH, NULL) {
50}
51
52
53/**
54 * The Destructor.
55 */
58
59/**
60 * Executes the command.
61 */
62bool
64
65 HDBManager* manager = wxGetApp().mainFrame().hdbManager();
66
67 if (manager == NULL) {
68 return false;
69 }
70
71 const RFEntry* entry = manager->rfByID(
72 wxGetApp().mainFrame().browser()->selectedRFEntry());
73
74 wxString rfs[1000];
75 const std::set<RowID> rfIDs = manager->rfArchitectureIDs();
76 std::set<RowID>::iterator iter = rfIDs.begin();
77 int i = 0;
78 for (;iter != rfIDs.end(); iter++) {
79 rfs[i] = WxConversion::toWxString(*iter);
80 i++;
81 }
82
83 wxSingleChoiceDialog choicer(
84 parentWindow(), _T("Choose Architecture"), _T("Choose Architecture"),
85 i, rfs);
86
87 if (choicer.ShowModal() != wxID_OK) {
88 return false;
89 }
90
91
92 std::string archID = WxConversion::toString(choicer.GetStringSelection());
93 RowID rowID = Conversion::toInt(archID);
94 manager->unsetArchitectureForRF(entry->id());
95 manager->setArchitectureForRF(entry->id(), rowID);
96
97 wxGetApp().mainFrame().update();
98 wxGetApp().mainFrame().browser()->selectRFEntry(entry->id());
99
100 return true;
101}
102
103/**
104 * Returns name of the command icon file.
105 *
106 * @return Command icon file name.
107 */
108std::string
110 return "";
111
112}
113
114
115/**
116 * Returns the command id.
117 *
118 * @return Command identifier for this command.
119 */
120int
124
125
126/**
127 * Creates and returns a new instance of the command.
128 *
129 * @return Newly created instance of this command.
130 */
133 return new SetRFArchitectureCmd();
134}
135
136/**
137 * Returns true if the command should be enabled in the menu/toolbar.
138 *
139 * @return True if the command is enabled, false if not.
140 */
141bool
143 HDB::HDBManager* manager = wxGetApp().mainFrame().hdbManager();
144
145 if (manager == NULL) {
146 return false;
147 }
148
149 if (!wxGetApp().mainFrame().browser()->isRFEntrySelected()) {
150 return false;
151 }
152 return true;
153}
154
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 > rfArchitectureIDs() const
void setArchitectureForRF(RowID rfID, RowID archID) const
void unsetArchitectureForRF(RowID rfID) const
virtual SetRFArchitectureCmd * create() const
virtual std::string icon() const
static wxString toWxString(const std::string &source)
static std::string toString(const wxString &source)