Fawkes API  Fawkes Development Version
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
remote.h
1 
2 /***************************************************************************
3  * remote.h - Remote BlackBoard using the Fawkes network protocol
4  *
5  * Created: Mon Mar 03 10:52:28 2008
6  * Copyright 2006-2008 Tim Niemueller [www.niemueller.de]
7  *
8  ****************************************************************************/
9 
10 /* This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version. A runtime exception applies to
14  * this software (see LICENSE.GPL_WRE file mentioned below for details).
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU Library General Public License for more details.
20  *
21  * Read the full text in the LICENSE.GPL_WRE file in the doc directory.
22  */
23 
24 #ifndef __BLACKBOARD_REMOTE_H_
25 #define __BLACKBOARD_REMOTE_H_
26 
27 #include <blackboard/blackboard.h>
28 #include <netcomm/fawkes/client_handler.h>
29 #include <core/utils/lock_map.h>
30 #include <core/exceptions/software.h>
31 
32 #include <list>
33 
34 namespace fawkes {
35 
36 class FawkesNetworkClient;
37 class FawkesNetworkMessage;
38 class Mutex;
39 class WaitCondition;
40 class Interface;
41 class InterfaceInfoList;
42 
43 class BlackBoardInstanceFactory;
44 class BlackBoardNotifier;
45 class BlackBoardInterfaceProxy;
46 class BlackBoardInterfaceListener;
47 class BlackBoardInterfaceObserver;
48 
50 : public BlackBoard,
52 {
53  public:
55  RemoteBlackBoard(const char *hostname, unsigned short int port);
56  virtual ~RemoteBlackBoard();
57 
58  virtual Interface * open_for_reading(const char *interface_type, const char *identifier);
59  virtual Interface * open_for_writing(const char *interface_type, const char *identifier);
60  virtual void close(Interface *interface);
61 
62  virtual InterfaceInfoList * list_all();
63  virtual InterfaceInfoList * list(const char *type_pattern,
64  const char *id_pattern);
65  virtual bool is_alive() const throw();
66  virtual bool try_aliveness_restore() throw();
67 
68  std::list<Interface *> open_multiple_for_reading(const char *interface_type,
69  const char *id_pattern = "*");
70 
71  /* for FawkesNetworkClientHandler */
72  virtual void deregistered(unsigned int id) throw();
73  virtual void inbound_received(FawkesNetworkMessage *msg,
74  unsigned int id) throw();
75  virtual void connection_died(unsigned int id) throw();
76  virtual void connection_established(unsigned int id) throw();
77 
78 
79  /* extensions for RemoteBlackBoard */
80 
81  private: /* methods */
82  void open_interface(const char *type, const char *identifier,
83  bool writer, Interface *iface);
84  Interface * open_interface(const char *type, const char *identifier, bool writer);
85  void reopen_interfaces();
86 
87 
88  private: /* members */
89  Mutex *__mutex;
90  FawkesNetworkClient *__fnc;
91  bool __fnc_owner;
93  BlackBoardInstanceFactory *__instance_factory;
96  std::list<BlackBoardInterfaceProxy *> __invalid_proxies;
97  std::list<BlackBoardInterfaceProxy *>::iterator __ipit;
98 
99  Mutex *__wait_mutex;
100  WaitCondition *__wait_cond;
101 
102  const char *__inbound_thread;
103 };
104 
105 } // end namespace fawkes
106 
107 #endif