OpenASIP  2.0
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 
33 #include "SetRFArchitectureCmd.hh"
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 
43 using 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  */
57 }
58 
59 /**
60  * Executes the command.
61  */
62 bool
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  */
108 std::string
110  return "";
111 
112 }
113 
114 
115 /**
116  * Returns the command id.
117  *
118  * @return Command identifier for this command.
119  */
120 int
123 }
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  */
141 bool
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 
WxConversion::toWxString
static wxString toWxString(const std::string &source)
HDBBrowserWindow.hh
HDB
Definition: CostDatabase.hh:49
SetRFArchitectureCmd::Do
virtual bool Do()
Definition: SetRFArchitectureCmd.cc:63
HDBEditor.hh
HDB::HDBEntry::id
RowID id() const
Definition: HDBEntry.cc:85
SetRFArchitectureCmd::SetRFArchitectureCmd
SetRFArchitectureCmd()
Definition: SetRFArchitectureCmd.cc:48
HDBEditorConstants.hh
HDB::RFEntry
Definition: RFEntry.hh:47
RowID
int RowID
Type definition of row ID in relational databases.
Definition: DBTypes.hh:37
SetRFArchitectureCmd
Definition: SetRFArchitectureCmd.hh:41
SetRFArchitectureCmd::isEnabled
virtual bool isEnabled()
Definition: SetRFArchitectureCmd.cc:142
GUICommand
Definition: GUICommand.hh:43
HDB::HDBManager::unsetArchitectureForRF
void unsetArchitectureForRF(RowID rfID) const
Definition: HDBManager.cc:1930
SetRFArchitectureCmd::id
virtual int id() const
Definition: SetRFArchitectureCmd.cc:121
HDB::HDBManager::setArchitectureForRF
void setArchitectureForRF(RowID rfID, RowID archID) const
Definition: HDBManager.cc:1895
Conversion.hh
HDBEditorMainFrame.hh
HDB::HDBManager
Definition: HDBManager.hh:82
SetRFArchitectureCmd::create
virtual SetRFArchitectureCmd * create() const
Definition: SetRFArchitectureCmd.cc:132
SetRFArchitectureCmd::icon
virtual std::string icon() const
Definition: SetRFArchitectureCmd.cc:109
HDB::HDBManager::rfArchitectureIDs
std::set< RowID > rfArchitectureIDs() const
Definition: HDBManager.cc:2734
SetRFArchitectureCmd.hh
HDBEditorConstants::COMMAND_SET_RF_ARCH
@ COMMAND_SET_RF_ARCH
Definition: HDBEditorConstants.hh:50
HDBEditorConstants
Definition: HDBEditorConstants.hh:42
SetRFArchitectureCmd::~SetRFArchitectureCmd
virtual ~SetRFArchitectureCmd()
Definition: SetRFArchitectureCmd.cc:56
RFEntry.hh
WxConversion.hh
Conversion::toInt
static int toInt(const T &source)
HDBManager.hh
WxConversion::toString
static std::string toString(const wxString &source)
GUICommand::parentWindow
wxWindow * parentWindow() const
Definition: GUICommand.cc:75