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) noexcept
 BlackBoard interface created notification. More...
 
virtual void bb_interface_destroyed (const char *type, const char *id) noexcept
 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="*") noexcept
 Add interface creation type to watch list. More...
 
void bbio_add_observed_destroy (const char *type_pattern, const char *id_pattern="*") noexcept
 Add interface destruction type to watch list. More...
 
ObservedInterfaceLockMapbbio_get_observed_create () noexcept
 Get interface creation type watch list. More...
 
ObservedInterfaceLockMapbbio_get_observed_destroy () noexcept
 Get interface destriction type watch list. More...
 

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 36 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 52 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 55 of file interface_observer.h.

Constructor & Destructor Documentation

◆ BlackBoardInterfaceObserver()

fawkes::BlackBoardInterfaceObserver::BlackBoardInterfaceObserver ( )

Empty constructor.

Definition at line 69 of file interface_observer.cpp.

◆ ~BlackBoardInterfaceObserver()

fawkes::BlackBoardInterfaceObserver::~BlackBoardInterfaceObserver ( )
virtual

Destructor.

Definition at line 74 of file interface_observer.cpp.

Member Function Documentation

◆ bb_interface_created()

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

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 fawkes::BlackBoardNetHandlerInterfaceObserver, fawkes::tf::TransformListener, LaserPointCloudThread, MongoLogBlackboardThread, fawkes::openni::HandIfObserver, fawkes::openni::SkelIfObserver, RobotStatePublisherThread, RosJointThread, RosLaserScanThread, RosPosition3DThread, RosTfThread, and BlackboardListenerThread.

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 
)
virtualnoexcept

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, and BlackboardListenerThread.

Definition at line 106 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 = "*" 
)
protectednoexcept

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 119 of file interface_observer.cpp.

Referenced by fawkes::BlackBoardInterfaceListMaintainer::BlackBoardInterfaceListMaintainer(), fawkes::BlackBoardNetHandlerInterfaceObserver::BlackBoardNetHandlerInterfaceObserver(), fawkes::openni::HandIfObserver::HandIfObserver(), LaserPointCloudThread::init(), MetricsThread::init(), MongoLogBlackboardThread::init(), NavGraphClustersThread::init(), RobotStatePublisherThread::init(), RosJointThread::init(), RosLaserScanThread::init(), RosPosition3DThread::init(), RosTfThread::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 = "*" 
)
protectednoexcept

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 138 of file interface_observer.cpp.

Referenced by fawkes::BlackBoardNetHandlerInterfaceObserver::BlackBoardNetHandlerInterfaceObserver().

◆ bbio_get_observed_create()

BlackBoardInterfaceObserver::ObservedInterfaceLockMap * fawkes::BlackBoardInterfaceObserver::bbio_get_observed_create ( )
protectednoexcept

Get interface creation type watch list.

Returns
interface type watch list

Definition at line 152 of file interface_observer.cpp.

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

◆ bbio_get_observed_destroy()

BlackBoardInterfaceObserver::ObservedInterfaceLockMap * fawkes::BlackBoardInterfaceObserver::bbio_get_observed_destroy ( )
protectednoexcept

Get interface destriction type watch list.

Returns
interface type watch list

Definition at line 161 of file interface_observer.cpp.

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


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