00001 #ifndef IONFLUX_TOOLS_IOMULTIPLEXER 00002 #define IONFLUX_TOOLS_IOMULTIPLEXER 00003 /* ========================================================================== 00004 * Ionflux Tools 00005 * Copyright (c) 2004 Joern P. Meier 00006 * mail@ionflux.org 00007 * -------------------------------------------------------------------------- 00008 * IOMultiplexer.hpp IO event multiplexer (abstract class). 00009 * ========================================================================== 00010 * 00011 * This file is part of Ionflux Tools. 00012 * 00013 * Ionflux Tools is free software; you can redistribute it and/or modify it 00014 * under the terms of the GNU General Public License as published by the Free 00015 * Software Foundation; either version 2 of the License, or (at your option) 00016 * any later version. 00017 * 00018 * Ionflux Tools is distributed in the hope that it will be useful, but 00019 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 00020 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 00021 * for more details. 00022 * 00023 * You should have received a copy of the GNU General Public License 00024 * along with Ionflux Tools; if not, write to the Free Software Foundation, 00025 * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00026 * 00027 * ========================================================================== */ 00028 00029 #include <string> 00030 #include <iostream> 00031 #include <sstream> 00032 #include <vector> 00033 #include <signal.h> 00034 #include "ionflux/IOHandler.hpp" 00035 #include "ionflux/Reporter.hpp" 00036 00037 namespace Ionflux 00038 { 00039 00040 namespace Tools 00041 { 00042 00050 00051 struct IOEventInfo 00052 { 00054 IOEvent event; 00056 IOHandler *handler; 00057 }; 00058 00071 class IOMultiplexer 00072 { 00073 protected: 00075 int type; 00076 00077 public: 00079 static const int IOM_TYPE_UNDEFINED; 00081 static const int IOM_TYPE_SELECT; 00083 static const int IOM_TYPE_GLIB; 00084 00089 IOMultiplexer(); 00090 00095 virtual ~IOMultiplexer() { }; 00096 00104 virtual void registerEvent(IOHandler *handler, IOEvent event) = 0; 00105 00113 virtual void removeEvent(IOHandler *handler, IOEvent event) = 0; 00114 00119 virtual void run() = 0; 00120 00125 virtual void quit() = 0; 00126 00131 virtual bool isRunning() = 0; 00132 00144 virtual int getType(); 00145 00152 static void shutdownHandler(int signum); 00153 00158 virtual Reporter &getLog() = 0; 00159 }; 00160 00162 00163 } 00164 00165 } 00166 00170 #endif