Fawkes API  Fawkes Development Version
fawkes::InterfaceDispatcher Class Reference

Interface listener with dispatcher. More...

#include <>>

Inheritance diagram for fawkes::InterfaceDispatcher:

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...
 
- Public Member Functions inherited from fawkes::BlackBoardInterfaceListener
 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...
 
- Protected Member Functions inherited from fawkes::BlackBoardInterfaceListener
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...
 
Interfacebbil_data_interface (const char *iuid) throw ()
 Get interface instance for given UID. More...
 
Interfacebbil_message_interface (const char *iuid) throw ()
 Get interface instance for given UID. More...
 
Interfacebbil_reader_interface (const char *iuid) throw ()
 Get interface instance for given UID. More...
 
Interfacebbil_writer_interface (const char *iuid) throw ()
 Get interface instance for given UID. More...
 

Additional Inherited Members

- Public Types inherited from fawkes::BlackBoardInterfaceListener
enum  QueueEntryType { DATA = 0, MESSAGES = 1, READER = 2, WRITER = 3 }
 Queue entry type. More...
 
typedef std::list< QueueEntryInterfaceQueue
 Queue of additions/removal of interfaces. More...
 
typedef std::map< std::string, Interface * > InterfaceMap
 Map of currently active event subscriptions. More...
 

Detailed Description

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.

Author
Tim Niemueller

Definition at line 35 of file interface_dispatcher.h.

Constructor & Destructor Documentation

◆ InterfaceDispatcher() [1/2]

fawkes::InterfaceDispatcher::InterfaceDispatcher ( const char *  listener_name,
fawkes::Interface iface,
bool  message_enqueueing = true 
)

Constructor.

Parameters
listener_namename of the listener
ifaceinterface to watch for data changes. Register this dispatcher as listener by yourself!
message_enqueueingtrue 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().

◆ InterfaceDispatcher() [2/2]

fawkes::InterfaceDispatcher::InterfaceDispatcher ( const char *  listener_name,
std::list< fawkes::Interface *>  ifaces,
bool  message_enqueueing = true 
)

Multi interface constructor.

Parameters
listener_namename of the listener
ifaceslist of interfaces to watch for data changes. Register this dispatcher as listener by yourself!
message_enqueueingtrue 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().

Member Function Documentation

◆ bb_interface_data_changed()

void fawkes::InterfaceDispatcher::bb_interface_data_changed ( Interface interface)
throw (
)
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.

Parameters
interfaceinterface instance that you supplied to bbil_add_data_interface()

Reimplemented from fawkes::BlackBoardInterfaceListener.

Definition at line 214 of file interface_dispatcher.cpp.

◆ bb_interface_message_received()

bool fawkes::InterfaceDispatcher::bb_interface_message_received ( Interface interface,
Message message 
)
throw (
)
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.

Parameters
interfaceinterface instance that you supplied to bbil_add_message_interface()
messagethe message that was sent
Returns
true to get the message enqueued afterwards as usual, false to prevent queuing of the message.

Reimplemented from fawkes::BlackBoardInterfaceListener.

Definition at line 221 of file interface_dispatcher.cpp.

◆ bb_interface_reader_added()

void fawkes::InterfaceDispatcher::bb_interface_reader_added ( Interface interface,
unsigned int  instance_serial 
)
throw (
)
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.

Parameters
interfaceinterface instance that you supplied to bbil_add_reader_interface()
instance_serialthe instance serial of the reading instance that has just been added.

Reimplemented from fawkes::BlackBoardInterfaceListener.

Definition at line 246 of file interface_dispatcher.cpp.

◆ bb_interface_reader_removed()

void fawkes::InterfaceDispatcher::bb_interface_reader_removed ( Interface interface,
unsigned int  instance_serial 
)
throw (
)
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.

Parameters
interfaceinterface instance that you supplied to bbil_add_reader_interface()
instance_serialthe instance serial of the reading instance that has just been removed.

