OpenASIP 2.2
Loading...
Searching...
No Matches
OSEdBuildAllCmd.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 OSEdBuildAllCmd.cc
26 *
27 * Definition of OSEdBuildAllCmd 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 "OSEdBuildAllCmd.hh"
38#include "OSEdConstants.hh"
39#include "OperationBuilder.hh"
40#include "ResultDialog.hh"
41#include "OperationContainer.hh"
42#include "OSEdTextGenerator.hh"
43#include "OperationModule.hh"
44#include "OperationIndex.hh"
45#include "WxConversion.hh"
46#include "OSEd.hh"
47#include "SimulateDialog.hh"
48
49using std::string;
50using std::vector;
51using std::map;
52using boost::format;
53
54/**
55 * Constructor.
56 */
58 GUICommand(OSEdConstants::CMD_NAME_BUILD_ALL, NULL) {
59}
60
61/**
62 * Destructor.
63 */
66
67/**
68 * Returns the id of the command.
69 *
70 * @return The id of the command.
71 */
72int
76
77/**
78 * Returns a new command.
79 *
80 * @return A new command.
81 */
84 return new OSEdBuildAllCmd();
85}
86
87/**
88 * Executes the command.
89 *
90 * @return True if execution is successful.
91 */
92bool
94
95 wxWindow* simulateDialog =
96 wxGetApp().mainFrame()->FindWindowByName(SimulateDialog::DIALOG_NAME);
97
98 if (simulateDialog != NULL) {
99 simulateDialog->Close();
100 }
101
105 wxStatusBar* statusBar = wxGetApp().mainFrame()->statusBar();
106
107 vector<OperationModule> buildModules;
108 vector<string> paths;
109 for (int i = 0; i < index.pathCount(); i++) {
110
111 string path = index.path(i);
112 for (int k = 0; k < index.moduleCount(path); k++) {
113
114 OperationModule& module = index.module(k, path);
115 if (module.hasBehaviorSource()) {
116 buildModules.push_back(module);
117 paths.push_back(path);
118 }
119 }
120 }
121
122 vector<string> output;
123 wxStopWatch sw;
124 sw.Pause();
125 wxBusyCursor* busy = new wxBusyCursor();
126 bool compileOk = true;
127 for (size_t i = 0; i < buildModules.size(); i++) {
128 OperationModule module = buildModules[i];
129 string path = paths[i];
130 output.push_back(module.name() + ":\n");
131 size_t oldSize = output.size();
132
133 sw.Resume();
134 builder.buildObject(module.name(),
135 module.behaviorSourceModule(),
136 path, output);
137 sw.Pause();
138
139 if (oldSize != output.size()) {
140 compileOk = false;
141 }
142 output.push_back("\n");
143 }
144
145 delete busy;
146
147 if (!compileOk) {
149 statusBar->SetStatusText(WxConversion::toWxString(fmt.str()));
151 ResultDialog dialog(parentWindow(), output, fmt.str());
152 dialog.ShowModal();
153 } else {
155 fmt % sw.Time();
156 statusBar->SetStatusText(WxConversion::toWxString(fmt.str()));
157 }
158 return true;
159}
160
161/**
162 * Returns true if command is enabled.
163 *
164 * Command is enabled, if at least one module has behavior source file.
165 *
166 * @return True if command is enabled.
167 */
168bool
171 for (int i = 0; i < index.moduleCount(); i++) {
172 OperationModule& module = index.module(i);
173 if (module.hasBehaviorSource()) {
174 return true;
175 }
176 }
177 return false;
178}
179
180/**
181 * Returns icon path.
182 *
183 * @return Empty string (icons not used).
184 */
185string
187 return "";
188}
wxWindow * parentWindow() const
Definition GUICommand.cc:75
virtual bool isEnabled()
virtual GUICommand * create() const
virtual bool Do()
virtual int id() const
virtual std::string icon() const
virtual ~OSEdBuildAllCmd()
@ CMD_BUILD_ALL
Build all command id.
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.
static OperationBuilder & instance()
bool buildObject(const std::string &baseName, const std::string &behaviorFile, const std::string &path, std::vector< std::string > &output)
static OperationIndex & operationIndex()
std::string path(int i) const
int pathCount() const
int moduleCount() const
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)