remote.h
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef __BLACKBOARD_REMOTE_H_
00025 #define __BLACKBOARD_REMOTE_H_
00026
00027 #include <blackboard/blackboard.h>
00028 #include <netcomm/fawkes/client_handler.h>
00029 #include <core/utils/lock_map.h>
00030 #include <core/exceptions/software.h>
00031
00032 #include <list>
00033
00034 namespace fawkes {
00035
00036 class FawkesNetworkClient;
00037 class FawkesNetworkMessage;
00038 class Mutex;
00039 class WaitCondition;
00040 class Interface;
00041 class InterfaceInfoList;
00042
00043 class BlackBoardInstanceFactory;
00044 class BlackBoardNotifier;
00045 class BlackBoardInterfaceProxy;
00046 class BlackBoardInterfaceListener;
00047 class BlackBoardInterfaceObserver;
00048
00049 class RemoteBlackBoard
00050 : public BlackBoard,
00051 public FawkesNetworkClientHandler
00052 {
00053 public:
00054 RemoteBlackBoard(FawkesNetworkClient *client);
00055 RemoteBlackBoard(const char *hostname, unsigned short int port);
00056 virtual ~RemoteBlackBoard();
00057
00058 virtual Interface * open_for_reading(const char *interface_type, const char *identifier);
00059 virtual Interface * open_for_writing(const char *interface_type, const char *identifier);
00060 virtual void close(Interface *interface);
00061
00062 virtual InterfaceInfoList * list_all();
00063 virtual bool is_alive() const throw();
00064 virtual bool try_aliveness_restore() throw();
00065
00066 std::list<Interface *> open_multiple_for_reading(const char *interface_type,
00067 const char *id_pattern = "*");
00068
00069 void register_listener(BlackBoardInterfaceListener *listener, unsigned int flags);
00070 void unregister_listener(BlackBoardInterfaceListener *listener);
00071
00072 void register_observer(BlackBoardInterfaceObserver *observer, unsigned int flags);
00073 void unregister_observer(BlackBoardInterfaceObserver *observer);
00074
00075
00076
00077 virtual void deregistered(unsigned int id) throw();
00078 virtual void inbound_received(FawkesNetworkMessage *msg,
00079 unsigned int id) throw();
00080 virtual void connection_died(unsigned int id) throw();
00081 virtual void connection_established(unsigned int id) throw();
00082
00083
00084
00085
00086 private:
00087 void open_interface(const char *type, const char *identifier,
00088 bool writer, Interface *iface);
00089 Interface * open_interface(const char *type, const char *identifier, bool writer);
00090 void reopen_interfaces();
00091
00092
00093 private:
00094 Mutex *__mutex;
00095 FawkesNetworkClient *__fnc;
00096 bool __fnc_owner;
00097 FawkesNetworkMessage *__m;
00098 BlackBoardNotifier *__notifier;
00099 BlackBoardInstanceFactory *__instance_factory;
00100 LockMap<unsigned int, BlackBoardInterfaceProxy *> __proxies;
00101 LockMap<unsigned int, BlackBoardInterfaceProxy *>::iterator __pit;
00102 std::list<BlackBoardInterfaceProxy *> __invalid_proxies;
00103 std::list<BlackBoardInterfaceProxy *>::iterator __ipit;
00104
00105 Mutex *__wait_mutex;
00106 WaitCondition *__wait_cond;
00107 };
00108
00109 }
00110
00111 #endif