Fawkes API  Fawkes Development Version
interface_observer.h
00001  
00002 /***************************************************************************
00003  *  interface_observer.h - BlackBoard interface observer
00004  *
00005  *  Created: Fri Jan 25 18:19:00 2008 (Just back from Hacking with Fawkes talk)
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_OBSERVER_H_
00025 #define __BLACKBOARD_INTERFACE_OBSERVER_H_
00026 
00027 #include <core/utils/lock_map.h>
00028 
00029 #include <list>
00030 #include <string>
00031 
00032 namespace fawkes {
00033 
00034 class BlackBoardInterfaceObserver
00035 {
00036 
00037  friend class BlackBoardNotifier;
00038 
00039  public:
00040   BlackBoardInterfaceObserver();
00041   virtual ~BlackBoardInterfaceObserver();
00042 
00043   virtual void bb_interface_created(const char *type, const char *id) throw();
00044   virtual void bb_interface_destroyed(const char *type, const char *id) throw();
00045 
00046  protected:
00047   void bbio_add_observed_create(const char *type_pattern,
00048                                 const char *id_pattern = "*") throw();
00049   void bbio_add_observed_destroy(const char *type_pattern,
00050                                  const char *id_pattern = "*") throw();
00051 
00052   /** Type for lockable interface type hash sets. */
00053   typedef  LockMap<std::string, std::list<std::string> >  ObservedInterfaceLockMap;
00054 
00055   /** Type for iterator of lockable interface type hash sets. */
00056   typedef  ObservedInterfaceLockMap::iterator   ObservedInterfaceLockMapIterator;
00057 
00058   ObservedInterfaceLockMap *  bbio_get_observed_create() throw();
00059   ObservedInterfaceLockMap *  bbio_get_observed_destroy() throw();
00060 
00061  private:
00062   ObservedInterfaceLockMap         __bbio_observed_create;
00063   ObservedInterfaceLockMap         __bbio_observed_destroy;
00064   ObservedInterfaceLockMapIterator __bbio_iti;
00065 };
00066 
00067 } // end namespace fawkes
00068 
00069 #endif