Fawkes API
Fawkes Development Version
|
BlackBoard interface manager. More...
#include <>>
Public Member Functions | |
BlackBoardInterfaceManager (BlackBoardMemoryManager *bb_memmgr, BlackBoardMessageManager *bb_msgmgr, BlackBoardNotifier *bb_notifier) | |
Constructor. More... | |
virtual | ~BlackBoardInterfaceManager () |
Destructor. More... | |
Interface * | open_for_reading (const char *interface_type, const char *identifier, const char *owner=NULL) |
Open interface for reading. More... | |
Interface * | open_for_writing (const char *interface_type, const char *identifier, const char *owner=NULL) |
Open interface for writing. More... | |
void | close (Interface *interface) |
Close interface. More... | |
InterfaceInfoList * | list_all () const |
Get a list of interfaces. More... | |
InterfaceInfoList * | list (const char *type_pattern, const char *id_pattern) const |
Get a constrained list of interfaces. More... | |
std::list< Interface * > | open_multiple_for_reading (const char *type_pattern, const char *id_pattern="*", const char *owner=NULL) |
Open all interfaces of the given type for reading. More... | |
virtual bool | exists_writer (const Interface *interface) const |
Check if a writer exists for the given interface. More... | |
virtual unsigned int | num_readers (const Interface *interface) const |
Get number of readers. More... | |
virtual void | notify_of_data_change (const Interface *interface) |
Notify of data change. More... | |
virtual std::list< std::string > | readers (const Interface *interface) const |
Get owners of interfaces who opened for reading. More... | |
virtual std::string | writer (const Interface *interface) const |
Get writer of interface. More... | |
std::list< std::string > | readers (const std::string &uid) const |
Get owners of interfaces who opened for reading. More... | |
std::string | writer (const std::string &uid) const |
Get writer of interface. More... | |
![]() | |
virtual | ~InterfaceMediator () |
Virtual destructor. More... | |
Friends | |
class | BlackBoardMessageManager |
BlackBoard interface manager.
This class is used by the BlackBoard to manage interfaces stored in the shared memory.
Definition at line 47 of file interface_manager.h.
fawkes::BlackBoardInterfaceManager::BlackBoardInterfaceManager | ( | BlackBoardMemoryManager * | bb_memmgr, |
BlackBoardMessageManager * | bb_msgmgr, | ||
BlackBoardNotifier * | bb_notifier | ||
) |
Constructor.
The shared memory segment is created with data from bbconfig.h.
bb_memmgr | BlackBoard memory manager to use |
bb_msgmgr | BlackBoard message manager to use |
bb_notifier | BlackBoard notifier to all for events |
Definition at line 67 of file interface_manager.cpp.
|
virtual |
Destructor.
Definition at line 85 of file interface_manager.cpp.
References fawkes::Exception::append(), fawkes::BlackBoardMemoryManager::begin(), fawkes::Interface::datasize(), fawkes::BlackBoardInstanceFactory::delete_interface_instance(), fawkes::BlackBoardMemoryManager::end(), fawkes::interface_header_t::flag_writer_active, fawkes::interface_header_t::hash, fawkes::Interface::hash(), fawkes::interface_header_t::id, fawkes::BlackBoardMemoryManager::is_master(), fawkes::Interface::is_writer(), fawkes::BlackBoardInstanceFactory::new_interface_instance(), fawkes::interface_header_t::num_readers, fawkes::interface_header_t::refcount, fawkes::interface_header_t::serial, fawkes::interface_header_t::type, fawkes::Interface::uid(), fawkes::Mutex::unlock(), and fawkes::BlackBoardMemoryManager::unlock().
void fawkes::BlackBoardInterfaceManager::close | ( | Interface * | interface | ) |
Close interface.
interface | interface to close |
Definition at line 488 of file interface_manager.cpp.
References fawkes::interface_header_t::flag_writer_active, fawkes::BlackBoardMemoryManager::free(), fawkes::Mutex::lock(), fawkes::BlackBoardNotifier::notify_of_interface_destroyed(), fawkes::BlackBoardNotifier::notify_of_reader_removed(), fawkes::BlackBoardNotifier::notify_of_writer_removed(), fawkes::interface_header_t::num_readers, fawkes::interface_header_t::refcount, fawkes::Interface::serial(), and fawkes::Mutex::unlock().
Referenced by fawkes::LocalBlackBoard::close().
|
virtual |
Check if a writer exists for the given interface.
interface | interface to check |
Implements fawkes::InterfaceMediator.
Definition at line 652 of file interface_manager.cpp.
InterfaceInfoList * fawkes::BlackBoardInterfaceManager::list | ( | const char * | type_pattern, |
const char * | id_pattern | ||
) | const |
Get a constrained list of interfaces.
type_pattern | tyoe pattern, may contain shell-like wildcards * (any number of characters) and ? (one character), cf. man fnmatch(). |
id_pattern | ID pattern, may contain shell-like wildcards * (any number of characters) and ? (one character), cf. man fnmatch(). |
Definition at line 574 of file interface_manager.cpp.
References fawkes::InterfaceInfoList::append(), fawkes::BlackBoardMemoryManager::begin(), fawkes::BlackBoardMemoryManager::end(), fawkes::interface_header_t::flag_writer_active, fawkes::interface_header_t::hash, fawkes::interface_header_t::id, fawkes::BlackBoardMemoryManager::lock(), fawkes::interface_header_t::num_readers, readers(), fawkes::interface_header_t::serial, fawkes::Interface::interface_data_ts_t::timestamp_sec, fawkes::Interface::interface_data_ts_t::timestamp_usec, fawkes::interface_header_t::type, fawkes::BlackBoardMemoryManager::unlock(), and writer().
Referenced by fawkes::LocalBlackBoard::list().
InterfaceInfoList * fawkes::BlackBoardInterfaceManager::list_all | ( | ) | const |
Get a list of interfaces.
Definition at line 533 of file interface_manager.cpp.
References fawkes::InterfaceInfoList::append(), fawkes::BlackBoardMemoryManager::begin(), fawkes::BlackBoardMemoryManager::end(), fawkes::interface_header_t::flag_writer_active, fawkes::interface_header_t::hash, fawkes::interface_header_t::id, fawkes::BlackBoardMemoryManager::lock(), fawkes::interface_header_t::num_readers, readers(), fawkes::interface_header_t::serial, fawkes::Interface::interface_data_ts_t::timestamp_sec, fawkes::Interface::interface_data_ts_t::timestamp_usec, fawkes::interface_header_t::type, fawkes::BlackBoardMemoryManager::unlock(), and writer().
Referenced by fawkes::LocalBlackBoard::list_all().
|
virtual |
Notify of data change.
Notify all subscribers of the given interface of a data change. This also influences logging and sending data over the network so it is mandatory to call this function! The interface base class write method does that for you.
interface | interface whose subscribers to notify |
Implements fawkes::InterfaceMediator.
Definition at line 645 of file interface_manager.cpp.
References fawkes::BlackBoardNotifier::notify_of_data_change().
|
virtual |
Get number of readers.
Get the number of readers that the given interface has.
interface | interface to check |
Implements fawkes::InterfaceMediator.
Definition at line 659 of file interface_manager.cpp.
References fawkes::interface_header_t::num_readers.
Interface * fawkes::BlackBoardInterfaceManager::open_for_reading | ( | const char * | type, |
const char * | identifier, | ||
const char * | owner = NULL |
||
) |
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 |
owner | name of entity which opened this interface. If using the BlackBoardAspect to access the blackboard leave this untouched unless you have a good reason. |
OutOfMemoryException | thrown if there is not enough free space for the requested interface. |
Definition at line 253 of file interface_manager.cpp.
References fawkes::interface_header_t::hash, fawkes::Interface::hash(), fawkes::Interface::hash_size(), fawkes::Mutex::lock(), fawkes::BlackBoardMemoryManager::lock(), fawkes::BlackBoardNotifier::notify_of_interface_created(), fawkes::BlackBoardNotifier::notify_of_reader_added(), fawkes::interface_header_t::num_readers, fawkes::interface_header_t::refcount, fawkes::interface_header_t::serial, fawkes::Interface::serial(), fawkes::Interface::uid(), fawkes::Mutex::unlock(), and fawkes::BlackBoardMemoryManager::unlock().
Referenced by fawkes::LocalBlackBoard::open_for_reading().
Interface * fawkes::BlackBoardInterfaceManager::open_for_writing | ( | const char * | type, |
const char * | identifier, | ||
const char * | owner = NULL |
||
) |
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 |
owner | name of entity which opened this interface. If using the BlackBoardAspect to access the blackboard leave this untouched unless you have a good reason. |
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 |
Definition at line 417 of file interface_manager.cpp.
References fawkes::interface_header_t::flag_writer_active, fawkes::interface_header_t::hash, fawkes::Interface::hash(), fawkes::Interface::hash_size(), fawkes::Mutex::lock(), fawkes::BlackBoardMemoryManager::lock(), fawkes::BlackBoardNotifier::notify_of_interface_created(), fawkes::BlackBoardNotifier::notify_of_writer_added(), fawkes::interface_header_t::refcount, fawkes::interface_header_t::serial, fawkes::Interface::serial(), fawkes::Interface::uid(), fawkes::Mutex::unlock(), and fawkes::BlackBoardMemoryManager::unlock().
Referenced by fawkes::LocalBlackBoard::open_for_writing().
std::list< Interface * > fawkes::BlackBoardInterfaceManager::open_multiple_for_reading | ( | const char * | type_pattern, |
const char * | id_pattern = "*" , |
||
const char * | owner = NULL |
||
) |
Open all interfaces of the 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.
type_pattern | pattern of interface types to open, 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. |
owner | name of entity which opened this interface. If using the BlackBoardAspect to access the blackboard leave this untouched unless you have a good reason. |
Definition at line 329 of file interface_manager.cpp.
References fawkes::BlackBoardMemoryManager::begin(), fawkes::BlackBoardMemoryManager::end(), fawkes::interface_header_t::hash, fawkes::Interface::hash(), fawkes::Interface::hash_size(), fawkes::interface_header_t::id, fawkes::Mutex::lock(), fawkes::BlackBoardMemoryManager::lock(), fawkes::BlackBoardNotifier::notify_of_reader_added(), fawkes::interface_header_t::num_readers, fawkes::interface_header_t::refcount, fawkes::interface_header_t::serial, fawkes::interface_header_t::type, fawkes::Interface::uid(), fawkes::Mutex::unlock(), and fawkes::BlackBoardMemoryManager::unlock().
Referenced by fawkes::LocalBlackBoard::open_multiple_for_reading().
|
virtual |
Get owners of interfaces who opened for reading.
interface | an interface to query for the UID |
Implements fawkes::InterfaceMediator.
Definition at line 666 of file interface_manager.cpp.
References fawkes::LockMap< KeyType, ValueType, LessKey >::lock(), fawkes::Interface::uid(), and fawkes::LockMap< KeyType, ValueType, LessKey >::unlock().
Referenced by list(), and list_all().
std::list< std::string > fawkes::BlackBoardInterfaceManager::readers | ( | const std::string & | uid | ) | const |
Get owners of interfaces who opened for reading.
uid | UID of interface to query for |
Definition at line 703 of file interface_manager.cpp.
References fawkes::LockMap< KeyType, ValueType, LessKey >::lock(), and fawkes::LockMap< KeyType, ValueType, LessKey >::unlock().
|
virtual |
Get writer of interface.
interface | an interface to query for the UID |
Implements fawkes::InterfaceMediator.
Definition at line 683 of file interface_manager.cpp.
References fawkes::LockMap< KeyType, ValueType, LessKey >::lock(), fawkes::Interface::uid(), and fawkes::LockMap< KeyType, ValueType, LessKey >::unlock().
Referenced by list(), and list_all().
std::string fawkes::BlackBoardInterfaceManager::writer | ( | const std::string & | uid | ) | const |
Get writer of interface.
uid | UID of interface to query for |
Definition at line 724 of file interface_manager.cpp.
References fawkes::LockMap< KeyType, ValueType, LessKey >::lock(), and fawkes::LockMap< KeyType, ValueType, LessKey >::unlock().