Fawkes API
Fawkes Development Version
|
Interface listener with dispatcher. More...
#include <>>
Public Member Functions | |
InterfaceDispatcher (const char *listener_name, fawkes::Interface *iface, bool message_enqueueing=true) | |
Constructor. More... | |
InterfaceDispatcher (const char *listener_name_prefix, std::list< fawkes::Interface *> ifaces, bool message_enqueueing=true) | |
Multi interface constructor. More... | |
void | set_message_enqueueing (bool enqueue) |
Set if received messages should be enqueued or not. More... | |
sigc::signal< void, Interface * > | signal_data_changed () |
Get "data changed" signal. More... | |
sigc::signal< void, Interface *, Message * > | signal_message_received () |
Get "message received" signal. More... | |
sigc::signal< void, Interface * > | signal_writer_added () |
Get "writer added" signal. More... | |
sigc::signal< void, Interface * > | signal_writer_removed () |
Get "writer removed" signal. More... | |
sigc::signal< void, Interface * > | signal_reader_added () |
Get "reader added" signal. More... | |
sigc::signal< void, Interface * > | signal_reader_removed () |
Get "reader removed" signal. More... | |
virtual void | bb_interface_data_changed (Interface *interface) throw () |
BlackBoard data changed notification. More... | |
virtual bool | bb_interface_message_received (Interface *interface, Message *message) throw () |
BlackBoard message received notification. More... | |
virtual void | bb_interface_writer_added (Interface *interface, unsigned int instance_serial) throw () |
A writing instance has been opened for a watched interface. More... | |
virtual void | bb_interface_writer_removed (Interface *interface, unsigned int instance_serial) throw () |
A writing instance has been closed for a watched interface. More... | |
virtual void | bb_interface_reader_added (Interface *interface, unsigned int instance_serial) throw () |
A reading instance has been opened for a watched interface. More... | |
virtual void | bb_interface_reader_removed (Interface *interface, unsigned int instance_serial) throw () |
A reading instance has been closed for a watched interface. More... | |
![]() | |
BlackBoardInterfaceListener (const char *name_format,...) | |
Constructor. More... | |
virtual | ~BlackBoardInterfaceListener () |
Destructor. More... | |
const char * | bbil_name () const |
Get BBIL name. More... | |
Protected Member Functions | |
virtual void | on_data_changed () |
Internal event handler. More... | |
virtual void | on_message_received () |
Internal event handler. More... | |
virtual void | on_writer_added () |
Internal event handler. More... | |
virtual void | on_writer_removed () |
Internal event handler. More... | |
virtual void | on_reader_added () |
Internal event handler. More... | |
virtual void | on_reader_removed () |
Internal event handler. More... | |
![]() | |
void | bbil_add_data_interface (Interface *interface) |
Add an interface to the data modification watch list. More... | |
void | bbil_add_message_interface (Interface *interface) |
Add an interface to the message received watch list. More... | |
void | bbil_add_reader_interface (Interface *interface) |
Add an interface to the reader addition/removal watch list. More... | |
void | bbil_add_writer_interface (Interface *interface) |
Add an interface to the writer addition/removal watch list. More... | |
void | bbil_remove_data_interface (Interface *interface) |
Remove an interface to the data modification watch list. More... | |
void | bbil_remove_message_interface (Interface *interface) |
Remove an interface to the message received watch list. More... | |
void | bbil_remove_reader_interface (Interface *interface) |
Remove an interface to the reader addition/removal watch list. More... | |
void | bbil_remove_writer_interface (Interface *interface) |
Remove an interface to the writer addition/removal watch list. More... | |
Interface * | bbil_data_interface (const char *iuid) throw () |
Get interface instance for given UID. More... | |
Interface * | bbil_message_interface (const char *iuid) throw () |
Get interface instance for given UID. More... | |
Interface * | bbil_reader_interface (const char *iuid) throw () |
Get interface instance for given UID. More... | |
Interface * | bbil_writer_interface (const char *iuid) throw () |
Get interface instance for given UID. More... | |
Additional Inherited Members | |
![]() | |
enum | QueueEntryType { DATA = 0, MESSAGES = 1, READER = 2, WRITER = 3 } |
Queue entry type. More... | |
typedef std::list< QueueEntry > | InterfaceQueue |
Queue of additions/removal of interfaces. More... | |
typedef std::map< std::string, Interface * > | InterfaceMap |
Map of currently active event subscriptions. More... | |
Interface listener with dispatcher.
An instance is used to react to a data changed event by triggering a signal dispatcher (which is thread-safe and can be used across thread borders in Glib/Gtk apps. You have to register this listener with BlackBoard::BBIL_FLAGS_DATA flag by yourself. Do not forget to unregister.
Definition at line 35 of file interface_dispatcher.h.
fawkes::InterfaceDispatcher::InterfaceDispatcher | ( | const char * | listener_name, |
fawkes::Interface * | iface, | ||
bool | message_enqueueing = true |
||
) |
Constructor.
listener_name | name of the listener |
iface | interface to watch for data changes. Register this dispatcher as listener by yourself! |
message_enqueueing | true to enqueue messages after the message received event handler has been called, false to drop the message afterwards. |
Definition at line 46 of file interface_dispatcher.cpp.
References fawkes::BlackBoardInterfaceListener::bbil_add_data_interface(), fawkes::BlackBoardInterfaceListener::bbil_add_message_interface(), fawkes::BlackBoardInterfaceListener::bbil_add_reader_interface(), fawkes::BlackBoardInterfaceListener::bbil_add_writer_interface(), and fawkes::Interface::is_writer().
fawkes::InterfaceDispatcher::InterfaceDispatcher | ( | const char * | listener_name, |
std::list< fawkes::Interface *> | ifaces, | ||
bool | message_enqueueing = true |
||
) |
Multi interface constructor.
listener_name | name of the listener |
ifaces | list of interfaces to watch for data changes. Register this dispatcher as listener by yourself! |
message_enqueueing | true to enqueue messages after the message received event handler has been called, false to drop the message afterwards. |
Definition at line 71 of file interface_dispatcher.cpp.
References fawkes::BlackBoardInterfaceListener::bbil_add_data_interface(), fawkes::BlackBoardInterfaceListener::bbil_add_message_interface(), fawkes::BlackBoardInterfaceListener::bbil_add_reader_interface(), fawkes::BlackBoardInterfaceListener::bbil_add_writer_interface(), on_data_changed(), on_message_received(), on_reader_added(), on_writer_added(), and on_writer_removed().
|
virtual |
BlackBoard data changed notification.
This is called whenever the data in an interface that you registered for is modified. This happens if a writer calls the Interface::write() method.
interface | interface instance that you supplied to bbil_add_data_interface() |
Reimplemented from fawkes::BlackBoardInterfaceListener.
Definition at line 214 of file interface_dispatcher.cpp.
|
virtual |
BlackBoard message received notification.
This is called whenever a message is received for this interface. This method is only called for writing instances of an interface, never on reading instances. If you have processed the message already, you can order that the message is not enqueued by returning false. Returning true will enqueue the message as usual. You should only do very (very!) quick tasks directly in this method, as it is out of the regular thread context and can harm performance of other plugins and the system as a whole. Note that if you decide to return false the message is not referenced. If you want to keep it longer you have to ref() it by yourself. An example where this would really make sense is a "STOP" message for the motor, which needs to be processed ASAP and maybe even waiting a couple of miliseconds for the next cycle is not acceptable.
interface | interface instance that you supplied to bbil_add_message_interface() |
message | the message that was sent |
Reimplemented from fawkes::BlackBoardInterfaceListener.
Definition at line 221 of file interface_dispatcher.cpp.
|
virtual |
A reading instance has been opened for a watched interface.
This is called whenever a reading instance of the interface you are watching is opened.
interface | interface instance that you supplied to bbil_add_reader_interface() |
instance_serial | the instance serial of the reading instance that has just been added. |
Reimplemented from fawkes::BlackBoardInterfaceListener.
Definition at line 246 of file interface_dispatcher.cpp.
|
virtual |
A reading instance has been closed for a watched interface.
This is called whenever a reading instance of an interface you are watching is closed.
interface | interface instance that you supplied to bbil_add_reader_interface() |
instance_serial | the instance serial of the reading instance that has just been removed. |
Reimplemented from fawkes::BlackBoardInterfaceListener.
Definition at line 254 of file interface_dispatcher.cpp.
|
virtual |
A writing instance has been opened for a watched interface.
This is called whenever a writing instance of the interface you are watching is opened.
interface | interface instance that you supplied to bbil_add_writer_interface() |
instance_serial | the instance serial of the writing instance that has just been added. |
Reimplemented from fawkes::BlackBoardInterfaceListener.
Definition at line 230 of file interface_dispatcher.cpp.
|
virtual |
A writing instance has been closed for a watched interface.
This is called whenever a writing instance of an interface you are watching is closed.
interface | interface instance that you supplied to bbil_add_writer_interface() |
instance_serial | the instance serial of the writing instance that has just been removed. |
Reimplemented from fawkes::BlackBoardInterfaceListener.
Definition at line 238 of file interface_dispatcher.cpp.
|
protectedvirtual |
Internal event handler.
Called by dispatcher to emit signal.
Definition at line 120 of file interface_dispatcher.cpp.
Referenced by InterfaceDispatcher().
|
protectedvirtual |
Internal event handler.
Called by dispatcher to emit signal.
Definition at line 136 of file interface_dispatcher.cpp.
Referenced by InterfaceDispatcher().
|
protectedvirtual |
Internal event handler.
Called by dispatcher to emit signal.
Definition at line 185 of file interface_dispatcher.cpp.
Referenced by InterfaceDispatcher().
|
protectedvirtual |
Internal event handler.
Called by dispatcher to emit signal.
Definition at line 201 of file interface_dispatcher.cpp.
|
protectedvirtual |
Internal event handler.
Called by dispatcher to emit signal.
Definition at line 153 of file interface_dispatcher.cpp.
Referenced by InterfaceDispatcher().
|
protectedvirtual |
Internal event handler.
Called by dispatcher to emit signal.
Definition at line 169 of file interface_dispatcher.cpp.
Referenced by InterfaceDispatcher().
void fawkes::InterfaceDispatcher::set_message_enqueueing | ( | bool | enqueue | ) |
Set if received messages should be enqueued or not.
The message received event handler can cause the message to be enqueued or not. The default is to enqueue the messages.
enqueue | true to cause messages to be enqueued, false to cause the messages not to be enqueued after they have been processed |
Definition at line 110 of file interface_dispatcher.cpp.
sigc::signal< void, Interface * > fawkes::InterfaceDispatcher::signal_data_changed | ( | ) |
Get "data changed" signal.
The signal is emitted if the data of the interface has changed.
Definition at line 266 of file interface_dispatcher.cpp.
Referenced by LaserGuiGtkWindow::open_interfaces(), Bumblebee2CalibGtkWindow::~Bumblebee2CalibGtkWindow(), NaoGuiGtkWindow::~NaoGuiGtkWindow(), and SkillGuiGtkWindow::~SkillGuiGtkWindow().
sigc::signal< void, Interface *, Message * > fawkes::InterfaceDispatcher::signal_message_received | ( | ) |
Get "message received" signal.
The signal is emitted if a message has been received via the watched interface. Note that this signal is only emitted on writing instances of an interface.
Definition at line 279 of file interface_dispatcher.cpp.
sigc::signal< void, Interface * > fawkes::InterfaceDispatcher::signal_reader_added | ( | ) |
Get "reader added" signal.
The signal is emitted if a reader has been added to the interface.
Definition at line 312 of file interface_dispatcher.cpp.
sigc::signal< void, Interface * > fawkes::InterfaceDispatcher::signal_reader_removed | ( | ) |
Get "reader removed" signal.
The signal is emitted if a reader has been removed from the interface.
Definition at line 323 of file interface_dispatcher.cpp.
sigc::signal< void, Interface * > fawkes::InterfaceDispatcher::signal_writer_added | ( | ) |
Get "writer added" signal.
The signal is emitted if a writer has been added to the interface.
Definition at line 290 of file interface_dispatcher.cpp.
sigc::signal< void, Interface * > fawkes::InterfaceDispatcher::signal_writer_removed | ( | ) |
Get "writer removed" signal.
The signal is emitted if a writer has been removed from the interface.
Definition at line 301 of file interface_dispatcher.cpp.