IOEvent.hh
Go to the documentation of this file.
1 //
2 // Copyright (c) 2020 Fraunhofer Institute for Applied Information Technology (FIT)
3 // Network Research Group (NET)
4 // Schloss Birlinghoven, 53754 Sankt Augustin, GERMANY
5 // Contact: support@wiback.org
6 //
7 // This file is part of the SENF code tree.
8 // It is licensed under the 3-clause BSD License (aka New BSD License).
9 // See LICENSE.txt in the top level directory for details or visit
10 // https://opensource.org/licenses/BSD-3-Clause
11 //
12 
13 
17 #ifndef HH_SENF_PPI_IOEvent_
18 #define HH_SENF_PPI_IOEvent_ 1
19 
20 // Custom includes
22 #include <senf/Utils/Exception.hh>
23 #include <senf/Utils/String.hh>
24 #include "Events.hh"
25 
26 //#include "IOEvent.mpp"
27 //-/////////////////////////////////////////////////////////////////////////////////////////////////
28 
29 namespace senf {
30 namespace ppi {
31 
36  struct IOEventInfo
37  {
38  int events;
39 
41  };
42 
61  class IOEvent
62  : public EventImplementation<IOEventInfo>
63  {
64  public:
65  //-////////////////////////////////////////////////////////////////////////
66  // Types
67 
68  // This is stupid, however there is no way to import the Scheduler::EventId enum together
69  // with the enumeration symbols
70 
71  enum EventFlags {
77  };
78 
79  //-////////////////////////////////////////////////////////////////////////
81  //\{
82 
83  IOEvent();
84 
85  template <class Handle>
86  IOEvent(Handle handle, unsigned events);
87 
88  //\}
89  //-////////////////////////////////////////////////////////////////////////
90 
91  template <class Handle>
92  void set(Handle handle, unsigned events);
93 
96  { explicit ErrorException(int fd, int code, std::string msg)
97  : senf::SystemException("error in senf::ppi::IOEvent callback on file descriptor " + senf::str(fd) + " : " + msg + " : ", code) {} };
98 
101  { HangupException() : senf::Exception("senf::ppi::IOEvent::HangupException") {} };
102 
103  private:
104  virtual void v_enable();
105  virtual void v_disable();
106 
107  void cb(int event);
108 
109  int fd_;
110  scheduler::FdEvent event_;
111  };
112 
113 }}
114 
115 //-/////////////////////////////////////////////////////////////////////////////////////////////////
116 #include "IOEvent.cci"
117 #include "IOEvent.ct"
118 #include "IOEvent.cti"
119 #endif
120 
121 
122 // Local Variables:
123 // mode: c++
124 // fill-column: 100
125 // comment-column: 40
126 // c-file-style: "senf"
127 // indent-tabs-mode: nil
128 // ispell-local-dictionary: "american"
129 // compile-command: "scons -u test"
130 // End:
int events
Type of event signaled.
Definition: IOEvent.hh:38
Event implementation base class.
Definition: Events.hh:169
FileHandle based I/O read/write event.
Definition: IOEvent.hh:61
ErrorException(int fd, int code, std::string msg)
Definition: IOEvent.hh:96
Unhandled hangup condition.
Definition: IOEvent.hh:100
Events public header.
Unhandled error condition.
Definition: IOEvent.hh:95
IOEvent event information.
Definition: IOEvent.hh:36