00001 00002 /*************************************************************************** 00003 * writer_listener.cpp - Sync Writer Interface Listener 00004 * 00005 * Created: Fri Jun 05 16:16:22 2009 00006 * Copyright 2006-2009 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. 00014 * 00015 * This program is distributed in the hope that it will be useful, 00016 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00017 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00018 * GNU Library General Public License for more details. 00019 * 00020 * Read the full text in the LICENSE.GPL file in the doc directory. 00021 */ 00022 00023 #include "writer_listener.h" 00024 #include "sync_thread.h" 00025 00026 #include <blackboard/blackboard.h> 00027 #include <utils/logging/logger.h> 00028 00029 using namespace fawkes; 00030 00031 /** @class SyncWriterInterfaceListener "writer_listener.h" 00032 * Listener for writer events in bbsync plugin. 00033 * This class provides an adapter which reacts to writer events for a given 00034 * number of (reading) interfaces. Note that the listener is <i>not</i> 00035 * automatically registered, this has to be done from the outside. 00036 * @author Tim Niemueller 00037 */ 00038 00039 /** Constructor. 00040 * @param sync_thread parent sync thread to sent events to 00041 * @param logger logger for informational output 00042 * @param desc description for this interface combination 00043 */ 00044 SyncWriterInterfaceListener::SyncWriterInterfaceListener(BlackBoardSynchronizationThread *sync_thread, 00045 fawkes::Logger *logger, 00046 const char *desc) 00047 : BlackBoardInterfaceListener("SyncWriterInterfaceListener(%s)", desc) 00048 { 00049 __logger = logger; 00050 __sync_thread = sync_thread; 00051 } 00052 00053 00054 /** Add an interface to listen to. 00055 * @param interface interface to listen to for writer events 00056 */ 00057 void 00058 SyncWriterInterfaceListener::add_interface(Interface *interface) 00059 { 00060 bbil_add_writer_interface(interface); 00061 } 00062 00063 00064 /** Remove an interface to listen to. 00065 * @param interface interface not to listen any longer for writer events 00066 */ 00067 void 00068 SyncWriterInterfaceListener::remove_interface(Interface *interface) 00069 { 00070 bbil_remove_writer_interface(interface); 00071 } 00072 00073 void 00074 SyncWriterInterfaceListener::bb_interface_writer_added(fawkes::Interface *interface, 00075 unsigned int instance_serial) throw() 00076 { 00077 __sync_thread->writer_added(interface); 00078 } 00079 00080 00081 void 00082 SyncWriterInterfaceListener::bb_interface_writer_removed(fawkes::Interface *interface, 00083 unsigned int instance_serial) throw() 00084 { 00085 __sync_thread->writer_removed(interface); 00086 }