RobWorkProject
24.12.4-
|
Event is used for managing subscribtions and firing of events. More...
#include <Event.hpp>
Public Types | |
typedef rw::core::EventListener< CallBackMethod > | Listener |
typedef std::list< Listener >::const_iterator | ConstListenerIterator |
iterator of event listeners | |
Public Member Functions | |
Event () | |
constructor | |
void | add (CallBackMethod callback, const void *obj=nullptr, int id=0) |
Descructor. More... | |
void | remove (void *obj) |
Removes all callback method from a given obj. More... | |
void | remove (void *obj, int id) |
Removes all callback methods associated with the obj and id. More... | |
std::pair< ConstListenerIterator, ConstListenerIterator > | getListeners () |
Returns list of listeners to the event. More... | |
std::list< Listener > & | getListenerList () |
Get the list of listeners for this event. More... | |
Public Attributes | |
FireFunctor< CallBackMethod, T1, T2, T3, T4, _n1 > | fire |
Fires the event. More... | |
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:
|
inline |
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
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) |
|
inline |
Get the list of listeners for this event.
|
inline |
Returns list of listeners to the event.
|
inline |
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.
obj | [in] Object for which to remove listeners |
|
inline |
Removes all callback methods associated with the obj and id.
obj | [in] Object associated with the callback |
id | [in] Id of the callback |
FireFunctor<CallBackMethod, T1, T2, T3, T4, _n1> fire |
Fires the event.
The signature of the fire method depends on the FireEventMethod template argument.