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
Message handler for FawkesNetworkClient.
BlackBoard instance factory.
Wait until a given condition holds.
Simple Fawkes network client.
Definition: client.h:51
virtual bool is_alive() const
Check if the BlackBoard is still alive.
Definition: remote.cpp:137
Representation of a message that is sent over the network.
Definition: message.h:75
virtual void deregistered(unsigned int id)
We are no longer registered in Fawkes network client.
Definition: remote.cpp:450
virtual void connection_established(unsigned int id)
Client has established a connection.
Definition: remote.cpp:536
Base class for all Fawkes BlackBoard interfaces.
Definition: interface.h:80
virtual InterfaceInfoList * list(const char *type_pattern, const char *id_pattern)
Get list of interfaces matching type and ID patterns.
Definition: remote.cpp:395
Map with a lock.
Definition: lock_map.h:37
Interface information list.
virtual void close(Interface *interface)
Close interface.
Definition: remote.cpp:326
virtual ~RemoteBlackBoard()
Destructor.
Definition: remote.cpp:116
virtual bool try_aliveness_restore()
Try to restore the aliveness of the BlackBoard instance.
Definition: remote.cpp:163
virtual void inbound_received(FawkesNetworkMessage *msg, unsigned int id)
Called for incoming messages.
Definition: remote.cpp:456
virtual void connection_died(unsigned int id)
Client connection died.
Definition: remote.cpp:521
virtual Interface * open_for_reading(const char *interface_type, const char *identifier)
Open interface for reading.
Definition: remote.cpp:272
Remote BlackBoard.
Definition: remote.h:49
RemoteBlackBoard(FawkesNetworkClient *client)
Constructor.
Definition: remote.cpp:58
virtual InterfaceInfoList * list_all()
Get list of all currently existing interfaces.
Definition: remote.cpp:353
The BlackBoard abstract class.
Definition: blackboard.h:49
Mutex mutual exclusion lock.
Definition: mutex.h:32
std::list< Interface * > open_multiple_for_reading(const char *interface_type, const char *id_pattern="*")
Open multiple interfaces for reading.
Definition: remote.cpp:286
virtual Interface * open_for_writing(const char *interface_type, const char *identifier)
Open interface for writing.
Definition: remote.cpp:279