Fawkes API
Fawkes Development Version
|
00001 00002 /*************************************************************************** 00003 * remote.h - Remote BlackBoard using the Fawkes network protocol 00004 * 00005 * Created: Mon Mar 03 10:52:28 2008 00006 * Copyright 2006-2008 Tim Niemueller [www.niemueller.de] 00007 * 00008 ****************************************************************************/ 00009 00010 /* This program is free software; you can redistribute it and/or modify 00011 * it under the terms of the GNU General Public License as published by 00012 * the Free Software Foundation; either version 2 of the License, or 00013 * (at your option) any later version. A runtime exception applies to 00014 * this software (see LICENSE.GPL_WRE file mentioned below for details). 00015 * 00016 * This program is distributed in the hope that it will be useful, 00017 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00018 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00019 * GNU Library General Public License for more details. 00020 * 00021 * Read the full text in the LICENSE.GPL_WRE file in the doc directory. 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 InterfaceInfoList * list(const char *type_pattern, 00064 const char *id_pattern); 00065 virtual bool is_alive() const throw(); 00066 virtual bool try_aliveness_restore() throw(); 00067 00068 std::list<Interface *> open_multiple_for_reading(const char *interface_type, 00069 const char *id_pattern = "*"); 00070 00071 /* for FawkesNetworkClientHandler */ 00072 virtual void deregistered(unsigned int id) throw(); 00073 virtual void inbound_received(FawkesNetworkMessage *msg, 00074 unsigned int id) throw(); 00075 virtual void connection_died(unsigned int id) throw(); 00076 virtual void connection_established(unsigned int id) throw(); 00077 00078 00079 /* extensions for RemoteBlackBoard */ 00080 00081 private: /* methods */ 00082 void open_interface(const char *type, const char *identifier, 00083 bool writer, Interface *iface); 00084 Interface * open_interface(const char *type, const char *identifier, bool writer); 00085 void reopen_interfaces(); 00086 00087 00088 private: /* members */ 00089 Mutex *__mutex; 00090 FawkesNetworkClient *__fnc; 00091 bool __fnc_owner; 00092 FawkesNetworkMessage *__m; 00093 BlackBoardInstanceFactory *__instance_factory; 00094 LockMap<unsigned int, BlackBoardInterfaceProxy *> __proxies; 00095 LockMap<unsigned int, BlackBoardInterfaceProxy *>::iterator __pit; 00096 std::list<BlackBoardInterfaceProxy *> __invalid_proxies; 00097 std::list<BlackBoardInterfaceProxy *>::iterator __ipit; 00098 00099 Mutex *__wait_mutex; 00100 WaitCondition *__wait_cond; 00101 00102 const char *__inbound_thread; 00103 }; 00104 00105 } // end namespace fawkes 00106 00107 #endif