OpenASIP 2.2
Loading...
Searching...
No Matches
ProximExecuteFileCmd.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 ProximExecuteFileCmd.cc
26 *
27 * Implementation of ProximExecuteFileCmd class.
28 *
29 * @author Veli-Pekka Jääskeläinen 2005 (vjaaskel-no.spam-cs.tut.fi)
30 * @note rating: red
31 */
32
33#include <fstream>
35#include "ProximConstants.hh"
36#include "ProximToolbox.hh"
37#include "ProximLineReader.hh"
38#include "WxConversion.hh"
39#include "ErrorDialog.hh"
41
42#if wxCHECK_VERSION(3, 0, 0)
43 #define wxOPEN wxFD_OPEN
44#endif
45
46/**
47 * The Constructor.
48 */
54
55/**
56 * The Destructor.
57 */
60
61
62/**
63 * Executes the command.
64 */
65bool
67 wxString message = _T("Choose a file.");
68 wxString wildcard = _T("Command history logs (*.log)|*.log|All files|*.*");
69 wxFileDialog dialog(
70 parentWindow(), message, _T(""), _T(""), wildcard, wxOPEN);
71
72 if (dialog.ShowModal() == wxID_CANCEL) {
73 return false;
74 }
75
76 std::string filename = WxConversion::toString(dialog.GetPath());
77 std::ifstream file(filename.c_str());
78
79 if (file.bad()) {
80 wxString message = _T("Error opening file '");
81 message.Append(dialog.GetPath());
82 message.Append(_T("'."));
83 ErrorDialog dialog(parentWindow(), message);
84 dialog.ShowModal();
85 return false;
86 }
87
89
90 while (!file.eof()) {
91 std::string command;
92 getline(file, command);
93 lineReader.input(command);
94 }
95
96 return true;
97}
98
99
100/**
101 * Returns full path to the command icon file.
102 *
103 * @return Full path to the command icon file.
104 */
105std::string
107 return "exec.png";
108}
109
110
111/**
112 * Returns ID of this command.
113 */
114int
118
119
120/**
121 * Creates and returns a new isntance of this command.
122 *
123 * @return Newly created instance of this command.
124 */
127 return new ProximExecuteFileCmd();
128}
129
130
131/**
132 * Returns true if the command is enabled, false otherwise.
133 *
134 * @return True if the simulation is initialized or stopped.
135 */
136bool
138
139 if (simulator_ != NULL) {
140 return true;
141 } else {
142 return false;
143 }
144}
wxWindow * parentWindow() const
Definition GUICommand.cc:75
virtual std::string icon() const
virtual ProximExecuteFileCmd * create() const
SimulatorFrontend * simulator_
void input(std::string command)
static ProximLineReader & lineReader()
static TracedSimulatorFrontend * frontend()
static std::string toString(const wxString &source)