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 <core/exceptions/software.h>
28 #include <core/utils/lock_map.h>
29 #include <netcomm/fawkes/client_handler.h>
30 #include <utils/uuid.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 {
51 public:
53  RemoteBlackBoard(const char *hostname, unsigned short int port);
54  virtual ~RemoteBlackBoard();
55 
56  virtual Interface *
57  open_for_reading(const char *interface_type, const char *identifier, const char *owner = NULL);
58  virtual Interface *
59  open_for_writing(const char *interface_type, const char *identifier, const char *owner = NULL);
60  virtual void close(Interface *interface);
61 
62  virtual InterfaceInfoList *list_all();
63  virtual InterfaceInfoList *list(const char *type_pattern, const char *id_pattern);
64  virtual bool is_alive() const noexcept;
65  virtual bool try_aliveness_restore() noexcept;
66 
67  std::list<Interface *> open_multiple_for_reading(const char *interface_type,
68  const char *id_pattern = "*",
69  const char *owner = NULL);
70 
71  /* for FawkesNetworkClientHandler */
72  virtual void deregistered(unsigned int id) noexcept;
73  virtual void inbound_received(FawkesNetworkMessage *msg, unsigned int id) noexcept;
74  virtual void connection_died(unsigned int id) noexcept;
75  virtual void connection_established(unsigned int id) noexcept;
76 
77  /* extensions for RemoteBlackBoard */
78 
79 private: /* methods */
80  void open_interface(const char *type,
81  const char *identifier,
82  const char *owner,
83  bool writer,
84  Interface * iface);
85  Interface *
86  open_interface(const char *type, const char *identifier, const char *owner, bool writer);
87  void reopen_interfaces();
88 
89 private: /* members */
90  Mutex * mutex_;
91  FawkesNetworkClient * fnc_;
92  bool fnc_owner_;
94  BlackBoardInstanceFactory * instance_factory_;
97  std::list<BlackBoardInterfaceProxy *> invalid_proxies_;
98  std::list<BlackBoardInterfaceProxy *>::iterator ipit_;
99 
100  Mutex * wait_mutex_;
101  WaitCondition *wait_cond_;
102 
103  const char *inbound_thread_;
104 };
105 
106 } // end namespace fawkes
107 
108 #endif
BlackBoard instance factory.
The BlackBoard abstract class.
Definition: blackboard.h:46
Message handler for FawkesNetworkClient.
Simple Fawkes network client.
Definition: client.h:52
Representation of a message that is sent over the network.
Definition: message.h:77
Interface information list.
Base class for all Fawkes BlackBoard interfaces.
Definition: interface.h:80
Map with a lock.
Definition: lock_map.h:36
Mutex mutual exclusion lock.
Definition: mutex.h:33
Remote BlackBoard.
Definition: remote.h:50
virtual bool try_aliveness_restore() noexcept
Try to restore the aliveness of the BlackBoard instance.
Definition: remote.cpp:157
virtual Interface * open_for_reading(const char *interface_type, const char *identifier, const char *owner=NULL)
Open interface for reading.
Definition: remote.cpp:267
virtual ~RemoteBlackBoard()
Destructor.
Definition: remote.cpp:112
virtual InterfaceInfoList * list_all()
Get list of all currently existing interfaces.
Definition: remote.cpp:345
virtual InterfaceInfoList * list(const char *type_pattern, const char *id_pattern)
Get list of interfaces matching type and ID patterns.
Definition: remote.cpp:391
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:279
virtual void connection_died(unsigned int id) noexcept
Client connection died.
Definition: remote.cpp:515
virtual void deregistered(unsigned int id) noexcept
We are no longer registered in Fawkes network client.
Definition: remote.cpp:447
virtual Interface * open_for_writing(const char *interface_type, const char *identifier, const char *owner=NULL)
Open interface for writing.
Definition: remote.cpp:273
virtual void connection_established(unsigned int id) noexcept
Client has established a connection.
Definition: remote.cpp:529
virtual bool is_alive() const noexcept
Check if the BlackBoard is still alive.
Definition: remote.cpp:132
virtual void close(Interface *interface)
Close interface.
Definition: remote.cpp:319
virtual void inbound_received(FawkesNetworkMessage *msg, unsigned int id) noexcept
Called for incoming messages.
Definition: remote.cpp:452
RemoteBlackBoard(FawkesNetworkClient *client)
Constructor.
Definition: remote.cpp:56
Wait until a given condition holds.
Fawkes library namespace.