Reimplemented from fawkes::BlackBoardInterfaceListener.

Definition at line 254 of file interface_dispatcher.cpp.

◆ bb_interface_writer_added()

void fawkes::InterfaceDispatcher::bb_interface_writer_added ( Interface interface,
unsigned int  instance_serial 
)
throw (
)
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.

Parameters
interfaceinterface instance that you supplied to bbil_add_writer_interface()
instance_serialthe instance serial of the writing instance that has just been added.

Reimplemented from fawkes::BlackBoardInterfaceListener.

Definition at line 230 of file interface_dispatcher.cpp.

◆ bb_interface_writer_removed()

void fawkes::InterfaceDispatcher::bb_interface_writer_removed ( Interface interface,
unsigned int  instance_serial 
)
throw (
)
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.

Parameters
interfaceinterface instance that you supplied to bbil_add_writer_interface()
instance_serialthe instance serial of the writing instance that has just been removed.

Reimplemented from fawkes::BlackBoardInterfaceListener.

Definition at line 238 of file interface_dispatcher.cpp.

◆ on_data_changed()

void fawkes::InterfaceDispatcher::on_data_changed ( )
protectedvirtual

Internal event handler.

Called by dispatcher to emit signal.

Definition at line 120 of file interface_dispatcher.cpp.

Referenced by InterfaceDispatcher().

◆ on_message_received()

void fawkes::InterfaceDispatcher::on_message_received ( )
protectedvirtual

Internal event handler.

Called by dispatcher to emit signal.

Definition at line 136 of file interface_dispatcher.cpp.

Referenced by InterfaceDispatcher().

◆ on_reader_added()

void fawkes::InterfaceDispatcher::on_reader_added ( )
protectedvirtual

Internal event handler.

Called by dispatcher to emit signal.

Definition at line 185 of file interface_dispatcher.cpp.

Referenced by InterfaceDispatcher().

◆ on_reader_removed()

void fawkes::InterfaceDispatcher::on_reader_removed ( )
protectedvirtual

Internal event handler.

Called by dispatcher to emit signal.

Definition at line 201 of file interface_dispatcher.cpp.

◆ on_writer_added()

void fawkes::InterfaceDispatcher::on_writer_added ( )
protectedvirtual

Internal event handler.

Called by dispatcher to emit signal.

Definition at line 153 of file interface_dispatcher.cpp.

Referenced by InterfaceDispatcher().

◆ on_writer_removed()

void fawkes::InterfaceDispatcher::on_writer_removed ( )
protectedvirtual

Internal event handler.

Called by dispatcher to emit signal.

Definition at line 169 of file interface_dispatcher.cpp.

Referenced by InterfaceDispatcher().

◆ set_message_enqueueing()

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.

Parameters
enqueuetrue 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.

◆ signal_data_changed()

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.

Returns
"data changed" signal.

Definition at line 266 of file interface_dispatcher.cpp.

Referenced by LaserGuiGtkWindow::open_interfaces(), Bumblebee2CalibGtkWindow::~Bumblebee2CalibGtkWindow(), NaoGuiGtkWindow::~NaoGuiGtkWindow(), and SkillGuiGtkWindow::~SkillGuiGtkWindow().

◆ signal_message_received()

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.

Returns
"message received" signal.

Definition at line 279 of file interface_dispatcher.cpp.

◆ signal_reader_added()

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.

Returns
"reader added" signal.

Definition at line 312 of file interface_dispatcher.cpp.

◆ signal_reader_removed()

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.

Returns
"reader added" signal.

Definition at line 323 of file interface_dispatcher.cpp.

◆ signal_writer_added()

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.

Returns
"writer added" signal.

Definition at line 290 of file interface_dispatcher.cpp.

◆ signal_writer_removed()

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.

Returns
"writer removed" signal.

Definition at line 301 of file interface_dispatcher.cpp.


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