Simbody  3.7
SimTK::EventHandler Class Referenceabstract

An EventHandler is an object that defines an event that can occur within a system. More...

+ Inheritance diagram for SimTK::EventHandler:

Public Member Functions

virtual ~EventHandler ()
virtual void handleEvent (State &state, Real accuracy, bool &shouldTerminate) const =0
 This method is invoked to handle the event. More...

Detailed Description

An EventHandler is an object that defines an event that can occur within a system.

It is an abstract class. Subclasses define how to determine when the event occurs, and what happens when it does. You will not generally subclass EventHandler directly. Instead, subclass ScheduledEventHandler (for events that occur at a particular time that is know in advance) or TriggeredEventHandler (for events that occur when some condition is satisfied within the system). ScheduledEventHandler also has another subclass, PeriodicEventHandler, for the common situation of events that occur at regular intervals.

An EventHandler should be thought of as an integral part of the system it belongs to, and may alter the physical properties or behavior of the system.
If you merely want to observe the system but not to alter it, you should generally use a EventReporter instead.

Once you have created an EventHandler, you can add it to a System by calling addEventHandler() on the System.

Constructor & Destructor Documentation

◆ ~EventHandler()

virtual SimTK::EventHandler::~EventHandler ( )

Member Function Documentation

◆ handleEvent()

virtual void SimTK::EventHandler::handleEvent ( State state,
Real  accuracy,
bool &  shouldTerminate 
) const
pure virtual

This method is invoked to handle the event.

It is given a State which describes the system at the time when the event occurs, and it is permitted to modify any aspect of the state except the time. In doing so, it should respect the specified accuracy requirements for the continuous variables and constraints.

stateThe state of the system when the event occurred. This method should modify state to reflect the changes caused by the event.
The accuracy to which this simulation is being computed. If your handler performs any approximate operation it should do so consistent with the simulation accuracy.
If the event handler sets this to true, it will cause the simulation to terminate immediately. This does not necessarily indicate an error condition.

Implemented in SimTK::GeodHitPlaneEvent.

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