39 #include "final/eventloop/monitor.h" 40 #include "final/util/fstring.h" 73 auto getClassName()
const ->
FString override;
77 void init (
int,
short, handler_t, T&&);
80 void validate (
int,
short,
const handler_t&)
const;
85 inline auto IoMonitor::getClassName()
const ->
FString 86 {
return "IoMonitor"; }
90 inline void IoMonitor::init (
int file_descriptor,
short ev
91 , handler_t hdl, T&& uc )
93 validate (file_descriptor, ev, hdl);
97 setFileDescriptor (file_descriptor);
99 setHandler (std::move(hdl));
100 setUserContext (std::forward<T>(uc));
104 setFileDescriptor (NO_FILE_DESCRIPTOR);
106 setHandler (handler_t{});
114 inline void IoMonitor::validate (
int file_descriptor,
short events
115 ,
const handler_t& hdl )
const 117 if ( isInitialized() )
118 throw monitor_error{
"This instance has already been initialised."};
120 if ( file_descriptor < 0 )
121 throw monitor_error{
"Invalid file descriptor: must be >= 0 (got " +
122 std::to_string(file_descriptor) +
")"};
124 throw monitor_error{
"Invalid events: must specify at least one event type."};
132 #endif // IO_MONITOR_H
Definition: eventloop.h:49
Definition: class_template.cpp:25
Definition: io_monitor.h:49