Fawkes API Fawkes Development Version
interface_mediator.h
1
2/***************************************************************************
3 * interface_mediator.h - BlackBoard Interface Mediator
4 *
5 * Generated: Tue Oct 17 15:35:45 2006
6 * Copyright 2006-2007 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 _INTERFACE_MEDIATOR_H_
25#define _INTERFACE_MEDIATOR_H_
26
27#include <list>
28#include <string>
29
30namespace fawkes {
31
32class Interface;
33
34/** Interface mediator interface.
35 * An interface mediator is used by interfaces to communicate events and to query
36 * status information which need interaction with the BlackBoard.
37 * @author Tim Niemueller
38 */
40{
41public:
42 /** Virtual destructor */
44 {
45 }
46
47 /** Check if a writer exists for the given interface.
48 * @param interface interface to check
49 * @return true, if there is any writer for the given interface, false otherwise
50 */
51 virtual bool exists_writer(const Interface *interface) const = 0;
52
53 /** Get number of readers.
54 * Get the number of readers that the given interface has.
55 * @param interface interface to check
56 * @return number of readers currently registered for the given interface.
57 */
58 virtual unsigned int num_readers(const Interface *interface) const = 0;
59
60 /** Get owners of interfaces who opened for reading.
61 * @param interface an interface to query for the UID
62 * @return list of readers for this interface
63 */
64 virtual std::list<std::string> readers(const Interface *interface) const = 0;
65
66 /** Get writer of interface.
67 * @param interface an interface to query for the UID
68 * @return owner name of writing interface instance, or empty string of no writer exists
69 */
70 virtual std::string writer(const Interface *interface) const = 0;
71
72 /** Notify of data change.
73 * Notify all subscribers of the given interface of a data change.
74 * This also influences logging and sending data over the network so it is
75 * mandatory to call this function! The interface base class write method does
76 * that for you.
77 * @param interface interface whose subscribers to notify
78 * @param has_changed whether the current data is different from the last time write()
79 * was called on the interface
80 * @see Interface::write()
81 */
82 virtual void notify_of_data_refresh(const Interface *interface, bool has_changed) = 0;
83};
84
85} // end namespace fawkes
86
87#endif
Interface mediator interface.
virtual unsigned int num_readers(const Interface *interface) const =0
Get number of readers.
virtual std::list< std::string > readers(const Interface *interface) const =0
Get owners of interfaces who opened for reading.
virtual void notify_of_data_refresh(const Interface *interface, bool has_changed)=0
Notify of data change.
virtual ~InterfaceMediator()
Virtual destructor.
virtual std::string writer(const Interface *interface) const =0
Get writer of interface.
virtual bool exists_writer(const Interface *interface) const =0
Check if a writer exists for the given interface.
Base class for all Fawkes BlackBoard interfaces.
Definition: interface.h:80
Fawkes library namespace.