4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
6 // The contents of this file are subject to the Fraunhofer FOKUS Public License
7 // Version 1.0 (the "License"); you may not use this file except in compliance
8 // with the License. You may obtain a copy of the License at
9 // http://senf.berlios.de/license.html
11 // The Fraunhofer FOKUS Public License Version 1.0 is based on,
12 // but modifies the Mozilla Public License Version 1.1.
13 // See the full license text for the amendments.
15 // Software distributed under the License is distributed on an "AS IS" basis,
16 // WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
17 // for the specific language governing rights and limitations under the License.
19 // The Original Code is Fraunhofer FOKUS code.
21 // The Initial Developer of the Original Code is Fraunhofer-Gesellschaft e.V.
22 // (registered association), Hansastraße 27 c, 80686 Munich, Germany.
23 // All Rights Reserved.
26 // Stefan Bund <g0dil@berlios.de>
29 \brief IOEvent public header */
31 #ifndef HH_SENF_PPI_IOEvent_
32 #define HH_SENF_PPI_IOEvent_ 1
35 #include <senf/Scheduler/FdEvent.hh>
36 #include <senf/Utils/Exception.hh>
39 //#include "IOEvent.mpp"
40 //-/////////////////////////////////////////////////////////////////////////////////////////////////
45 /** \brief IOEvent event information
47 Information passed to the IOEvent event handler
51 unsigned events; ///< Type of event signaled
52 /**< The value is a combination of the flags from
53 IOEvent::EventFlags */
56 /** \brief FileHandle based I/O read/write event
58 An IOEvent is signaled, whenever the FileHandle \a handle becomes readable or writable. The
59 type of event is specified using the \a events mask with values from EventFlags.
61 There are two types of flags:
63 \li <em>Event flags</em> (\ref Read, \ref Prio, \ref Write) specify the type of event. The
64 callback will be called whenever one of the specified events occurs on the filehandle
65 \li <em>Error flags</em> (\ref Hup, \ref Err) specify some type of error condition on the
66 filehandle. If you specify an error flag when registering the event, the error condition
67 will be passed to the callback, otherwise an ErrorException or HangupException will be
75 : public EventImplementation<IOEventInfo>
78 //-////////////////////////////////////////////////////////////////////////
81 // This is stupid, however there is no way to import the Scheduler::EventId enum together
82 // with the enumeration symbols
85 Read = scheduler::FdEvent::EV_READ /**< FileHandle is readable */
86 , Prio = scheduler::FdEvent::EV_PRIO /**< FileHandle priority data is readable */
87 , Write = scheduler::FdEvent::EV_WRITE /**< FileHandle is writable */
88 , Hup = scheduler::FdEvent::EV_HUP /**< Hangup condition on FileHandle */
89 , Err = scheduler::FdEvent::EV_ERR /**< Some other error condition on FileHandle */
92 //-////////////////////////////////////////////////////////////////////////
93 ///\name Structors and default members
98 template <class Handle>
99 IOEvent(Handle handle, unsigned events);
102 //-////////////////////////////////////////////////////////////////////////
104 template <class Handle>
105 void set(Handle handle, unsigned events);
107 /** \brief Unhandled error condition */
108 struct ErrorException : public senf::Exception
109 { ErrorException() : senf::Exception("senf::ppi::IOEvent::ErrorException") {} };
111 /** \brief Unhandled hangup condition */
112 struct HangupException : public senf::Exception
113 { HangupException() : senf::Exception("senf::ppi::IOEvent::HangupException") {} };
116 virtual void v_enable();
117 virtual void v_disable();
122 scheduler::FdEvent event_;
127 //-/////////////////////////////////////////////////////////////////////////////////////////////////
128 #include "IOEvent.cci"
129 #include "IOEvent.ct"
130 #include "IOEvent.cti"
137 // comment-column: 40
138 // c-file-style: "senf"
139 // indent-tabs-mode: nil
140 // ispell-local-dictionary: "american"
141 // compile-command: "scons -u test"