Fawkes API
Fawkes Development Version
|
Remote BlackBoard. More...
#include <>>
Public Member Functions | |
RemoteBlackBoard (FawkesNetworkClient *client) | |
Constructor. | |
RemoteBlackBoard (const char *hostname, unsigned short int port) | |
Constructor. | |
virtual | ~RemoteBlackBoard () |
Destructor. | |
virtual Interface * | open_for_reading (const char *interface_type, const char *identifier) |
Open interface for reading. | |
virtual Interface * | open_for_writing (const char *interface_type, const char *identifier) |
Open interface for writing. | |
virtual void | close (Interface *interface) |
Close interface. | |
virtual InterfaceInfoList * | list_all () |
Get list of interfaces. | |
virtual bool | is_alive () const throw () |
Check if the BlackBoard is still alive. | |
virtual bool | try_aliveness_restore () throw () |
Try to restore the aliveness of the BlackBoard instance. | |
std::list< Interface * > | open_multiple_for_reading (const char *interface_type, const char *id_pattern="*") |
Open multiple interfaces for reading. | |
void | register_listener (BlackBoardInterfaceListener *listener, unsigned int flags) |
Register BB event listener. | |
void | unregister_listener (BlackBoardInterfaceListener *listener) |
Unregister BB interface listener. | |
void | register_observer (BlackBoardInterfaceObserver *observer, unsigned int flags) |
Register BB interface observer. | |
void | unregister_observer (BlackBoardInterfaceObserver *observer) |
Unregister BB interface observer. | |
virtual void | deregistered (unsigned int id) throw () |
We are no longer registered in Fawkes network client. | |
virtual void | inbound_received (FawkesNetworkMessage *msg, unsigned int id) throw () |
Called for incoming messages. | |
virtual void | connection_died (unsigned int id) throw () |
Client connection died. | |
virtual void | connection_established (unsigned int id) throw () |
Client has established a connection. |
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 57 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 85 of file remote.cpp.
References fawkes::FawkesNetworkClient::connect(), fawkes::FawkesNetworkClient::connected(), and fawkes::FawkesNetworkClient::register_handler().
fawkes::RemoteBlackBoard::~RemoteBlackBoard | ( | ) | [virtual] |
Destructor.
Definition at line 115 of file remote.cpp.
References fawkes::FawkesNetworkClient::deregister_handler(), and fawkes::FawkesNetworkClient::disconnect().
void fawkes::RemoteBlackBoard::close | ( | Interface * | interface | ) | [virtual] |
Close interface.
interface | interface to close |
Implements fawkes::BlackBoard.
Definition at line 301 of file remote.cpp.
References fawkes::Interface::serial(), fawkes::FawkesNetworkClient::connected(), fawkes::bb_iserial_msg_t::serial, fawkes::FawkesNetworkClient::enqueue(), and fawkes::BlackBoardInstanceFactory::delete_interface_instance().
Referenced by open_multiple_for_reading(), and RefBoxStateBBWriter::~RefBoxStateBBWriter().
void fawkes::RemoteBlackBoard::connection_died | ( | unsigned int | id | ) | throw () [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 452 of file remote.cpp.
void fawkes::RemoteBlackBoard::connection_established | ( | unsigned int | id | ) | throw () [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 466 of file remote.cpp.
void fawkes::RemoteBlackBoard::deregistered | ( | unsigned int | id | ) | throw () [virtual] |
We are no longer registered in Fawkes network client.
Ignored.
id | the id of the calling client |
Implements fawkes::FawkesNetworkClientHandler.
Definition at line 395 of file remote.cpp.
void fawkes::RemoteBlackBoard::inbound_received | ( | FawkesNetworkMessage * | m, |
unsigned int | id | ||
) | throw () [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 401 of file remote.cpp.
References fawkes::bb_ieventserial_msg_t::serial, and fawkes::bb_ieventserial_msg_t::event_serial.
bool fawkes::RemoteBlackBoard::is_alive | ( | ) | const throw () [virtual] |
Check if the BlackBoard is still alive.
Implements fawkes::BlackBoard.
Definition at line 137 of file remote.cpp.
References fawkes::FawkesNetworkClient::connected().
InterfaceInfoList * fawkes::RemoteBlackBoard::list_all | ( | ) | [virtual] |
Get list of interfaces.
Implements fawkes::BlackBoard.
Definition at line 356 of file remote.cpp.
References fawkes::Mutex::lock(), fawkes::FawkesNetworkClient::enqueue(), fawkes::FawkesNetworkMessage::msgid(), fawkes::RefCount::unref(), fawkes::WaitCondition::wait(), fawkes::Mutex::unlock(), fawkes::FawkesNetworkMessage::msgc(), fawkes::BlackBoardInterfaceListContent::has_next(), fawkes::BlackBoardInterfaceListContent::next(), fawkes::InterfaceInfoList::append(), fawkes::bb_iinfo_msg_t::type, fawkes::bb_iinfo_msg_t::id, fawkes::bb_iinfo_msg_t::hash, fawkes::bb_iinfo_msg_t::serial, fawkes::bb_iinfo_msg_t::has_writer, and fawkes::bb_iinfo_msg_t::num_readers.
Referenced by open_multiple_for_reading().
Interface * fawkes::RemoteBlackBoard::open_for_reading | ( | const char * | type, |
const char * | identifier | ||
) | [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 |
OutOfMemoryException | thrown if there is not enough free space for the requested interface. |
Implements fawkes::BlackBoard.
Definition at line 256 of file remote.cpp.
Referenced by open_multiple_for_reading(), LaserGuiGtkWindow::on_connect(), and LaserGuiHildonWindow::on_connect().
Interface * fawkes::RemoteBlackBoard::open_for_writing | ( | const char * | type, |
const char * | identifier | ||
) | [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 |
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 263 of file remote.cpp.
std::list< Interface * > fawkes::RemoteBlackBoard::open_multiple_for_reading | ( | const char * | type, |
const char * | id_pattern = "*" |
||
) | [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 | type of the interface |
id_pattern | pattern of interface IDs to open, supports wildcards similar to filenames (*, ?, []), see "man fnmatch" for all supported. |
Implements fawkes::BlackBoard.
Definition at line 270 of file remote.cpp.
References list_all(), open_for_reading(), and close().
void fawkes::RemoteBlackBoard::register_listener | ( | BlackBoardInterfaceListener * | listener, |
unsigned int | flags | ||
) | [virtual] |
Register BB event listener.
listener | BlackBoard event listener to register |
flags | an or'ed combination of BBIL_FLAG_DATA, BBIL_FLAG_READER, BBIL_FLAG_WRITER and BBIL_FLAG_INTERFACE. Only for the given types the event listener is registered. BBIL_FLAG_ALL can be supplied to register for all events. |
Implements fawkes::BlackBoard.
Definition at line 328 of file remote.cpp.
References fawkes::BlackBoardNotifier::register_listener().
void fawkes::RemoteBlackBoard::register_observer | ( | BlackBoardInterfaceObserver * | observer, |
unsigned int | flags | ||
) | [virtual] |
Register BB interface observer.
observer | BlackBoard interface observer to register |
flags | an or'ed combination of BBIO_FLAG_CREATED, BBIO_FLAG_DESTROYED |
Implements fawkes::BlackBoard.
Definition at line 342 of file remote.cpp.
References fawkes::BlackBoardNotifier::register_observer().
bool fawkes::RemoteBlackBoard::try_aliveness_restore | ( | ) | throw () [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::FawkesNetworkClient::connected(), and fawkes::FawkesNetworkClient::connect().
void fawkes::RemoteBlackBoard::unregister_listener | ( | BlackBoardInterfaceListener * | listener | ) | [virtual] |
Unregister BB interface listener.
This will remove the given BlackBoard interface listener from any event that it was previously registered for.
listener | BlackBoard event listener to remove |
Implements fawkes::BlackBoard.
Definition at line 335 of file remote.cpp.
References fawkes::BlackBoardNotifier::unregister_listener().
void fawkes::RemoteBlackBoard::unregister_observer | ( | BlackBoardInterfaceObserver * | observer | ) | [virtual] |
Unregister BB interface observer.
This will remove the given BlackBoard event listener from any event that it was previously registered for.
observer | BlackBoard event listener to remove |
Implements fawkes::BlackBoard.
Definition at line 349 of file remote.cpp.
References fawkes::BlackBoardNotifier::unregister_observer().