Fawkes API  Fawkes Development Version
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-2015 Tim Niemueller [www.niemueller.de]
7  ****************************************************************************/
8 
9 /* This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version. A runtime exception applies to
13  * this software (see LICENSE.GPL_WRE file mentioned below for details).
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU Library General Public License for more details.
19  *
20  * Read the full text in the LICENSE.GPL_WRE file in the doc directory.
21  */
22 
23 #ifndef __BLACKBOARD_REMOTE_H_
24 #define __BLACKBOARD_REMOTE_H_
25 
26 #include <blackboard/blackboard.h>
27 #include <netcomm/fawkes/client_handler.h>
28 #include <core/utils/lock_map.h>
29 #include <core/exceptions/software.h>
30 
31 #include <list>
32 
33 namespace fawkes {
34 
35 class FawkesNetworkClient;
36 class FawkesNetworkMessage;
37 class Mutex;
38 class WaitCondition;
39 class Interface;
40 class InterfaceInfoList;
41 
42 class BlackBoardInstanceFactory;
43 class BlackBoardNotifier;
44 class BlackBoardInterfaceProxy;
45 class BlackBoardInterfaceListener;
46 class BlackBoardInterfaceObserver;
47 
49 : public BlackBoard,
51 {
52  public:
54  RemoteBlackBoard(const char *hostname, unsigned short int port);
55  virtual ~RemoteBlackBoard();
56 
57  virtual Interface * open_for_reading(const char *interface_type, const char *identifier,
58  const char *owner = NULL);
59  virtual Interface * open_for_writing(const char *interface_type, const char *identifier,
60  const char *owner = NULL);
61  virtual void close(Interface *interface);
62 
63  virtual InterfaceInfoList * list_all();
64  virtual InterfaceInfoList * list(const char *type_pattern,
65  const char *id_pattern);
66  virtual bool is_alive() const throw();
67  virtual bool try_aliveness_restore() throw();
68 
69  std::list<Interface *> open_multiple_for_reading(const char *interface_type,
70  const char *id_pattern = "*",
71  const char *owner = NULL);
72 
73  /* for FawkesNetworkClientHandler */
74  virtual void deregistered(unsigned int id) throw();
75  virtual void inbound_received(FawkesNetworkMessage *msg,
76  unsigned int id) throw();
77  virtual void connection_died(unsigned int id) throw();
78  virtual void connection_established(unsigned int id) throw();
79 
80 
81  /* extensions for RemoteBlackBoard */
82 
83  private: /* methods */
84  void open_interface(const char *type, const char *identifier, const char *owner,
85  bool writer, Interface *iface);
86  Interface * open_interface(const char *type, const char *identifier, const char *owner, bool writer);
87  void reopen_interfaces();
88 
89 
90  private: /* members */
91  Mutex *__mutex;
92  FawkesNetworkClient *__fnc;
93  bool __fnc_owner;
95  BlackBoardInstanceFactory *__instance_factory;
98  std::list<BlackBoardInterfaceProxy *> __invalid_proxies;
99  std::list<BlackBoardInterfaceProxy *>::iterator __ipit;
100 
101  Mutex *__wait_mutex;
102  WaitCondition *__wait_cond;
103 
104  const char *__inbound_thread;
105 };
106 
107 } // end namespace fawkes
108 
109 #endif
Message handler for FawkesNetworkClient.
BlackBoard instance factory.
Wait until a given condition holds.
virtual Interface * open_for_writing(const char *interface_type, const char *identifier, const char *owner=NULL)
Open interface for writing.
Definition: remote.cpp:279
Simple Fawkes network client.
Definition: client.h:52
Fawkes library namespace.
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:456
virtual void connection_established(unsigned int id)
Client has established a connection.
Definition: remote.cpp:542
Base class for all Fawkes BlackBoard interfaces.
Definition: interface.h:79
virtual InterfaceInfoList * list(const char *type_pattern, const char *id_pattern)
Get list of interfaces matching type and ID patterns.
Definition: remote.cpp:398
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:462
virtual void connection_died(unsigned int id)
Client connection died.
Definition: remote.cpp:527
Remote BlackBoard.
Definition: remote.h:48
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:48
Mutex mutual exclusion lock.
Definition: mutex.h:32
virtual bool is_alive() const
Check if the BlackBoard is still alive.
Definition: remote.cpp:137
virtual Interface * open_for_reading(const char *interface_type, const char *identifier, const char *owner=NULL)
Open interface for reading.
Definition: remote.cpp:272
std::list< Interface * > open_multiple_for_reading(const char *interface_type, const char *id_pattern="*", const char *owner=NULL)
Open multiple interfaces for reading.
Definition: remote.cpp:286