Package org.robwork.sdurw
Class WorkCellChangedEvent
- java.lang.Object
-
- org.robwork.sdurw.WorkCellChangedEvent
-
public class WorkCellChangedEvent extends java.lang.Object
Event is used for managing subscribtions and firing of events.
Event is used for managing subscribtions and firing of events. The signature of the
callback method and the fire method is termined through the template arguments.
CallBackMethod, defines the signature of the callback method needed for subscribing to
the event.
FireEventMethod, defines the interface for firing events.
Example of usage in RobWorkStudio:
In: RobWorkStudio.hpp typedef boost::functionvoid(const rw::kinematics::State) StateChangedListener; typedef EventStateChangedListener, StateChangedListener StateChangedEvent; StateChangedEvent stateChangedEvent() { return _stateChangedEvent; } void fireStateChangedEvent(const rw::kinematics::State state) { for(const StateChangedEvent::Listener listener : stateChangedEvent().getListeners()) { listener.callback(state); } } In: RobWorkStudio.cpp RobWorkStudio::RobWorkStudio(...): _stateChangedEvent(boost::bind(RobWorkStudio::fireStateChangedEvent, this, boost::arg1())), ... { ... }
-
-
Constructor Summary
Constructors Constructor Description WorkCellChangedEvent()
constructorWorkCellChangedEvent(long cPtr, boolean cMemoryOwn)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(SWIGTYPE_p_WorkCellChangedListener callback)
Descructor.
Adds a listener to the event
Adds callback as a listener to the event.void
add(SWIGTYPE_p_WorkCellChangedListener callback, SWIGTYPE_p_void obj)
Descructor.
Adds a listener to the event
Adds callback as a listener to the event.void
add(SWIGTYPE_p_WorkCellChangedListener callback, SWIGTYPE_p_void obj, int id)
Descructor.
Adds a listener to the event
Adds callback as a listener to the event.void
delete()
static long
getCPtr(WorkCellChangedEvent obj)
SWIGTYPE_p_rw__core__FireFunctorT_WorkCellChangedListener_int_rw__core___n1_rw__core___n1_rw__core___n1_rw__core___n1_t
getFire()
Fires the event
The signature of the fire method depends on the FireEventMethod template argument.SWIGTYPE_p_std__listT_rw__core__EventListenerT_WorkCellChangedListener_t_t
getListenerList()
Get the list of listeners for this event.void
remove(SWIGTYPE_p_void obj)
Removes all callback method from a given obj
All callbacks associated with obj are removed.void
remove(SWIGTYPE_p_void obj, int id)
Removes all callback methods associated with the obj and id.
void
setFire(SWIGTYPE_p_rw__core__FireFunctorT_WorkCellChangedListener_int_rw__core___n1_rw__core___n1_rw__core___n1_rw__core___n1_t value)
Fires the event
The signature of the fire method depends on the FireEventMethod template argument.
-
-
-
Method Detail
-
getCPtr
public static long getCPtr(WorkCellChangedEvent obj)
-
delete
public void delete()
-
add
public void add(SWIGTYPE_p_WorkCellChangedListener callback, SWIGTYPE_p_void obj, int id)
Descructor.
Adds a listener to the event
Adds callback as a listener to the event. The optional obj and
id are stored with callback to enable removing listeners. It is
recommended to set obj as the object on which the callback is defined.
Direct comparison of boost::function pointers does not work on all
platform. It is thus necessary to provide the user with the optional
id to enable removing a specific callback.
Typical usage
void MyPlugin::frameSelectedListener(rw::kinematics::Frame* frame) { ... } void MyPlugin::initialize() { getRobWorkStudio()-frameSelectedEvent().add( boost::bind(MyPlugin::frameSelectedListener, this, boost::arg1()), this); }
- Parameters:
callback
- [in] The callback function
obj
- [in] Pointer to object associated with the listener (only used
when removing listeners)
id
- [in] Id associated with the callback (only used for removing a
specific listener)
-
add
public void add(SWIGTYPE_p_WorkCellChangedListener callback, SWIGTYPE_p_void obj)
Descructor.
Adds a listener to the event
Adds callback as a listener to the event. The optional obj and
id are stored with callback to enable removing listeners. It is
recommended to set obj as the object on which the callback is defined.
Direct comparison of boost::function pointers does not work on all
platform. It is thus necessary to provide the user with the optional
id to enable removing a specific callback.
Typical usage
void MyPlugin::frameSelectedListener(rw::kinematics::Frame* frame) { ... } void MyPlugin::initialize() { getRobWorkStudio()-frameSelectedEvent().add( boost::bind(MyPlugin::frameSelectedListener, this, boost::arg1()), this); }
- Parameters:
callback
- [in] The callback function
obj
- [in] Pointer to object associated with the listener (only used
when removing listeners)
-
add
public void add(SWIGTYPE_p_WorkCellChangedListener callback)
Descructor.
Adds a listener to the event
Adds callback as a listener to the event. The optional obj and
id are stored with callback to enable removing listeners. It is
recommended to set obj as the object on which the callback is defined.
Direct comparison of boost::function pointers does not work on all
platform. It is thus necessary to provide the user with the optional
id to enable removing a specific callback.
Typical usage
void MyPlugin::frameSelectedListener(rw::kinematics::Frame* frame) { ... } void MyPlugin::initialize() { getRobWorkStudio()-frameSelectedEvent().add( boost::bind(MyPlugin::frameSelectedListener, this, boost::arg1()), this); }
- Parameters:
callback
- [in] The callback function
-
remove
public void remove(SWIGTYPE_p_void obj)
Removes all callback method from a given obj
All callbacks associated with obj are removed. Typical use will be to remove
all callbacks to an object before it is destroyed.
- Parameters:
obj
- [in] Object for which to remove listeners
-
remove
public void remove(SWIGTYPE_p_void obj, int id)
Removes all callback methods associated with the obj and id.
- Parameters:
obj
- [in] Object associated with the callbackid
- [in] Id of the callback
-
getListenerList
public SWIGTYPE_p_std__listT_rw__core__EventListenerT_WorkCellChangedListener_t_t getListenerList()
Get the list of listeners for this event.- Returns:
- list of listeners.
-
setFire
public void setFire(SWIGTYPE_p_rw__core__FireFunctorT_WorkCellChangedListener_int_rw__core___n1_rw__core___n1_rw__core___n1_rw__core___n1_t value)
Fires the event
The signature of the fire method depends on the FireEventMethod template argument.
-
getFire
public SWIGTYPE_p_rw__core__FireFunctorT_WorkCellChangedListener_int_rw__core___n1_rw__core___n1_rw__core___n1_rw__core___n1_t getFire()
Fires the event
The signature of the fire method depends on the FireEventMethod template argument.
-
-