Fawkes API  Fawkes Development Version
fawkes::BlackBoardInterfaceObserver Class Reference

BlackBoard interface observer. More...

#include <>>

Inheritance diagram for fawkes::BlackBoardInterfaceObserver:

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...
 
ObservedInterfaceLockMapbbio_get_observed_create () throw ()
 Get interface creation type watch list. More...
 
ObservedInterfaceLockMapbbio_get_observed_destroy () throw ()
 Get interface destriction type watch list. More...
 

Friends

class BlackBoardNotifier
 

Detailed Description

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.

Author
Tim Niemueller
See also
BlackBoardInterfaceManager::register_observer()
BlackBoardInterfaceManager::unregister_observer()

Definition at line 34 of file interface_observer.h.

Member Typedef Documentation

◆ ObservedInterfaceLockMap

typedef LockMap<std::string, std::list<std::string> > fawkes::BlackBoardInterfaceObserver::ObservedInterfaceLockMap
protected

Type for lockable interface type hash sets.

Definition at line 53 of file interface_observer.h.

◆ ObservedInterfaceLockMapIterator

typedef ObservedInterfaceLockMap::iterator fawkes::BlackBoardInterfaceObserver::ObservedInterfaceLockMapIterator
protected

Type for iterator of lockable interface type hash sets.

Definition at line 56 of file interface_observer.h.

Constructor & Destructor Documentation

◆ BlackBoardInterfaceObserver()

fawkes::BlackBoardInterfaceObserver::BlackBoardInterfaceObserver ( )

Empty constructor.

Definition at line 68 of file interface_observer.cpp.

◆ ~BlackBoardInterfaceObserver()

fawkes::BlackBoardInterfaceObserver::~BlackBoardInterfaceObserver ( )
virtual

Destructor.

Definition at line 73 of file interface_observer.cpp.

Member Function Documentation

◆ bb_interface_created()

void fawkes::BlackBoardInterfaceObserver::bb_interface_created ( const char *  type,
const char *  id 
)
throw (
)
virtual

BlackBoard interface created notification.

This is called whenever an interface is created for a type that you registered for.

Parameters
typetype 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
idID 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().

◆ bb_interface_destroyed()

void fawkes::BlackBoardInterfaceObserver::bb_interface_destroyed ( const char *  type,
const char *  id 
)
throw (
)
virtual

BlackBoard interface destroyed notification.

This is called whenever an interface is destroyed for a type that you registered for.

Parameters
typetype 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
idID 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().

◆ bbio_add_observed_create()

void fawkes::BlackBoardInterfaceObserver::bbio_add_observed_create ( const char *  type_pattern,
const char *  id_pattern = "*" 
)
throw (
)
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.

Parameters
type_patternpattern of interface types to watch, supports wildcards similar to filenames (*, ?, []), see "man fnmatch" for all supported.
id_patternpattern 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().

◆ bbio_add_observed_destroy()

void fawkes::BlackBoardInterfaceObserver::bbio_add_observed_destroy ( const char *  type_pattern,
const char *  id_pattern = "*" 
)
throw (
)
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.

Parameters
type_patternpattern of interface types to watch, supports wildcards similar to filenames (*, ?, []), see "man fnmatch" for all supported.
id_patternpattern 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().

◆ bbio_get_observed_create()

BlackBoardInterfaceObserver::ObservedInterfaceLockMap * fawkes::BlackBoardInterfaceObserver::bbio_get_observed_create ( )
throw (
)
protected

Get interface creation type watch list.

Returns
interface type watch list

Definition at line 156 of file interface_observer.cpp.

Referenced by fawkes::BlackBoardNotifier::register_observer().

◆ bbio_get_observed_destroy()

BlackBoardInterfaceObserver::ObservedInterfaceLockMap * fawkes::BlackBoardInterfaceObserver::bbio_get_observed_destroy ( )
throw (
)
protected

Get interface destriction type watch list.

Returns
interface type watch list

Definition at line 166 of file interface_observer.cpp.

Referenced by fawkes::BlackBoardNotifier::register_observer().


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