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 
30 namespace fawkes {
31 
32 class 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 {
41  public:
42  /** Virtual destructor */
43  virtual ~InterfaceMediator() {}
44 
45  /** Check if a writer exists for the given interface.
46  * @param interface interface to check
47  * @return true, if there is any writer for the given interface, false otherwise
48  */
49  virtual bool exists_writer(const Interface *interface) const = 0;
50 
51  /** Get number of readers.
52  * Get the number of readers that the given interface has.
53  * @param interface interface to check
54  * @return number of readers currently registered for the given interface.
55  */
56  virtual unsigned int num_readers(const Interface *interface) const = 0;
57 
58  /** Get owners of interfaces who opened for reading.
59  * @param interface an interface to query for the UID
60  * @return list of readers for this interface
61  */
62  virtual std::list<std::string> readers(const Interface *interface) const = 0;
63 
64  /** Get writer of interface.
65  * @param interface an interface to query for the UID
66  * @return owner name of writing interface instance, or empty string of no writer exists
67  */
68  virtual std::string writer(const Interface *interface) const = 0;
69 
70  /** Notify of data change.
71  * Notify all subscribers of the given interface of a data change.
72  * This also influences logging and sending data over the network so it is
73  * mandatory to call this function! The interface base class write method does
74  * that for you.
75  * @param interface interface whose subscribers to notify
76  * @see Interface::write()
77  */
78  virtual void notify_of_data_change(const Interface *interface) = 0;
79 };
80 
81 } // end namespace fawkes
82 
83 #endif
virtual bool exists_writer(const Interface *interface) const =0
Check if a writer exists for the given interface.
Fawkes library namespace.
virtual unsigned int num_readers(const Interface *interface) const =0
Get number of readers.
Base class for all Fawkes BlackBoard interfaces.
Definition: interface.h:79
virtual std::string writer(const Interface *interface) const =0
Get writer of interface.
Interface mediator interface.
virtual ~InterfaceMediator()
Virtual destructor.
virtual void notify_of_data_change(const Interface *interface)=0
Notify of data change.
virtual std::list< std::string > readers(const Interface *interface) const =0
Get owners of interfaces who opened for reading.