00001 // $Id: IOEvent.hh 1781 2011-04-11 12:10:19Z tho $ 00002 // 00003 // Copyright (C) 2007 00004 // Fraunhofer (FOKUS) 00005 // Competence Center NETwork research (NET), St. Augustin, GERMANY 00006 // Stefan Bund <g0dil@berlios.de> 00007 // 00008 // This program is free software; you can redistribute it and/or modify 00009 // it under the terms of the GNU General Public License as published by 00010 // the Free Software Foundation; either version 2 of the License, or 00011 // (at your option) any later version. 00012 // 00013 // This program is distributed in the hope that it will be useful, 00014 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00016 // GNU General Public License for more details. 00017 // 00018 // You should have received a copy of the GNU General Public License 00019 // along with this program; if not, write to the 00020 // Free Software Foundation, Inc., 00021 // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00022 00026 #ifndef HH_SENF_PPI_IOEvent_ 00027 #define HH_SENF_PPI_IOEvent_ 1 00028 00029 // Custom includes 00030 #include <senf/Scheduler/FdEvent.hh> 00031 #include <senf/Utils/Exception.hh> 00032 #include "Events.hh" 00033 00034 //#include "IOEvent.mpp" 00035 //-///////////////////////////////////////////////////////////////////////////////////////////////// 00036 00037 namespace senf { 00038 namespace ppi { 00039 00044 struct IOEventInfo 00045 { 00046 unsigned events; 00047 00049 }; 00050 00069 class IOEvent 00070 : public EventImplementation<IOEventInfo> 00071 { 00072 public: 00073 //-//////////////////////////////////////////////////////////////////////// 00074 // Types 00075 00076 // This is stupid, however there is no way to import the Scheduler::EventId enum together 00077 // with the enumeration symbols 00078 00079 enum EventFlags { 00080 Read = scheduler::FdEvent::EV_READ 00081 , Prio = scheduler::FdEvent::EV_PRIO 00082 , Write = scheduler::FdEvent::EV_WRITE 00083 , Hup = scheduler::FdEvent::EV_HUP 00084 , Err = scheduler::FdEvent::EV_ERR 00085 }; 00086 00087 //-//////////////////////////////////////////////////////////////////////// 00089 //\{ 00090 00091 IOEvent(); 00092 00093 template <class Handle> 00094 IOEvent(Handle handle, unsigned events); 00095 00096 //\} 00097 //-//////////////////////////////////////////////////////////////////////// 00098 00099 template <class Handle> 00100 void set(Handle handle, unsigned events); 00101 00103 struct ErrorException : public senf::Exception 00104 { ErrorException() : senf::Exception("senf::ppi::IOEvent::ErrorException") {} }; 00105 00107 struct HangupException : public senf::Exception 00108 { HangupException() : senf::Exception("senf::ppi::IOEvent::HangupException") {} }; 00109 00110 private: 00111 virtual void v_enable(); 00112 virtual void v_disable(); 00113 00114 void cb(int event); 00115 00116 int fd_; 00117 scheduler::FdEvent event_; 00118 }; 00119 00120 }} 00121 00122 //-///////////////////////////////////////////////////////////////////////////////////////////////// 00123 #include "IOEvent.cci" 00124 #include "IOEvent.ct" 00125 #include "IOEvent.cti" 00126 #endif 00127 00128 00129 // Local Variables: 00130 // mode: c++ 00131 // fill-column: 100 00132 // comment-column: 40 00133 // c-file-style: "senf" 00134 // indent-tabs-mode: nil 00135 // ispell-local-dictionary: "american" 00136 // compile-command: "scons -u test" 00137 // End: