Fawkes API
Fawkes Development Version
|
The BlackBoard. More...
#include <blackboard/blackboard.h>
Public Member Functions | |
virtual | ~BlackBoard () |
Virtual empty destructor. | |
virtual Interface * | open_for_reading (const char *interface_type, const char *identifier)=0 |
Open interface for reading. | |
virtual Interface * | open_for_writing (const char *interface_type, const char *identifier)=0 |
Open interface for writing. | |
virtual void | close (Interface *interface)=0 |
Close interface. | |
virtual InterfaceInfoList * | list_all ()=0 |
Get list of interfaces. | |
virtual bool | is_alive () const =0 throw () |
Check if the BlackBoard is still alive. | |
virtual bool | try_aliveness_restore ()=0 throw () |
Try to restore the aliveness of the BlackBoard instance. | |
virtual std::list< Interface * > | open_multiple_for_reading (const char *interface_type, const char *id_pattern="*")=0 |
Open multiple interfaces for reading. | |
template<class InterfaceType > | |
std::list< InterfaceType * > | open_multiple_for_reading (const char *id_pattern="*") |
Open all interfaces of given type for reading. | |
template<class InterfaceType > | |
InterfaceType * | open_for_reading (const char *identifier) |
Get interface of given type. | |
template<class InterfaceType > | |
InterfaceType * | open_for_writing (const char *identifier) |
Get writer interface of given type. | |
virtual void | register_listener (BlackBoardInterfaceListener *listener, unsigned int flags)=0 |
Register BB event listener. | |
virtual void | unregister_listener (BlackBoardInterfaceListener *listener)=0 |
Unregister BB interface listener. | |
virtual void | register_observer (BlackBoardInterfaceObserver *observer, unsigned int flags)=0 |
Register BB interface observer. | |
virtual void | unregister_observer (BlackBoardInterfaceObserver *observer)=0 |
Unregister BB interface observer. | |
std::string | demangle_fawkes_interface_name (const char *type) |
Produce interface name from C++ signature. | |
Static Public Attributes | |
static const unsigned int | BBIL_FLAG_DATA = 1 |
Data changed notification flag. | |
static const unsigned int | BBIL_FLAG_MESSAGES = 2 |
Message received notification flag. | |
static const unsigned int | BBIL_FLAG_READER = 4 |
Reader added/removed notification flag. | |
static const unsigned int | BBIL_FLAG_WRITER = 8 |
Writer added/removed notification flag. | |
static const unsigned int | BBIL_FLAG_ALL |
All interface listener notifications. | |
static const unsigned int | BBIO_FLAG_CREATED = 1 |
Interface creation notification flag. | |
static const unsigned int | BBIO_FLAG_DESTROYED = 2 |
Interface destruction notification flag. | |
static const unsigned int | BBIO_FLAG_ALL |
All interface observer notifications. |
The BlackBoard.
This class is the single one entry point for programs that use the BlackBoard. It is used to open and close interfaces, register and unregister listeners and observers and to maintain the BlackBoard shared memory segment. Not other classes shall be used directly.
The BlackBoard holds a number of so-called interfaces. The interfaces store data and provide means to pass messages. The BlackBoard also allows for registering listeners and observers. The listeners can be used to get events for specific interfaces while the observer gets global interface creation and destruction events for a specified set of types of interfaces.
An interface consists of a few parts. First there is the storage block. This is a chunk of memory in the shared memory segment where the actual data is stored. Then there is the accessor object, an instance of a derivate of the Interface class which is used to access the data in the shared memory segment. Last but not least there is an internal message queue that can be used to pass messages from readers to the writer (not the other way around!).
The interface manager keeps track of all the allocated interfaces. Events can be triggered if a specific interface changes (like logging the data to a file, sending it over the network or notifying another interface of such a change).
Interfaces can only be instantiated through the BlackBoard. The BlackBoard instantiates an interface on request and guarantees that the instance is fully initialized and usable. This cannot be guaranteed if instantiating an interface through any other means!
Interfaces can be opened for reading or writing, not both! There can be only one writer at a time for any given interface. Interfaces are identified via a type (which denotes the data and its semantics) and an identifier. There may be several interfaces for a given type, but the identifier has to be unique. The identifier is in most cases a well-known string that is used to share data among plugins.
Interfaces provide a way to propagate data to the writer via messages. Available messages types depend on the interface type. Only matching messages are accepted and can be queued.
The BlackBoard can operate in two modes, master and slave. Only the master creates and destroys the shared memory segment. Currently, the slave mode is not fully implemented and thus may not be used.
fawkes::BlackBoard::~BlackBoard | ( | ) | [virtual] |
Virtual empty destructor.
Definition at line 197 of file blackboard.cpp.
void fawkes::BlackBoard::close | ( | Interface * | interface | ) | [pure virtual] |
Close interface.
interface | interface to close |
Implemented in fawkes::RemoteBlackBoard, and fawkes::LocalBlackBoard.
Referenced by fawkes::BlackBoardNetworkHandler::~BlackBoardNetworkHandler(), fawkes::BlackBoardNetworkHandler::loop(), fawkes::BlackBoardNetworkHandler::client_disconnected(), BallPosLogThread::init(), BallPosLogThread::finalize(), BBLoggerThread::init(), BBLoggerThread::finalize(), BBLogReplayThread::finalize(), BlackBoardSynchronizationThread::writer_added(), BlackBoardSynchronizationThread::writer_removed(), ExampleBlackBoardThread::finalize(), WorldModelNetworkThread::finalize(), WorldModelNetworkThread::loop(), WorldModelNetworkThread::opponent_disapp_rcvd(), FestivalSynthThread::finalize(), FliteSynthThread::finalize(), JoystickSensorThread::finalize(), LaserSensorThread::init(), LaserSensorThread::finalize(), KatanaActThread::finalize(), LaserHtSensorProcThread::init(), LaserHtSensorProcThread::finalize(), LuaAgentExecutionThread::finalize(), SkillerExecutionThread::finalize(), PanTiltDirectedPerceptionThread::finalize(), PanTiltRX28Thread::finalize(), PanTiltSonyEviD100PThread::finalize(), AgentControlThread::finalize(), RefBoxCommThread::finalize(), RemoteBlackBoardRefBoxProcessor::~RemoteBlackBoardRefBoxProcessor(), WorldModelMultiCopyFuser::WorldModelMultiCopyFuser(), WorldModelObjPosAverageFuser::WorldModelObjPosAverageFuser(), WorldModelObjPosMajorityFuser::WorldModelObjPosMajorityFuser(), WorldModelObjPosMajorityFuser::~WorldModelObjPosMajorityFuser(), WorldModelThread::finalize(), XabslEngineThread::finalize(), and BatteryMonitorTreeView::rem_host().
std::string fawkes::BlackBoard::demangle_fawkes_interface_name | ( | const char * | type | ) |
Produce interface name from C++ signature.
This extracts the interface name for a mangled signature. It has has been coded with GCC (4) in mind and assumes interfaces to be in the fawkes namespace. It cannot deal with anythin else.
type | type name to strip |
Definition at line 210 of file blackboard.cpp.
Referenced by open_for_reading(), open_multiple_for_reading(), and open_for_writing().
bool fawkes::BlackBoard::is_alive | ( | ) | const throw () [pure virtual] |
Check if the BlackBoard is still alive.
Implemented in fawkes::RemoteBlackBoard, and fawkes::LocalBlackBoard.
Referenced by RemoteBlackBoardRefBoxProcessor::refbox_process(), and RemoteBlackBoardRefBoxProcessor::check_connection().
InterfaceInfoList * fawkes::BlackBoard::list_all | ( | ) | [pure virtual] |
Get list of interfaces.
Implemented in fawkes::RemoteBlackBoard, and fawkes::LocalBlackBoard.
Referenced by fawkes::BlackBoardNetworkHandler::loop().
Interface * fawkes::BlackBoard::open_for_reading | ( | const char * | type, |
const char * | identifier | ||
) | [pure virtual] |
Open interface for reading.
This will create a new interface instance of the given type. The result can be casted to the appropriate type.
type | type of the interface |
identifier | identifier of the interface |
OutOfMemoryException | thrown if there is not enough free space for the requested interface. |
Implemented in fawkes::RemoteBlackBoard, and fawkes::LocalBlackBoard.
Referenced by open_for_reading(), fawkes::BlackBoardNetworkHandler::loop(), BallPosLogThread::init(), BBLoggerThread::init(), ExampleBlackBoardThread::init(), LaserHtSensorProcThread::init(), LuaAgentExecutionThread::init(), EclipseAgentThread::init(), RefBoxCommThread::init(), WorldModelObjPosMajorityFuser::WorldModelObjPosMajorityFuser(), WorldModelSingleCopyFuser::WorldModelSingleCopyFuser(), WorldModelThread::init(), XabslEngineThread::init(), and BatteryMonitorTreeView::add_host().
InterfaceType * fawkes::BlackBoard::open_for_reading | ( | const char * | identifier | ) |
Get interface of given type.
This will open a new interface for reading just like the non-template version of open_for_reading(). But with the template method you will get a correctly typed object that you can use. An TypeMismatchException is thrown if the string representation of the type and the actual class type of the interface do not match.
identifier | identifier of the interface |
OutOfMemoryException | thrown if there is not enough free space for the requested interface. |
TypeMismatchException | thrown if type in interface_type and the actual class type do not fit. |
Definition at line 107 of file blackboard.h.
References demangle_fawkes_interface_name(), and open_for_reading().
Interface * fawkes::BlackBoard::open_for_writing | ( | const char * | type, |
const char * | identifier | ||
) | [pure virtual] |
Open interface for writing.
This will create a new interface instance of the given type. The result can be casted to the appropriate type. This will only succeed if there is not already a writer for the given interface type/id!
type | type of the interface |
identifier | identifier of the interface |
OutOfMemoryException | thrown if there is not enough free space for the requested interface. |
BlackBoardWriterActiveException | thrown if there is already a writing instance with the same type/id |
Implemented in fawkes::RemoteBlackBoard, and fawkes::LocalBlackBoard.
Referenced by open_for_writing(), fawkes::BlackBoardNetworkHandler::loop(), BBLoggerThread::init(), BBLogReplayThread::init(), BlackBoardSynchronizationThread::writer_added(), ExampleBlackBoardThread::init(), WorldModelNetworkThread::init(), WorldModelNetworkThread::pose_rcvd(), WorldModelNetworkThread::ball_pos_rcvd(), WorldModelNetworkThread::global_ball_pos_rcvd(), WorldModelNetworkThread::opponent_pose_rcvd(), FestivalSynthThread::init(), FliteSynthThread::init(), JoystickSensorThread::init(), LaserSensorThread::init(), KatanaActThread::init(), LaserHtSensorProcThread::init(), LuaAgentExecutionThread::init(), SkillerExecutionThread::init(), PanTiltDirectedPerceptionThread::init(), PanTiltRX28Thread::init(), PanTiltSonyEviD100PThread::init(), AgentControlThread::init(), EclipseAgentThread::init(), RefBoxCommThread::init(), WorldModelMultiCopyFuser::WorldModelMultiCopyFuser(), WorldModelObjPosAverageFuser::WorldModelObjPosAverageFuser(), WorldModelObjPosMajorityFuser::WorldModelObjPosMajorityFuser(), and WorldModelSingleCopyFuser::WorldModelSingleCopyFuser().
InterfaceType * fawkes::BlackBoard::open_for_writing | ( | const char * | identifier | ) |
Get writer interface of given type.
This will open a new interface for writing just like the non-template version of open_for_writing(). But with the template method you will get a correctly typed object that you can use. An TypeMismatchException is thrown if the string representation of the type and the actual class type of the interface do not match.
identifier | identifier of the interface |
OutOfMemoryException | thrown if there is not enough free space for the requested interface. |
BlackBoardWriterActiveException | thrown if there is already a writing instance with the same type/id |
TypeMismatchException | thrown if type in interface_type and the actual class type do not fit. |
Definition at line 155 of file blackboard.h.
References demangle_fawkes_interface_name(), and open_for_writing().
std::list< Interface * > fawkes::BlackBoard::open_multiple_for_reading | ( | const char * | type, |
const char * | id_pattern = "*" |
||
) | [pure virtual] |
Open multiple interfaces for reading.
This will create interface instances for currently registered interfaces of the given type that match the given ID pattern. The result can be casted to the appropriate type.
type | type of the interface |
id_pattern | pattern of interface IDs to open, supports wildcards similar to filenames (*, ?, []), see "man fnmatch" for all supported. |
Implemented in fawkes::RemoteBlackBoard, and fawkes::LocalBlackBoard.
Referenced by open_multiple_for_reading(), WorldModelMultiCopyFuser::WorldModelMultiCopyFuser(), WorldModelObjPosAverageFuser::WorldModelObjPosAverageFuser(), and WorldModelObjPosMajorityFuser::WorldModelObjPosMajorityFuser().
std::list< InterfaceType * > fawkes::BlackBoard::open_multiple_for_reading | ( | const char * | id_pattern = "*" | ) |
Open all interfaces of given type for reading.
This will create interface instances for all currently registered interfaces of the given type. The result can be casted to the appropriate type.
id_pattern | pattern of interface IDs to open, supports wildcards similar to filenames (*, ?, []), see "man fnmatch" for all supported. |
Definition at line 126 of file blackboard.h.
References demangle_fawkes_interface_name(), and open_multiple_for_reading().
void fawkes::BlackBoard::register_listener | ( | BlackBoardInterfaceListener * | listener, |
unsigned int | flags | ||
) | [pure virtual] |
Register BB event listener.
listener | BlackBoard event listener to register |
flags | an or'ed combination of BBIL_FLAG_DATA, BBIL_FLAG_READER, BBIL_FLAG_WRITER and BBIL_FLAG_INTERFACE. Only for the given types the event listener is registered. BBIL_FLAG_ALL can be supplied to register for all events. |
Implemented in fawkes::RemoteBlackBoard, and fawkes::LocalBlackBoard.
Referenced by fawkes::BlackBoardNetHandlerInterfaceListener::BlackBoardNetHandlerInterfaceListener(), BBLoggerThread::init(), SyncInterfaceListener::SyncInterfaceListener(), FestivalSynthThread::init(), FliteSynthThread::init(), KatanaActThread::init(), SkillerExecutionThread::init(), PanTiltDirectedPerceptionThread::init(), PanTiltRX28Thread::init(), PanTiltSonyEviD100PThread::init(), and BatteryMonitorTreeView::add_host().
void fawkes::BlackBoard::register_observer | ( | BlackBoardInterfaceObserver * | observer, |
unsigned int | flags | ||
) | [pure virtual] |
Register BB interface observer.
observer | BlackBoard interface observer to register |
flags | an or'ed combination of BBIO_FLAG_CREATED, BBIO_FLAG_DESTROYED |
Implemented in fawkes::RemoteBlackBoard, and fawkes::LocalBlackBoard.
Referenced by WorldModelMultiCopyFuser::WorldModelMultiCopyFuser(), WorldModelObjPosAverageFuser::WorldModelObjPosAverageFuser(), and WorldModelObjPosMajorityFuser::WorldModelObjPosMajorityFuser().
bool fawkes::BlackBoard::try_aliveness_restore | ( | ) | throw () [pure virtual] |
Try to restore the aliveness of the BlackBoard instance.
Note that even though the aliveness of the BlackBoard is restored single interfaces may still be invalid. That can for instance happen if a remote connection is re-established and a writer has been created during the downtime and an own writer instance of that very interface cannot be restored.
Implemented in fawkes::RemoteBlackBoard, and fawkes::LocalBlackBoard.
void fawkes::BlackBoard::unregister_listener | ( | BlackBoardInterfaceListener * | listener | ) | [pure virtual] |
Unregister BB interface listener.
This will remove the given BlackBoard interface listener from any event that it was previously registered for.
listener | BlackBoard event listener to remove |
Implemented in fawkes::RemoteBlackBoard, and fawkes::LocalBlackBoard.
Referenced by fawkes::BlackBoardNetHandlerInterfaceListener::~BlackBoardNetHandlerInterfaceListener(), BBLoggerThread::finalize(), SyncInterfaceListener::~SyncInterfaceListener(), FestivalSynthThread::finalize(), FliteSynthThread::finalize(), KatanaActThread::finalize(), SkillerExecutionThread::finalize(), PanTiltDirectedPerceptionThread::finalize(), PanTiltRX28Thread::finalize(), PanTiltSonyEviD100PThread::finalize(), and BatteryMonitorTreeView::rem_host().
void fawkes::BlackBoard::unregister_observer | ( | BlackBoardInterfaceObserver * | observer | ) | [pure virtual] |
Unregister BB interface observer.
This will remove the given BlackBoard event listener from any event that it was previously registered for.
observer | BlackBoard event listener to remove |
Implemented in fawkes::RemoteBlackBoard, and fawkes::LocalBlackBoard.
Referenced by WorldModelObjPosMajorityFuser::~WorldModelObjPosMajorityFuser().
const unsigned int fawkes::BlackBoard::BBIL_FLAG_ALL [static] |
All interface listener notifications.
Definition at line 75 of file blackboard.h.
Referenced by fawkes::BlackBoardNetHandlerInterfaceListener::BlackBoardNetHandlerInterfaceListener().
const unsigned int fawkes::BlackBoard::BBIL_FLAG_DATA = 1 [static] |
Data changed notification flag.
Definition at line 71 of file blackboard.h.
Referenced by fawkes::BlackBoardNotifier::register_listener(), JoystickBlackBoardLogger::JoystickBlackBoardLogger(), LaserDeadSpotCalibrator::LaserDeadSpotCalibrator(), LaserGuiGtkWindow::on_connect(), LaserGuiGtkWindow::on_resolution_toggled(), and LaserGuiHildonWindow::on_connect().
const unsigned int fawkes::BlackBoard::BBIL_FLAG_MESSAGES = 2 [static] |
Message received notification flag.
Definition at line 72 of file blackboard.h.
Referenced by fawkes::BlackBoardNotifier::register_listener().
const unsigned int fawkes::BlackBoard::BBIL_FLAG_READER = 4 [static] |
Reader added/removed notification flag.
Definition at line 73 of file blackboard.h.
Referenced by fawkes::BlackBoardNotifier::register_listener().
const unsigned int fawkes::BlackBoard::BBIL_FLAG_WRITER = 8 [static] |
Writer added/removed notification flag.
Definition at line 74 of file blackboard.h.
Referenced by fawkes::BlackBoardNotifier::register_listener(), and LaserGuiHildonWindow::on_connect().
const unsigned int fawkes::BlackBoard::BBIO_FLAG_ALL [static] |
All interface observer notifications.
Definition at line 79 of file blackboard.h.
const unsigned int fawkes::BlackBoard::BBIO_FLAG_CREATED = 1 [static] |
Interface creation notification flag.
Definition at line 77 of file blackboard.h.
Referenced by fawkes::BlackBoardNotifier::register_observer(), WorldModelMultiCopyFuser::WorldModelMultiCopyFuser(), WorldModelObjPosAverageFuser::WorldModelObjPosAverageFuser(), and WorldModelObjPosMajorityFuser::WorldModelObjPosMajorityFuser().
const unsigned int fawkes::BlackBoard::BBIO_FLAG_DESTROYED = 2 [static] |
Interface destruction notification flag.
Definition at line 78 of file blackboard.h.
Referenced by fawkes::BlackBoardNotifier::register_observer().