Package org.robwork.sdurwsim
Class ThreadSimulatorStepEventDispatcher
- java.lang.Object
-
- org.robwork.sdurwsim.ThreadSimulatorStepEventDispatcher
-
- All Implemented Interfaces:
ThreadSimulatorStepCallbackHandler
public class ThreadSimulatorStepEventDispatcher extends java.lang.Object implements ThreadSimulatorStepCallbackHandler
Register listeners for step events from theThreadSimulator
. When this object is added to theThreadSimulator
, it will dispatch aThreadSimulatorStepEvent
for each callback from the stepper loop of the simulator. All registeredThreadSimulatorStepEventListener
s will be notified. The dispatcher will first dispatch events when it is added to theThreadSimulator
using the setStepCallBack method.- Since:
- 2013-11-22
- See Also:
ThreadSimulator.setStepCallBack(ThreadSimulatorStepCallbackEnv)
-
-
Constructor Summary
Constructors Constructor Description ThreadSimulatorStepEventDispatcher()
Construct new dispatcher.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addThreadSimulatorStepEventListener(ThreadSimulatorStepEventListener listener)
Add a listener that will be notified of new events.void
callback(ThreadSimulator simulator, State state)
The callback method that is called from the simulator.int
getNumberOfListeners()
Get the number of listeners currently registered.void
removeThreadSimulatorStepEventListener(ThreadSimulatorStepEventListener listener)
Remove a registered listener that will then receive no more events.
-
-
-
Method Detail
-
addThreadSimulatorStepEventListener
public void addThreadSimulatorStepEventListener(ThreadSimulatorStepEventListener listener)
Add a listener that will be notified of new events.- Parameters:
listener
- the listener to add.
-
removeThreadSimulatorStepEventListener
public void removeThreadSimulatorStepEventListener(ThreadSimulatorStepEventListener listener)
Remove a registered listener that will then receive no more events.- Parameters:
listener
- the listener to remove.
-
getNumberOfListeners
public int getNumberOfListeners()
Get the number of listeners currently registered.- Returns:
- the number of listeners.
-
callback
public void callback(ThreadSimulator simulator, State state)
Description copied from interface:ThreadSimulatorStepCallbackHandler
The callback method that is called from the simulator.- Specified by:
callback
in interfaceThreadSimulatorStepCallbackHandler
- Parameters:
simulator
- theThreadSimulator
that makes the callback.state
- the newState
after the simulation cycle.- See Also:
ThreadSimulatorStepCallbackHandler.callback(org.robwork.sdurwsim.ThreadSimulator, org.robwork.sdurw_kinematics.State)
-
-