Fawkes API  Fawkes Development Version
interface_listener.h
00001  
00002 /***************************************************************************
00003  *  interface_listener.h - BlackBoard event listener
00004  *
00005  *  Created: Wed Nov 07 23:55:53 2007 (Saw Ella for the first time)
00006  *  Copyright  2007-2008  Tim Niemueller [www.niemueller.de]
00007  *
00008  ****************************************************************************/
00009 
00010 /*  This program is free software; you can redistribute it and/or modify
00011  *  it under the terms of the GNU General Public License as published by
00012  *  the Free Software Foundation; either version 2 of the License, or
00013  *  (at your option) any later version. A runtime exception applies to
00014  *  this software (see LICENSE.GPL_WRE file mentioned below for details).
00015  *
00016  *  This program is distributed in the hope that it will be useful,
00017  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00018  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00019  *  GNU Library General Public License for more details.
00020  *
00021  *  Read the full text in the LICENSE.GPL_WRE file in the doc directory.
00022  */
00023 
00024 #ifndef __BLACKBOARD_INTERFACE_LISTENER_H_
00025 #define __BLACKBOARD_INTERFACE_LISTENER_H_
00026 
00027 #include <core/utils/lock_map.h>
00028 #include <utils/misc/string_compare.h>
00029 #include <string>
00030 
00031 namespace fawkes {
00032 
00033 class Interface;
00034 class Message;
00035 
00036 class BlackBoardInterfaceListener
00037 {
00038  friend class BlackBoardNotifier;
00039 
00040  public:
00041   /** Type for lockable interface maps. */
00042  typedef  LockMap<std::string, Interface *> InterfaceLockMap;
00043  /** Iterator for InterfaceLockMap */
00044  typedef  InterfaceLockMap::iterator   InterfaceLockMapIterator;
00045 
00046 
00047   BlackBoardInterfaceListener(const char *name_format, ...);
00048   virtual ~BlackBoardInterfaceListener();
00049 
00050   const char * bbil_name() const;
00051 
00052   virtual void bb_interface_data_changed(Interface *interface) throw();
00053   virtual bool bb_interface_message_received(Interface *interface, Message *message) throw();
00054   virtual void bb_interface_writer_added(Interface *interface,
00055                                          unsigned int instance_serial) throw();
00056   virtual void bb_interface_writer_removed(Interface *interface,
00057                                            unsigned int instance_serial) throw();
00058   virtual void bb_interface_reader_added(Interface *interface,
00059                                          unsigned int instance_serial) throw();
00060   virtual void bb_interface_reader_removed(Interface *interface,
00061                                            unsigned int instance_serial) throw();
00062 
00063  protected:
00064   void bbil_add_data_interface(Interface *interface);
00065   void bbil_add_message_interface(Interface *interface);
00066   void bbil_add_reader_interface(Interface *interface);
00067   void bbil_add_writer_interface(Interface *interface);
00068 
00069   void bbil_remove_data_interface(Interface *interface);
00070   void bbil_remove_message_interface(Interface *interface);
00071   void bbil_remove_reader_interface(Interface *interface);
00072   void bbil_remove_writer_interface(Interface *interface);
00073 
00074   InterfaceLockMap *      bbil_data_interfaces() throw();
00075   InterfaceLockMap *      bbil_message_interfaces() throw();
00076   InterfaceLockMap *      bbil_reader_interfaces() throw();
00077   InterfaceLockMap *      bbil_writer_interfaces() throw();
00078 
00079   Interface * bbil_data_interface(const char *iuid) throw();
00080   Interface * bbil_message_interface(const char *iuid) throw();
00081   Interface * bbil_reader_interface(const char *iuid) throw();
00082   Interface * bbil_writer_interface(const char *iuid) throw();
00083 
00084  private:
00085   InterfaceLockMap         __bbil_data_interfaces;
00086   InterfaceLockMap         __bbil_message_interfaces;
00087   InterfaceLockMap         __bbil_reader_interfaces;
00088   InterfaceLockMap         __bbil_writer_interfaces;
00089 
00090   InterfaceLockMapIterator __bbil_ii;
00091 
00092   char *__name;
00093 };
00094 
00095 } // end namespace fawkes
00096 
00097 #endif