Fawkes API
Fawkes Development Version
|
Remote BlackBoard. More...
#include <>>
Public Member Functions | |
RemoteBlackBoard (FawkesNetworkClient *client) | |
Constructor. More... | |
RemoteBlackBoard (const char *hostname, unsigned short int port) | |
Constructor. More... | |
virtual | ~RemoteBlackBoard () |
Destructor. More... | |
virtual Interface * | open_for_reading (const char *interface_type, const char *identifier, const char *owner=NULL) |
Open interface for reading. More... | |
virtual Interface * | open_for_writing (const char *interface_type, const char *identifier, const char *owner=NULL) |
Open interface for writing. More... | |
virtual void | close (Interface *interface) |
Close interface. More... | |
virtual InterfaceInfoList * | list_all () |
Get list of all currently existing interfaces. More... | |
virtual InterfaceInfoList * | list (const char *type_pattern, const char *id_pattern) |
Get list of interfaces matching type and ID patterns. More... | |
virtual bool | is_alive () const throw () |
Check if the BlackBoard is still alive. More... | |
virtual bool | try_aliveness_restore () throw () |
Try to restore the aliveness of the BlackBoard instance. More... | |
std::list< Interface * > | open_multiple_for_reading (const char *interface_type, const char *id_pattern="*", const char *owner=NULL) |
Open multiple interfaces for reading. More... | |
virtual void | deregistered (unsigned int id) throw () |
We are no longer registered in Fawkes network client. More... | |
virtual void | inbound_received (FawkesNetworkMessage *msg, unsigned int id) throw () |
Called for incoming messages. More... | |
virtual void | connection_died (unsigned int id) throw () |
Client connection died. More... | |
virtual void | connection_established (unsigned int id) throw () |
Client has established a connection. More... | |
![]() | |
virtual | ~BlackBoard () |
Destructor. More... | |
virtual Interface * | open_for_reading_f (const char *interface_type, const char *identifier,...) |
Open interface for reading with identifier format string. More... | |
virtual Interface * | open_for_writing_f (const char *interface_type, const char *identifier,...) |
Open interface for writing with identifier format string. More... | |
template<class InterfaceType > | |
std::list< InterfaceType * > | open_multiple_for_reading (const char *id_pattern="*", const char *owner=NULL) |
Open all interfaces of given type for reading. More... | |
template<class InterfaceType > | |
InterfaceType * | open_for_reading (const char *identifier, const char *owner=NULL) |
Get interface of given type. More... | |
template<class InterfaceType > | |
InterfaceType * | open_for_writing (const char *identifier, const char *owner=NULL) |
Get writer interface of given type. More... | |
template<class InterfaceType > | |
InterfaceType * | open_for_reading_f (const char *identifier,...) |
Get interface of given type with identifier format string. More... | |
template<class InterfaceType > | |
InterfaceType * | open_for_writing_f (const char *identifier,...) |
Get writer interface of given type with identifier format string. More... | |
virtual void | register_listener (BlackBoardInterfaceListener *listener, ListenerRegisterFlag flag=BBIL_FLAG_ALL) |
Register BB event listener. More... | |
virtual void | update_listener (BlackBoardInterfaceListener *listener, ListenerRegisterFlag flag=BBIL_FLAG_ALL) |
Update BB event listener. More... | |
virtual void | unregister_listener (BlackBoardInterfaceListener *listener) |
Unregister BB interface listener. More... | |
virtual void | register_observer (BlackBoardInterfaceObserver *observer) |
Register BB interface observer. More... | |
virtual void | unregister_observer (BlackBoardInterfaceObserver *observer) |
Unregister BB interface observer. More... | |
std::string | demangle_fawkes_interface_name (const char *type) |
Produce interface name from C++ signature. More... | |
std::string | format_identifier (const char *identifier_format, va_list arg) |
Get formatted identifier string. More... | |
![]() | |
virtual | ~FawkesNetworkClientHandler () |
Empty virtual destructor. More... | |
Additional Inherited Members | |
![]() | |
enum | ListenerRegisterFlag { BBIL_FLAG_DATA = 1, BBIL_FLAG_MESSAGES = 2, BBIL_FLAG_READER = 4, BBIL_FLAG_WRITER = 8, BBIL_FLAG_ALL = 15 } |
Flags to constrain listener registration/updates. More... | |
![]() | |
BlackBoard (bool create_notifier=true) | |
Constructor. More... | |
![]() | |
BlackBoardNotifier * | __notifier |
Notifier for BB events. More... | |
Remote BlackBoard.
This class implements the access to a remote BlackBoard using the Fawkes network protocol.
fawkes::RemoteBlackBoard::RemoteBlackBoard | ( | FawkesNetworkClient * | client | ) |
Constructor.
client | Fawkes network client to use. |
Definition at line 58 of file remote.cpp.
References fawkes::FawkesNetworkClient::connected(), and fawkes::FawkesNetworkClient::register_handler().
fawkes::RemoteBlackBoard::RemoteBlackBoard | ( | const char * | hostname, |
unsigned short int | port | ||
) |
Constructor.
This will internall create a fawkes network client that is used to communicate with the remote BlackBoard.
hostname | hostname to connect to |
port | port to connect to |
Definition at line 86 of file remote.cpp.
References fawkes::FawkesNetworkClient::connect(), fawkes::FawkesNetworkClient::connected(), and fawkes::FawkesNetworkClient::register_handler().
|
virtual |
Destructor.
Definition at line 116 of file remote.cpp.
References fawkes::FawkesNetworkClient::deregister_handler(), and fawkes::FawkesNetworkClient::disconnect().
|
virtual |
Close interface.
interface | interface to close |
Implements fawkes::BlackBoard.
Definition at line 326 of file remote.cpp.
References fawkes::FawkesNetworkClient::connected(), fawkes::BlackBoardInstanceFactory::delete_interface_instance(), fawkes::FawkesNetworkClient::enqueue(), fawkes::Interface::serial(), and fawkes::bb_iserial_msg_t::serial.
Referenced by open_multiple_for_reading().
|
virtual |
Client connection died.
This method is used to inform handlers that the connection has died for any reason. No more data can be send and no more messages should be enqueued because it is unclear when they would be sent.
id | the id of the calling client |
Implements fawkes::FawkesNetworkClientHandler.
Definition at line 527 of file remote.cpp.
References fawkes::WaitCondition::wake_all().
|
virtual |
Client has established a connection.
Whenever the client establishes a connection this is signaled to handlers with this method. You can register to a client at any time, you may even enqueue messages to a client while the connection is dead. If the client at some point gets connected again, the messages will then be send out in one go. You should use this in your application though to only send data if the connection is alive and you should let the user know about the connection status.
id | the id of the calling client |
Implements fawkes::FawkesNetworkClientHandler.
Definition at line 542 of file remote.cpp.
|
virtual |
We are no longer registered in Fawkes network client.
Ignored.
id | the id of the calling client |
Implements fawkes::FawkesNetworkClientHandler.
Definition at line 456 of file remote.cpp.
|
virtual |
Called for incoming messages.
This is called when an incoming message has been received. If this method was called one or more times then the a previously carried out wait(cid) call will continue.
m | Message to handle |
id | the id of the calling client |
Implements fawkes::FawkesNetworkClientHandler.
Definition at line 462 of file remote.cpp.
References fawkes::BlackBoard::__notifier, fawkes::Thread::current_thread(), fawkes::bb_ieventserial_msg_t::event_serial, fawkes::bb_ievent_msg_t::id, fawkes::Mutex::lock(), fawkes::Thread::name(), fawkes::BlackBoardNotifier::notify_of_interface_created(), fawkes::BlackBoardNotifier::notify_of_interface_destroyed(), fawkes::RefCount::ref(), fawkes::bb_ieventserial_msg_t::serial, fawkes::bb_ievent_msg_t::type, fawkes::Mutex::unlock(), and fawkes::WaitCondition::wake_all().
|
virtual |
Check if the BlackBoard is still alive.
Implements fawkes::BlackBoard.
Definition at line 137 of file remote.cpp.
References fawkes::FawkesNetworkClient::connected(), fawkes::Interface::id(), fawkes::Interface::is_writer(), fawkes::Interface::owner(), fawkes::Interface::set_validity(), and fawkes::Interface::type().
Referenced by try_aliveness_restore().
|
virtual |
Get list of interfaces matching type and ID patterns.
See the fnmatch() documentation for possible patterns.
type_pattern | pattern with shell like globs (* for any number of characters, ? for exactly one character) to match the interface type. |
id_pattern | pattern with shell like globs (* for any number of characters, ? for exactly one character) to match the interface ID. |
Implements fawkes::BlackBoard.
Definition at line 398 of file remote.cpp.
References fawkes::InterfaceInfoList::append(), fawkes::Thread::current_thread(), fawkes::FawkesNetworkClient::enqueue(), fawkes::BlackBoardInterfaceListContent::has_next(), fawkes::bb_iinfo_msg_t::hash, fawkes::bb_iinfo_msg_t::id, fawkes::bb_ilistreq_msg_t::id_pattern, fawkes::Mutex::lock(), fawkes::FawkesNetworkMessage::msgc(), fawkes::FawkesNetworkMessage::msgid(), fawkes::BlackBoardInterfaceListContent::next(), fawkes::bb_iinfo_msg_t::serial, fawkes::bb_iinfo_msg_t::timestamp_sec, fawkes::bb_iinfo_msg_t::timestamp_usec, fawkes::bb_iinfo_msg_t::type, fawkes::bb_ilistreq_msg_t::type_pattern, fawkes::Mutex::unlock(), fawkes::RefCount::unref(), fawkes::WaitCondition::wait(), and fawkes::bb_iinfo_msg_t::writer_readers.
|
virtual |
Get list of all currently existing interfaces.
Implements fawkes::BlackBoard.
Definition at line 353 of file remote.cpp.
References fawkes::InterfaceInfoList::append(), fawkes::Thread::current_thread(), fawkes::FawkesNetworkClient::enqueue(), fawkes::BlackBoardInterfaceListContent::has_next(), fawkes::bb_iinfo_msg_t::hash, fawkes::bb_iinfo_msg_t::id, fawkes::Mutex::lock(), fawkes::FawkesNetworkMessage::msgc(), fawkes::FawkesNetworkMessage::msgid(), fawkes::BlackBoardInterfaceListContent::next(), fawkes::bb_iinfo_msg_t::serial, fawkes::bb_iinfo_msg_t::timestamp_sec, fawkes::bb_iinfo_msg_t::timestamp_usec, fawkes::bb_iinfo_msg_t::type, fawkes::Mutex::unlock(), fawkes::RefCount::unref(), fawkes::WaitCondition::wait(), and fawkes::bb_iinfo_msg_t::writer_readers.
Referenced by open_multiple_for_reading().
|
virtual |
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. |
Implements fawkes::BlackBoard.
Definition at line 272 of file remote.cpp.
Referenced by LaserGuiHildonWindow::on_connect(), open_multiple_for_reading(), and EclipseDebugger::~EclipseDebugger().
|
virtual |
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 |
Implements fawkes::BlackBoard.
Definition at line 279 of file remote.cpp.
|
virtual |
Open multiple interfaces for reading.
This will create interface instances for currently registered interfaces of the given type that match the given ID pattern. 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. |
Implements fawkes::BlackBoard.
Definition at line 286 of file remote.cpp.
References close(), list_all(), and open_for_reading().
|
virtual |
Try to restore the aliveness of the BlackBoard instance.
Note that even though the aliveness of the BlackBoard is restored single interfaces may still be invalid. That can for instance happen if a remote connection is re-established and a writer has been created during the downtime and an own writer instance of that very interface cannot be restored.
Implements fawkes::BlackBoard.
Definition at line 163 of file remote.cpp.
References fawkes::BlackBoard::__notifier, fawkes::BB_ERR_HASH_MISMATCH, fawkes::BB_ERR_UNKNOWN_TYPE, fawkes::BB_ERR_WRITER_EXISTS, fawkes::FawkesNetworkClient::connect(), fawkes::FawkesNetworkClient::connected(), fawkes::Thread::current_thread(), fawkes::BlackBoardInstanceFactory::delete_interface_instance(), fawkes::FawkesNetworkClient::enqueue(), fawkes::bb_iopenfail_msg_t::error_code, fawkes::bb_iopen_msg_t::hash, fawkes::Interface::hash(), fawkes::bb_iopen_msg_t::id, is_alive(), fawkes::Mutex::lock(), fawkes::FawkesNetworkMessage::msg(), fawkes::FawkesNetworkMessage::msgid(), fawkes::BlackBoardInstanceFactory::new_interface_instance(), fawkes::BlackBoardInterfaceProxy::serial(), fawkes::bb_iopen_msg_t::type, fawkes::Mutex::unlock(), fawkes::RefCount::unref(), and fawkes::WaitCondition::wait().