OpenASIP 2.2
Loading...
Searching...
No Matches
Public Member Functions | Private Attributes | List of all members
ProximRuntimeErrorHandler Class Reference

#include <ProximRuntimeErrorHandler.hh>

Inheritance diagram for ProximRuntimeErrorHandler:
Inheritance graph
Collaboration diagram for ProximRuntimeErrorHandler:
Collaboration graph

Public Member Functions

 ProximRuntimeErrorHandler (SimulatorFrontend &frontend, wxEvtHandler &gui)
 
 ~ProximRuntimeErrorHandler ()
 
virtual void handleEvent ()
 
- Public Member Functions inherited from Listener
 Listener ()
 
virtual ~Listener ()
 
virtual void handleEvent (int event)
 

Private Attributes

SimulatorFrontendfrontend_
 Simulator frontend to stop when a fatal error occurs.
 
wxEvtHandler & gui_
 GUI to send the simulator events to.
 

Detailed Description

A class which handles simulation runtime errors in Proxim.

The errors are reported to the GUI using SimulatorEvents, and the simultion is stopped id necessary.

Definition at line 47 of file ProximRuntimeErrorHandler.hh.

Constructor & Destructor Documentation

◆ ProximRuntimeErrorHandler()

ProximRuntimeErrorHandler::ProximRuntimeErrorHandler ( SimulatorFrontend frontend,
wxEvtHandler &  gui 
)

The Constructor.

The created error handler is registered automatically as simulator event handler listener.

Parameters
frontendSimulator frontend to stop when a fatal error occurs.
guiGUI to send the error events to.

Definition at line 50 of file ProximRuntimeErrorHandler.cc.

52 :
53 Listener(),
54 frontend_(frontend),
55 gui_(gui) {
56
59}
virtual bool registerListener(int event, Listener *listener)
Definition Informer.cc:87
SimulatorFrontend & frontend_
Simulator frontend to stop when a fatal error occurs.
wxEvtHandler & gui_
GUI to send the simulator events to.
@ SE_RUNTIME_ERROR
Sent when a runtime error is detected in the simulated program.
SimulationEventHandler & eventHandler()

References SimulatorFrontend::eventHandler(), Informer::registerListener(), and SimulationEventHandler::SE_RUNTIME_ERROR.

Here is the call graph for this function:

◆ ~ProximRuntimeErrorHandler()

ProximRuntimeErrorHandler::~ProximRuntimeErrorHandler ( )

The Destructor.

Definition at line 64 of file ProximRuntimeErrorHandler.cc.

64 {
67}
virtual bool unregisterListener(int event, Listener *listener)
Definition Informer.cc:104

References SimulatorFrontend::eventHandler(), frontend_, SimulationEventHandler::SE_RUNTIME_ERROR, and Informer::unregisterListener().

Here is the call graph for this function:

Member Function Documentation

◆ handleEvent()

void ProximRuntimeErrorHandler::handleEvent ( )
virtual

Handles simulator runtime errors.

This event handler sends a SimulatorEvent to the GUI when a runtime error occurs. An error message explaining the error is sent as the event string payload. If a fatal error occured, the simulator is stopped.

Reimplemented from Listener.

Definition at line 78 of file ProximRuntimeErrorHandler.cc.

78 {
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}
@ SRE_RUNTIME_ERROR
A fatal runtime error occured in the simulated program.
static const wxEventType EVT_SIMULATOR_RUNTIME_WARNING
Runtime warning event.
static const wxEventType EVT_SIMULATOR_RUNTIME_ERROR
Runtime error event.
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)

References SimulatorFrontend::clearProgramErrorReports(), SimulatorEvent::EVT_SIMULATOR_RUNTIME_ERROR, SimulatorEvent::EVT_SIMULATOR_RUNTIME_WARNING, frontend_, gui_, SimulatorFrontend::prepareToStop(), SimulatorFrontend::programErrorReport(), SimulatorFrontend::programErrorReportCount(), SimulatorFrontend::RES_FATAL, SimulatorFrontend::RES_MINOR, and SRE_RUNTIME_ERROR.

Here is the call graph for this function:

Member Data Documentation

◆ frontend_

SimulatorFrontend& ProximRuntimeErrorHandler::frontend_
private

Simulator frontend to stop when a fatal error occurs.

Definition at line 58 of file ProximRuntimeErrorHandler.hh.

Referenced by handleEvent(), and ~ProximRuntimeErrorHandler().

◆ gui_

wxEvtHandler& ProximRuntimeErrorHandler::gui_
private

GUI to send the simulator events to.

Definition at line 60 of file ProximRuntimeErrorHandler.hh.

Referenced by handleEvent().


The documentation for this class was generated from the following files: