Fawkes API Fawkes Development Version
interface_proxy.h
1
2/***************************************************************************
3 * interface_proxy.h - BlackBoard interface proxy for RemoteBlackBoard
4 *
5 * Created: Tue Mar 04 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_INTERFACE_PROXY_H_
25#define _BLACKBOARD_INTERFACE_PROXY_H_
26
27#include <interface/mediators/interface_mediator.h>
28#include <interface/mediators/message_mediator.h>
29#include <utils/uuid.h>
30
31#include <cstdlib>
32
33namespace fawkes {
34
35class FawkesNetworkClient;
36class FawkesNetworkMessage;
37class RefCountRWLock;
38class BlackBoardNotifier;
39class Interface;
40
42{
43public:
46 BlackBoardNotifier * notifier,
48 bool readwrite);
50
53 void reader_added(Uuid event_serial);
54 void reader_removed(Uuid event_serial);
55 void writer_added(Uuid event_serial);
56 void writer_removed(Uuid event_serial);
57
58 Uuid serial() const;
59 Uuid clid() const;
60 Interface *interface() const;
61
62 /* InterfaceMediator */
63 virtual bool exists_writer(const Interface *interface) const;
64 virtual unsigned int num_readers(const Interface *interface) const;
65 virtual void notify_of_data_refresh(const Interface *interface, bool has_changed);
66 virtual std::list<std::string> readers(const Interface *interface) const;
67 virtual std::string writer(const Interface *interface) const;
68
69 /* MessageMediator */
70 virtual void transmit(Message *message);
71
72private:
73 inline unsigned int
74 next_msg_id()
75 {
76 return next_msg_id_++;
77 }
78
79private:
81
82 RefCountRWLock * rwlock_;
83 BlackBoardNotifier *notifier_;
84 Interface * interface_;
85
86 void * mem_chunk_;
87 void * data_chunk_;
88 size_t data_size_;
89
90 Uuid instance_serial_;
91 unsigned short next_msg_id_;
92 unsigned int num_readers_;
93 bool has_writer_;
94 unsigned int clid_;
95};
96
97} // end namespace fawkes
98
99#endif
Interface proxy for remote BlackBoard.
virtual void transmit(Message *message)
Transmit message.
Uuid clid() const
Get client ID of assigned client.
Interface * interface() const
Get instance serial of interface.
void process_interface_message(FawkesNetworkMessage *msg)
Process MSG_BB_INTERFACE message.
virtual bool exists_writer(const Interface *interface) const
Check if a writer exists for the given interface.
void reader_removed(Uuid event_serial)
Reader has been removed.
void reader_added(Uuid event_serial)
Reader has been added.
Uuid serial() const
Get instance serial of interface.
void process_data_refreshed(FawkesNetworkMessage *msg)
Process MSG_BB_DATA_CHANGED/REFRESHED message.
virtual void notify_of_data_refresh(const Interface *interface, bool has_changed)
Notify of data change.
virtual unsigned int num_readers(const Interface *interface) const
Get number of readers.
BlackBoardInterfaceProxy(FawkesNetworkClient *client, FawkesNetworkMessage *msg, BlackBoardNotifier *notifier, Interface *interface, bool readwrite)
Constructor.
virtual std::list< std::string > readers(const Interface *interface) const
Get owners of interfaces who opened for reading.
virtual std::string writer(const Interface *interface) const
Get writer of interface.
void writer_added(Uuid event_serial)
Writer has been added.
void writer_removed(Uuid event_serial)
Writer has been removed.
BlackBoard notifier.
Definition: notifier.h:44
Simple Fawkes network client.
Definition: client.h:52
Representation of a message that is sent over the network.
Definition: message.h:77
Interface mediator interface.
Base class for all Fawkes BlackBoard interfaces.
Definition: interface.h:80
Message mediator interface.
Base class for all messages passed through interfaces in Fawkes BlackBoard.
Definition: message.h:44
Read/write lock with reference counting.
Definition: refc_rwlock.h:33
A convenience class for universally unique identifiers (UUIDs).
Definition: uuid.h:29
Fawkes library namespace.