OpenASIP  2.0
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. More...
 
wxEvtHandler & gui_
 GUI to send the simulator events to. More...
 

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 
57  frontend.eventHandler().registerListener(
59 }

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.

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";
90  message += frontend_.programErrorReport(
91  SimulatorFrontend::RES_MINOR, i) + "\n\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 +=
105  SimulatorFrontend::RES_FATAL, i) + "\n";
106 
107  }
108 
109  SimulatorEvent simEvent(
111  wxPostEvent(&gui_, simEvent);
112 
113  // Stop simulation.
115  }
116 
118 }

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:
SimulatorEvent::EVT_SIMULATOR_RUNTIME_WARNING
static const wxEventType EVT_SIMULATOR_RUNTIME_WARNING
Runtime warning event.
Definition: SimulatorEvent.hh:66
ProximRuntimeErrorHandler::frontend_
SimulatorFrontend & frontend_
Simulator frontend to stop when a fatal error occurs.
Definition: ProximRuntimeErrorHandler.hh:58
Informer::unregisterListener
virtual bool unregisterListener(int event, Listener *listener)
Definition: Informer.cc:104
SimulatorEvent::EVT_SIMULATOR_RUNTIME_ERROR
static const wxEventType EVT_SIMULATOR_RUNTIME_ERROR
Runtime error event.
Definition: SimulatorEvent.hh:64
SimulatorFrontend::programErrorReport
std::string programErrorReport(RuntimeErrorSeverity severity, std::size_t index)
Definition: SimulatorFrontend.cc:2321
Informer::registerListener
virtual bool registerListener(int event, Listener *listener)
Definition: Informer.cc:87
SRE_RUNTIME_ERROR
@ SRE_RUNTIME_ERROR
A fatal runtime error occured in the simulated program.
Definition: SimulatorConstants.hh:68
SimulatorFrontend::RES_MINOR
@ RES_MINOR
Minor runtime error, no abort necessary.
Definition: SimulatorFrontend.hh:94
SimulatorFrontend::RES_FATAL
@ RES_FATAL
Fatal runtime error, there is a serious error in the simulated program, thus it makes no sense to go ...
Definition: SimulatorFrontend.hh:95
SimulationEventHandler::SE_RUNTIME_ERROR
@ SE_RUNTIME_ERROR
Sent when a runtime error is detected in the simulated program.
Definition: SimulationEventHandler.hh:52
SimulatorFrontend::programErrorReportCount
std::size_t programErrorReportCount(RuntimeErrorSeverity severity)
Definition: SimulatorFrontend.cc:2344
SimulatorFrontend::clearProgramErrorReports
void clearProgramErrorReports()
Definition: SimulatorFrontend.cc:2360
SimulatorFrontend::eventHandler
SimulationEventHandler & eventHandler()
Definition: SimulatorFrontend.cc:2260
ProximRuntimeErrorHandler::gui_
wxEvtHandler & gui_
GUI to send the simulator events to.
Definition: ProximRuntimeErrorHandler.hh:60
Listener::Listener
Listener()
Definition: Listener.cc:40
SimulatorEvent
Definition: SimulatorEvent.hh:42
SimulatorFrontend::prepareToStop
void prepareToStop(StopReason reason)
Definition: SimulatorFrontend.cc:1331