Fawkes API
Fawkes Development Version
|
BlackBoard interface observer. More...
#include <>>
Public Member Functions | |
BlackBoardInterfaceObserver () | |
Empty constructor. More... | |
virtual | ~BlackBoardInterfaceObserver () |
Destructor. More... | |
virtual void | bb_interface_created (const char *type, const char *id) throw () |
BlackBoard interface created notification. More... | |
virtual void | bb_interface_destroyed (const char *type, const char *id) throw () |
BlackBoard interface destroyed notification. More... | |
Protected Types | |
typedef LockMap< std::string, std::list< std::string > > | ObservedInterfaceLockMap |
Type for lockable interface type hash sets. More... | |
typedef ObservedInterfaceLockMap::iterator | ObservedInterfaceLockMapIterator |
Type for iterator of lockable interface type hash sets. More... | |
Protected Member Functions | |
void | bbio_add_observed_create (const char *type_pattern, const char *id_pattern="*") throw () |
Add interface creation type to watch list. More... | |
void | bbio_add_observed_destroy (const char *type_pattern, const char *id_pattern="*") throw () |
Add interface destruction type to watch list. More... | |
ObservedInterfaceLockMap * | bbio_get_observed_create () throw () |
Get interface creation type watch list. More... | |
ObservedInterfaceLockMap * | bbio_get_observed_destroy () throw () |
Get interface destriction type watch list. More... | |
Friends | |
class | BlackBoardNotifier |
BlackBoard interface observer.
Derive this class if you want to be notified of specific BlackBoard events that are not tied to particular instances of interfaces like create and destroy operations.
The bb_interface_* methods are called during the appropriate operation. The operation that you carry out in this event handler really has to be damn fast, or the performance of the whole system will suffer severely. For this reason use this notification facility only rarely and only register for the appropriate events.
This class provides the basic infrastructure that can be used to build your own observer. During the life time of your observer you first add all the interfaces to the appropriate structures that you want to listen for and add the interface types where you want to be notified of creation events.
The interface created event is raised whenever an interface of a type that you registered for is created. The destroyed event is raised if the an interface is irrecoverable deleted from the BlackBoard. This happens when the last reader or writer closes the interface. That means neither a writer nor any reader has a particular interface still opened.
Here is a simple life cycle of a BlackBoard interface observer: First you add all the interface types that you want to observe with calls to bbio_add_interface_create_type() and bbio_add_interface_destroy_type(). Then you register the observer with InterfaceManager::register_observer(). From then on you are notified of the events. Afterwards you unregister your observer to no longer receive events.
Definition at line 34 of file interface_observer.h.
|
protected |
Type for lockable interface type hash sets.
Definition at line 53 of file interface_observer.h.
|
protected |
Type for iterator of lockable interface type hash sets.
Definition at line 56 of file interface_observer.h.
fawkes::BlackBoardInterfaceObserver::BlackBoardInterfaceObserver | ( | ) |
Empty constructor.
Definition at line 68 of file interface_observer.cpp.
|
virtual |
Destructor.
Definition at line 73 of file interface_observer.cpp.
|
virtual |
BlackBoard interface created notification.
This is called whenever an interface is created for a type that you registered for.
type | type of the interface. If you want to store this make a copy as it is not guaranteed that the supplied string exists for longer than the duration of the method call |
id | ID of the newly created interface. If you want to store this make a copy as it is not guaranteed that the supplied string exists for longer than the duration of the method call |
Reimplemented in RobotStatePublisherThread, fawkes::tf::TransformListener, RosTfThread, RosLaserScanThread, LaserPointCloudThread, MongoLogBlackboardThread, RosPosition3DThread, RosJointThread, fawkes::openni::HandIfObserver, fawkes::openni::SkelIfObserver, and fawkes::BlackBoardNetHandlerInterfaceObserver.
Definition at line 91 of file interface_observer.cpp.
Referenced by fawkes::BlackBoardNotifier::notify_of_interface_created().
|
virtual |
BlackBoard interface destroyed notification.
This is called whenever an interface is destroyed for a type that you registered for.
type | type of the interface. If you want to store this make a copy as it is not guaranteed that the supplied string exists for longer than the duration of the method call |
id | ID of the newly created interface. If you want to store this make a copy as it is not guaranteed that the supplied string exists for longer than the duration of the method call |
Reimplemented in fawkes::BlackBoardNetHandlerInterfaceObserver.
Definition at line 107 of file interface_observer.cpp.
Referenced by fawkes::BlackBoardNotifier::notify_of_interface_destroyed().
|
protected |
Add interface creation type to watch list.
With this you add an interface type to the watch list. For any type on this list you will be notified if an interface is created.
type_pattern | pattern of interface types to watch, supports wildcards similar to filenames (*, ?, []), see "man fnmatch" for all supported. |
id_pattern | pattern of interface IDs to open, supports wildcards similar to filenames (*, ?, []), see "man fnmatch" for all supported. |
Definition at line 121 of file interface_observer.cpp.
References fawkes::LockMap< KeyType, ValueType, LessKey >::lock(), and fawkes::LockMap< KeyType, ValueType, LessKey >::unlock().
Referenced by fawkes::BlackBoardInterfaceListMaintainer::BlackBoardInterfaceListMaintainer(), fawkes::BlackBoardNetHandlerInterfaceObserver::BlackBoardNetHandlerInterfaceObserver(), fawkes::openni::HandIfObserver::HandIfObserver(), RosJointThread::init(), MongoLogBlackboardThread::init(), RosPosition3DThread::init(), LaserPointCloudThread::init(), RosLaserScanThread::init(), NavGraphClustersThread::init(), RosTfThread::init(), RobotStatePublisherThread::init(), fawkes::openni::SkelIfObserver::SkelIfObserver(), and fawkes::tf::TransformListener::TransformListener().
|
protected |
Add interface destruction type to watch list.
With this you add an interface type to the watch list. For any type on this list you will be notified if an interface is destroyed.
type_pattern | pattern of interface types to watch, supports wildcards similar to filenames (*, ?, []), see "man fnmatch" for all supported. |
id_pattern | pattern of interface IDs to open, supports wildcards similar to filenames (*, ?, []), see "man fnmatch" for all supported. |
Definition at line 141 of file interface_observer.cpp.
References fawkes::LockMap< KeyType, ValueType, LessKey >::lock(), and fawkes::LockMap< KeyType, ValueType, LessKey >::unlock().
Referenced by fawkes::BlackBoardNetHandlerInterfaceObserver::BlackBoardNetHandlerInterfaceObserver().
|
protected |
Get interface creation type watch list.
Definition at line 156 of file interface_observer.cpp.
Referenced by fawkes::BlackBoardNotifier::register_observer().
|
protected |
Get interface destriction type watch list.
Definition at line 166 of file interface_observer.cpp.
Referenced by fawkes::BlackBoardNotifier::register_observer().