Fawkes API Fawkes Development Version

fawkes::InterfaceDispatcher Class Reference

Interface listener with dispatcher. More...

#include <>>

Inheritance diagram for fawkes::InterfaceDispatcher:

List of all members.

Public Member Functions

 InterfaceDispatcher (const char *listener_name, fawkes::Interface *iface, bool message_enqueueing=true)
 Constructor.
void set_message_enqueueing (bool enqueue)
 Set if received messages should be enqueued or not.
sigc::signal< void, Interface * > signal_data_changed ()
 Get "data changed" signal.
sigc::signal< void, Interface
*, Message * > 
signal_message_received ()
 Get "message received" signal.
sigc::signal< void, Interface * > signal_writer_added ()
 Get "writer added" signal.
sigc::signal< void, Interface * > signal_writer_removed ()
 Get "writer removed" signal.
sigc::signal< void, Interface * > signal_reader_added ()
 Get "reader added" signal.
sigc::signal< void, Interface * > signal_reader_removed ()
 Get "reader removed" signal.
virtual void bb_interface_data_changed (Interface *interface) throw ()
 BlackBoard data changed notification.
virtual bool bb_interface_message_received (Interface *interface, Message *message) throw ()
 BlackBoard message received notification.
virtual void bb_interface_writer_added (Interface *interface, unsigned int instance_serial) throw ()
 A writing instance has been opened for a watched interface.
virtual void bb_interface_writer_removed (Interface *interface, unsigned int instance_serial) throw ()
 A writing instance has been closed for a watched interface.
virtual void bb_interface_reader_added (Interface *interface, unsigned int instance_serial) throw ()
 A reading instance has been opened for a watched interface.
virtual void bb_interface_reader_removed (Interface *interface, unsigned int instance_serial) throw ()
 A reading instance has been closed for a watched interface.

Protected Member Functions

virtual void on_data_changed ()
 Internal event handler.
virtual void on_message_received ()
 Internal event handler.
virtual void on_writer_added ()
 Internal event handler.
virtual void on_writer_removed ()
 Internal event handler.
virtual void on_reader_added ()
 Internal event handler.
virtual void on_reader_removed ()
 Internal event handler.

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

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(), fawkes::Interface::is_writer(), on_data_changed(), on_message_received(), on_reader_added(), on_writer_added(), and on_writer_removed().


Member Function Documentation

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 180 of file interface_dispatcher.cpp.

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 187 of file interface_dispatcher.cpp.

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 212 of file interface_dispatcher.cpp.

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 220 of file interface_dispatcher.cpp.

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 196 of file interface_dispatcher.cpp.

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 204 of file interface_dispatcher.cpp.

void fawkes::InterfaceDispatcher::on_data_changed ( ) [protected, virtual]

Internal event handler.

Called by dispatcher to emit signal.

Definition at line 86 of file interface_dispatcher.cpp.

References fawkes::LockQueue< Type >::lock(), and fawkes::LockQueue< Type >::unlock().

Referenced by InterfaceDispatcher().

void fawkes::InterfaceDispatcher::on_message_received ( ) [protected, virtual]

Internal event handler.

Called by dispatcher to emit signal.

Definition at line 102 of file interface_dispatcher.cpp.

References fawkes::LockQueue< Type >::lock(), and fawkes::LockQueue< Type >::unlock().

Referenced by InterfaceDispatcher().

void fawkes::InterfaceDispatcher::on_reader_added ( ) [protected, virtual]

Internal event handler.

Called by dispatcher to emit signal.

Definition at line 151 of file interface_dispatcher.cpp.

References fawkes::LockQueue< Type >::lock(), and fawkes::LockQueue< Type >::unlock().

Referenced by InterfaceDispatcher().

void fawkes::InterfaceDispatcher::on_reader_removed ( ) [protected, virtual]

Internal event handler.

Called by dispatcher to emit signal.

Definition at line 167 of file interface_dispatcher.cpp.

References fawkes::LockQueue< Type >::lock(), and fawkes::LockQueue< Type >::unlock().

void fawkes::InterfaceDispatcher::on_writer_added ( ) [protected, virtual]

Internal event handler.

Called by dispatcher to emit signal.

Definition at line 119 of file interface_dispatcher.cpp.

References fawkes::LockQueue< Type >::lock(), and fawkes::LockQueue< Type >::unlock().

Referenced by InterfaceDispatcher().

void fawkes::InterfaceDispatcher::on_writer_removed ( ) [protected, virtual]

Internal event handler.

Called by dispatcher to emit signal.

Definition at line 135 of file interface_dispatcher.cpp.

References fawkes::LockQueue< Type >::lock(), and fawkes::LockQueue< Type >::unlock().

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.

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 76 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.

Returns:
"data changed" signal.

Definition at line 232 of file interface_dispatcher.cpp.

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 245 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.

Returns:
"reader added" signal.

Definition at line 278 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.

Returns:
"reader added" signal.

Definition at line 289 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.

Returns:
"writer added" signal.

Definition at line 256 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.

Returns:
"writer removed" signal.

Definition at line 267 of file interface_dispatcher.cpp.


The documentation for this class was generated from the following files:
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends