interface_proxy.h

00001 
00002 /***************************************************************************
00003  *  interface_proxy.h - BlackBoard interface proxy for RemoteBlackBoard
00004  *
00005  *  Created: Tue Mar 04 10:52:28 2008
00006  *  Copyright  2006-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_PROXY_H
00025 #define __BLACKBOARD_INTERFACE_PROXY_H_
00026 
00027 #include <interface/mediators/interface_mediator.h>
00028 #include <interface/mediators/message_mediator.h>
00029 #include <cstdlib>
00030 
00031 namespace fawkes {
00032 
00033 class FawkesNetworkClient;
00034 class FawkesNetworkMessage;
00035 class RefCountRWLock;
00036 class BlackBoardNotifier;
00037 class Interface;
00038 
00039 class BlackBoardInterfaceProxy
00040 : public InterfaceMediator,
00041   public MessageMediator
00042 {
00043  public:
00044   BlackBoardInterfaceProxy(FawkesNetworkClient *client, FawkesNetworkMessage *msg,
00045                            BlackBoardNotifier *notifier, Interface *interface,
00046                            bool readwrite);
00047   ~BlackBoardInterfaceProxy();
00048 
00049   void process_data_changed(FawkesNetworkMessage *msg);
00050   void process_interface_message(FawkesNetworkMessage *msg);
00051   void reader_added(unsigned int event_serial);
00052   void reader_removed(unsigned int event_serial);
00053   void writer_added(unsigned int event_serial);
00054   void writer_removed(unsigned int event_serial);
00055 
00056   unsigned int serial() const;
00057   unsigned int clid() const;
00058   Interface *  interface() const;
00059 
00060   /* InterfaceMediator */
00061   virtual bool exists_writer(const Interface *interface) const;
00062   virtual unsigned int num_readers(const Interface *interface) const;
00063   virtual void notify_of_data_change(const Interface *interface);
00064 
00065   /* MessageMediator */
00066   virtual void transmit(Message *message);
00067 
00068  private:
00069   inline unsigned int next_msg_id()
00070   {
00071     return ((__instance_serial << 16) | __next_msg_id++);
00072   }
00073 
00074  private:
00075   FawkesNetworkClient *__fnc;
00076 
00077   RefCountRWLock      *__rwlock;
00078   BlackBoardNotifier  *__notifier;
00079   Interface           *__interface;
00080 
00081   void                *__mem_chunk;
00082   void                *__data_chunk;
00083   size_t               __data_size;
00084 
00085   unsigned short       __instance_serial;
00086   unsigned short       __next_msg_id;
00087   unsigned int         __num_readers;
00088   bool                 __has_writer;
00089   unsigned int         __clid;
00090 };
00091 
00092 } // end namespace fawkes
00093 
00094 #endif

Generated on 1 Mar 2011 for Fawkes API by  doxygen 1.6.1