OpenASIP 2.2
Loading...
Searching...
No Matches
ProximRuntimeErrorHandler.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 ProximRuntimeErrorHandler.cc
26 *
27 * Implementation of ProximRuntimeErrorHandler class.
28 *
29 * @author Veli-Pekka Jääskeläinen 2005 (vjaaskel-no.spam-cs.tut.fi)
30 * @author Pekka Jääskeläinen 2009 (pjaaskel-no.spam-cs.tut.fi)
31 * @note rating: red
32 */
33
34#include <string>
37#include "SimulatorEvent.hh"
38
39using std::string;
40
41/**
42 * The Constructor.
43 *
44 * The created error handler is registered automatically as simulator
45 * event handler listener.
46 *
47 * @param frontend Simulator frontend to stop when a fatal error occurs.
48 * @param gui GUI to send the error events to.
49 */
51 SimulatorFrontend& frontend,
52 wxEvtHandler& gui):
53 Listener(),
54 frontend_(frontend),
55 gui_(gui) {
56
59}
60
61/**
62 * The Destructor.
63 */
68
69
70/**
71 * Handles simulator runtime errors.
72 *
73 * This event handler sends a SimulatorEvent to the GUI when a runtime error
74 * occurs. An error message explaining the error is sent as the event
75 * string payload. If a fatal error occured, the simulator is stopped.
76 */
77void
79
80 size_t minorErrors = frontend_.programErrorReportCount(
82 size_t fatalErrors = frontend_.programErrorReportCount(
84
85 // Send runtime warning event if minor errors occured.
86 if (minorErrors > 0) {
87 string message;
88 for (size_t i = 0; i < minorErrors; ++i) {
89 message += "warning: runtime error: \n";
92 }
93 SimulatorEvent simEvent(
95 wxPostEvent(&gui_, simEvent);
96 }
97
98 // Send runtime error event if fatal errors occured.
99 if (fatalErrors > 0) {
100 string message;
101 for (size_t i = 0; i < fatalErrors; ++i) {
102 message += "error: runtime error: \n";
103 message +=
106
107 }
108
109 SimulatorEvent simEvent(
111 wxPostEvent(&gui_, simEvent);
112
113 // Stop simulation.
115 }
116
118}
119
@ SRE_RUNTIME_ERROR
A fatal runtime error occured in the simulated program.
virtual bool unregisterListener(int event, Listener *listener)
Definition Informer.cc:104
virtual bool registerListener(int event, Listener *listener)
Definition Informer.cc:87
SimulatorFrontend & frontend_
Simulator frontend to stop when a fatal error occurs.
ProximRuntimeErrorHandler(SimulatorFrontend &frontend, wxEvtHandler &gui)
wxEvtHandler & gui_
GUI to send the simulator events to.
@ SE_RUNTIME_ERROR
Sent when a runtime error is detected in the simulated program.
static const wxEventType EVT_SIMULATOR_RUNTIME_WARNING
Runtime warning event.
static const wxEventType EVT_SIMULATOR_RUNTIME_ERROR
Runtime error event.
SimulationEventHandler & eventHandler()
std::size_t programErrorReportCount(RuntimeErrorSeverity severity)
@ RES_FATAL
Fatal runtime error, there is a serious error in the simulated program, thus it makes no sense to go ...
@ RES_MINOR
Minor runtime error, no abort necessary.
std::string programErrorReport(RuntimeErrorSeverity severity, std::size_t index)
void prepareToStop(StopReason reason)