25 #include "interface_list_maintainer.h" 27 #include <core/threading/mutex_locker.h> 60 std::list<fawkes::Interface *>::iterator pif_tmp;
61 for ( pif_tmp = ifs_tmp.begin(); pif_tmp != ifs_tmp.end(); ++pif_tmp ) {
63 std::string id_list_tmp( (*pif_tmp)->id() );
64 bool is_in_list =
false;
66 for ( pif_class = ifs_.begin(); pif_class != ifs_.end(); ++pif_class ) {
67 std::string id_list_class( (*pif_class)->id() );
69 if ( id_list_tmp.compare( id_list_class ) == 0 ) {
70 blackboard_->
close( *pif_tmp );
76 ifs_.push_back( (*pif_tmp) );
94 for ( pif = ifs_.begin(); pif != ifs_.end(); ++pif ) {
98 blackboard_->
close( *pif );
109 BlackBoardInterfaceListMaintainer::bb_interface_created(
const char *
type,
const char *
id)
throw()
125 logger_->
log_warn(name_,
"Failed to register for %s:%s: %s",
131 blackboard_->
close(pif);
133 logger_->
log_error(name_,
"Failed to deregister %s:%s during error recovery: %s",
148 BlackBoardInterfaceListMaintainer::bb_interface_writer_removed(
fawkes::Interface *interface,
149 unsigned int instance_serial)
throw()
151 conditional_close(interface);
160 BlackBoardInterfaceListMaintainer::bb_interface_reader_removed(
fawkes::Interface *interface,
161 unsigned int instance_serial)
throw()
163 conditional_close(interface);
172 BlackBoardInterfaceListMaintainer::conditional_close(
Interface *pif)
throw()
178 std::find(ifs_.begin(), ifs_.end(), pif);
180 if (c != ifs_.end() &&
184 logger_->
log_info(name_,
"Last on %s, closing", pif->
uid());
192 std::string
uid = pif->
uid();
197 blackboard_->
close(pif);
199 logger_->
log_error(name_,
"Failed to unregister or close %s: %s",
200 uid.c_str(), e.
what());
virtual void register_observer(BlackBoardInterfaceObserver *observer)
Register BB interface observer.
virtual void log_info(const char *component, const char *format,...)=0
Log informational message.
Fawkes library namespace.
void bbil_add_writer_interface(Interface *interface)
Add an interface to the writer addition/removal watch list.
virtual const char * what() const
Get primary string.
virtual void update_listener(BlackBoardInterfaceListener *listener, ListenerRegisterFlag flag=BBIL_FLAG_ALL)
Update BB event listener.
Base class for all Fawkes BlackBoard interfaces.
BlackBoardInterfaceListMaintainer(const char *n, BlackBoard *bb, Logger *l, const char *type, const char *pattern)
Constructor.
void bbil_remove_writer_interface(Interface *interface)
Remove an interface to the writer addition/removal watch list.
void push_back_locked(const Type &x)
Push element to list at back with lock protection.
RefPtr< Mutex > mutex() const
Get access to the internal mutex.
virtual void register_listener(BlackBoardInterfaceListener *listener, ListenerRegisterFlag flag=BBIL_FLAG_ALL)
Register BB event listener.
void bbio_add_observed_create(const char *type_pattern, const char *id_pattern="*")
Add interface creation type to watch list.
virtual ~BlackBoardInterfaceListMaintainer()
Destructor.
const char * type() const
Get type of interface.
Base class for exceptions in Fawkes.
virtual void unlock() const
Unlock list.
bool has_writer() const
Check if there is a writer for the interface.
const char * uid() const
Get unique identifier of interface.
virtual const char * what_no_backtrace() const
Get primary string (does not implicitly print the back trace).
virtual void log_warn(const char *component, const char *format,...)=0
Log warning message.
virtual void log_error(const char *component, const char *format,...)=0
Log error message.
virtual std::list< Interface * > open_multiple_for_reading(const char *type_pattern, const char *id_pattern="*", const char *owner=NULL)=0
Open multiple interfaces for reading.
void bbil_add_reader_interface(Interface *interface)
Add an interface to the reader addition/removal watch list.
virtual Interface * open_for_reading(const char *interface_type, const char *identifier, const char *owner=NULL)=0
Open interface for reading.
unsigned int num_readers() const
Get the number of readers.
The BlackBoard abstract class.
void bbil_remove_reader_interface(Interface *interface)
Remove an interface to the reader addition/removal watch list.
void unlock_list()
unlocks the mutex in this class
BlackBoard interface listener.
virtual void close(Interface *interface)=0
Close interface.