OpenASIP 2.2
Loading...
Searching...
No Matches
OSEdBuildCmd.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 OSEdBuildCmd.cc
26 *
27 * Definition of OSEdBuildCmd class.
28 *
29 * @author Jussi Nykänen 2004 (nykanen-no.spam-cs.tut.fi)
30 * @note rating: red
31 */
32
33#include <vector>
34#include <boost/format.hpp>
35#include <wx/timer.h>
36
37#include "OSEdBuildCmd.hh"
38#include "OSEdConstants.hh"
39#include "OSEd.hh"
40#include "OperationBuilder.hh"
41#include "OperationContainer.hh"
42#include "ResultDialog.hh"
43#include "OSEdTextGenerator.hh"
44#include "OperationModule.hh"
45#include "OSEdTreeView.hh"
46#include "WxConversion.hh"
47#include "SimulateDialog.hh"
48
49using std::string;
50using std::vector;
51using boost::format;
52
53/**
54 * Constructor.
55 */
57 GUICommand(OSEdConstants::CMD_NAME_BUILD, NULL) {
58}
59
60/**
61 * Destructor.
62 */
65
66/**
67 * Returns the id of the command.
68 *
69 * @return The id of the command.
70 */
71int
75
76/**
77 * Creates a new command.
78 *
79 * @return A new command.
80 */
83 return new OSEdBuildCmd();
84}
85
86/**
87 * Executes the command.
88 *
89 * @return True if execution is successful.
90 */
91bool
93
94 wxWindow* simulateDialog =
95 wxGetApp().mainFrame()->FindWindowByName(SimulateDialog::DIALOG_NAME);
96
97 if (simulateDialog != NULL) {
98 simulateDialog->Close();
99 }
100
102 wxStatusBar* statusBar = wxGetApp().mainFrame()->statusBar();
103 OSEdTreeView* treeView = wxGetApp().mainFrame()->treeView();
104
105 string modName = treeView->selectedModule();
106 wxTreeItemId modId = treeView->selectedModuleId();
107 string pathName = treeView->pathOfModule(modId);
108 OperationModule& module = OperationContainer::module(pathName, modName);
109
111 fmt % module.name();
112 statusBar->SetStatusText(WxConversion::toWxString(fmt.str()));
113
114 vector<string> output;
115 output.push_back(module.name() + ":\n");
117 size_t oldSize = output.size();
118
119 wxStopWatch sw;
120 wxBusyCursor* busy = new wxBusyCursor();
121 builder.buildObject(
122 module.name(), module.behaviorSourceModule(), pathName, output);
123 delete busy;
124 sw.Pause();
125
126 if (oldSize == output.size()) {
128 fmt % sw.Time();
129 statusBar->SetStatusText(WxConversion::toWxString(fmt.str()));
130 } else {
132 statusBar->SetStatusText(WxConversion::toWxString(fmt.str()));
134 ResultDialog dialog(parentWindow(), output, fmt.str(),
135 module.behaviorSourceModule());
136 dialog.ShowModal();
137 }
138 return true;
139}
140
141/**
142 * Returns true if command is enabled.
143 *
144 * Command is enabled when module with behavior source file has been
145 * selected.
146 *
147 * @return True if command is enabled.
148 */
149bool
151 OSEdMainFrame* mainFrame = wxGetApp().mainFrame();
152 OSEdTreeView* treeView = mainFrame->treeView();
153 string modName = treeView->selectedModule();
154 if (modName == "") {
155 return false;
156 }
157 wxTreeItemId modId = treeView->selectedModuleId();
158 string pathName = treeView->pathOfModule(modId);
159 OperationModule& module = OperationContainer::module(pathName, modName);
160 return module.hasBehaviorSource();
161}
162
163/**
164 * Returns the icon path.
165 *
166 * @return Empty string (icons not used).
167 */
168string
170 return "";
171}
wxWindow * parentWindow() const
Definition GUICommand.cc:75
virtual GUICommand * create() const
virtual bool Do()
virtual int id() const
virtual ~OSEdBuildCmd()
virtual std::string icon() const
virtual bool isEnabled()
@ CMD_BUILD
Build command id.
OSEdTreeView * treeView() const
static OSEdTextGenerator & instance()
@ TXT_STATUS_COMPILE_SUCCESS
Status bar text when compiling was successful.
@ TXT_STATUS_COMPILE_FAILED
Status bar text when compilation failed.
@ TXT_BUILD_RESULT_DIALOG_TITLE
Build result dialog title.
@ TXT_STATUS_COMPILING
Status bar text when compiling.
wxTreeItemId selectedModuleId()
std::string pathOfModule(wxTreeItemId id)
std::string selectedModule()
static OperationBuilder & instance()
bool buildObject(const std::string &baseName, const std::string &behaviorFile, const std::string &path, std::vector< std::string > &output)
static const wxString DIALOG_NAME
Name of the dialog so it can be found with wxWindow::FindWindowByName.
virtual boost::format text(int textId)
static wxString toWxString(const std::string &source)