Fix documentation build under maverick (doxygen 1.7.1)
[senf.git] / senf / PPI / IOEvent.hh
1 // $Id$
2 //
3 // Copyright (C) 2007
4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
5 // Competence Center NETwork research (NET), St. Augustin, GERMANY
6 //     Stefan Bund <g0dil@berlios.de>
7 //
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.
12 //
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.
17 //
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.
22
23 /** \file
24     \brief IOEvent public header */
25
26 #ifndef HH_SENF_PPI_IOEvent_
27 #define HH_SENF_PPI_IOEvent_ 1
28
29 // Custom includes
30 #include <senf/Scheduler/Scheduler.hh>
31 #include "Events.hh"
32 #include <senf/Utils/Exception.hh>
33
34 //#include "IOEvent.mpp"
35 //-/////////////////////////////////////////////////////////////////////////////////////////////////
36
37 namespace senf {
38 namespace ppi {
39
40     /** \brief IOEvent event information
41
42         Information passed to the IOEvent event handler
43      */
44     struct IOEventInfo
45     {
46         unsigned events;                ///< Type of event signaled
47                                         /**< The value is a combination of the flags from
48                                              IOEvent::EventFlags */
49     };
50
51     /** \brief FileHandle based I/O read/write event
52
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.
55
56         There are two types of flags:
57
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
63             thrown.
64
65         \see IOEventInfo
66
67         \ingroup event_group
68       */
69     class IOEvent
70         : public EventImplementation<IOEventInfo>
71     {
72     public:
73         //-////////////////////////////////////////////////////////////////////////
74         // Types
75
76         // This is stupid, however there is no way to import the Scheduler::EventId enum together
77         // with the enumeration symbols
78
79         enum EventFlags {
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 */
85         };
86
87         //-////////////////////////////////////////////////////////////////////////
88         ///\name Structors and default members
89         //\{
90
91         IOEvent();
92
93         template <class Handle>
94         IOEvent(Handle handle, unsigned events);
95
96         //\}
97         //-////////////////////////////////////////////////////////////////////////
98
99         template <class Handle>
100         void set(Handle handle, unsigned events);
101
102         /** \brief Unhandled error condition */
103         struct ErrorException : public senf::Exception
104         { ErrorException() : senf::Exception("senf::ppi::IOEvent::ErrorException") {} };
105
106         /** \brief Unhandled hangup condition */
107         struct HangupException : public senf::Exception
108         { HangupException() : senf::Exception("senf::ppi::IOEvent::HangupException") {} };
109
110     protected:
111
112     private:
113         virtual void v_enable();
114         virtual void v_disable();
115
116         void cb(int event);
117
118         int fd_;
119         scheduler::FdEvent event_;
120     };
121
122
123 }}
124
125 //-/////////////////////////////////////////////////////////////////////////////////////////////////
126 #include "IOEvent.cci"
127 #include "IOEvent.ct"
128 #include "IOEvent.cti"
129 #endif
130
131 \f
132 // Local Variables:
133 // mode: c++
134 // fill-column: 100
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"
140 // End: