4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
5 // Competence Center NETwork research (NET), St. Augustin, GERMANY
6 // Stefan Bund <g0dil@berlios.de>
8 // This program is free software; you can redistribute it and/or modify
9 // it under the terms of the GNU General Public License as published by
10 // the Free Software Foundation; either version 2 of the License, or
11 // (at your option) any later version.
13 // This program is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 // GNU General Public License for more details.
18 // You should have received a copy of the GNU General Public License
19 // along with this program; if not, write to the
20 // Free Software Foundation, Inc.,
21 // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24 \brief IOEvent public header */
26 #ifndef HH_SENF_PPI_IOEvent_
27 #define HH_SENF_PPI_IOEvent_ 1
30 #include "../Scheduler/Scheduler.hh"
32 #include "../Utils/Exception.hh"
34 //#include "IOEvent.mpp"
35 ///////////////////////////////hh.p////////////////////////////////////////
40 /** \brief IOEvent event information
42 Information passed to the IOEvent event handler
46 unsigned events; ///< Type of event signaled
47 /**< The value is a combination of the flags from
48 IOEvent::EventFlags */
51 /** \brief FileHandle based I/O read/write event
53 An IOEvent is signaled, whenever the FileHandle \a handle becomes readable or writable. The
54 type of event is specified using the \a events mask with values from EventFlags.
56 There are two types of flags:
58 \li <em>Event flags</em> (\ref Read, \ref Prio, \ref Write) specify the type of event. The
59 callback will be called whenever one of the specified events occurs on the filehandle
60 \li <em>Error flags</em> (\ref Hup, \ref Err) specify some type of error condition on the
61 filehandle. If you specify an error flag when registering the event, the error condition
62 will be passed to the callback, otherwise an ErrorException or HangupException will be
70 : public EventImplementation<IOEventInfo>
73 ///////////////////////////////////////////////////////////////////////////
76 // This is stupid, however there is no way to import the Scheduler::EventId enum together
77 // with the enumeration symbols
80 Read = scheduler::FdEvent::EV_READ /**< FileHandle is readable */
81 , Prio = scheduler::FdEvent::EV_PRIO /**< FileHandle priority data is readable */
82 , Write = scheduler::FdEvent::EV_WRITE /**< FileHandle is writable */
83 , Hup = scheduler::FdEvent::EV_HUP /**< Hangup condition on FileHandle */
84 , Err = scheduler::FdEvent::EV_ERR /**< Some other error condition on FileHandle */
87 ///////////////////////////////////////////////////////////////////////////
88 ///\name Structors and default members
93 template <class Handle>
94 IOEvent(Handle handle, unsigned events);
97 ///////////////////////////////////////////////////////////////////////////
99 template <class Handle>
100 void set(Handle handle, unsigned events);
102 /** \brief Unhandled error condition */
103 struct ErrorException : public senf::Exception
104 { ErrorException() : senf::Exception("senf::ppi::IOEvent::ErrorException"){} };
106 /** \brief Unhandled hangup condition */
107 struct HangupException : public senf::Exception
108 { HangupException() : senf::Exception("senf::ppi::IOEvent::HangupException"){} };
113 virtual void v_enable();
114 virtual void v_disable();
119 scheduler::FdEvent event_;
125 ///////////////////////////////hh.e////////////////////////////////////////
126 #include "IOEvent.cci"
127 #include "IOEvent.ct"
128 #include "IOEvent.cti"
135 // comment-column: 40
136 // c-file-style: "senf"
137 // indent-tabs-mode: nil
138 // ispell-local-dictionary: "american"
139 // compile-command: "scons -u test"