X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=PPI%2FIOEvent.hh;h=0d19eb33b17ae24a213b46b5448e591dc9bf26a1;hb=bd9f9d3fd6fbcff0112a7bf48ab9284da9576b11;hp=4e143b2387252d40d41090771a2fa1439cba8b6b;hpb=81ffa1c459b96dd44472bcef37e1e373934ee138;p=senf.git diff --git a/PPI/IOEvent.hh b/PPI/IOEvent.hh index 4e143b2..0d19eb3 100644 --- a/PPI/IOEvent.hh +++ b/PPI/IOEvent.hh @@ -1,8 +1,8 @@ // $Id$ // -// Copyright (C) 2007 -// Fraunhofer Institut fuer offene Kommunikationssysteme (FOKUS) -// Kompetenzzentrum fuer Satelitenkommunikation (SatCom) +// Copyright (C) 2007 +// Fraunhofer Institute for Open Communication Systems (FOKUS) +// Competence Center NETwork research (NET), St. Augustin, GERMANY // Stefan Bund // // This program is free software; you can redistribute it and/or modify @@ -23,12 +23,13 @@ /** \file \brief IOEvent public header */ -#ifndef HH_IOEvent_ -#define HH_IOEvent_ 1 +#ifndef HH_SENF_PPI_IOEvent_ +#define HH_SENF_PPI_IOEvent_ 1 // Custom includes +#include "../Scheduler/Scheduler.hh" #include "Events.hh" -#include "Scheduler/Scheduler.hh" +#include "../Utils/Exception.hh" //#include "IOEvent.mpp" ///////////////////////////////hh.p//////////////////////////////////////// @@ -36,12 +37,34 @@ namespace senf { namespace ppi { + /** \brief IOEvent event information + + Information passed to the IOEvent event handler + */ struct IOEventInfo { - unsigned events; + unsigned events; ///< Type of event signaled + /**< The value is a combination of the flags from + IOEvent::EventFlags */ }; - /** \brief + /** \brief FileHandle based I/O read/write event + + An IOEvent is signaled, whenever the FileHandle \a handle becomes readable or writable. The + type of event is specified using the \a events mask with values from EventFlags. + + There are two types of flags: + + \li Event flags (\ref Read, \ref Prio, \ref Write) specify the type of event. The + callback will be called whenever one of the specified events occurs on the filehandle + \li Error flags (\ref Hup, \ref Err) specify some type of error condition on the + filehandle. If you specify an error flag when registering the event, the error condition + will be passed to the callback, otherwise an ErrorException or HangupException will be + thrown. + + \see IOEventInfo + + \ingroup event_group */ class IOEvent : public EventImplementation @@ -50,37 +73,58 @@ namespace ppi { /////////////////////////////////////////////////////////////////////////// // Types - enum EventFlags { Read = Scheduler::EV_READ, - Write = Scheduler::EV_WRITE }; + // This is stupid, however there is no way to import the Scheduler::EventId enum together + // with the enumeration symbols + + enum EventFlags { + Read = scheduler::FdEvent::EV_READ /**< FileHandle is readable */ + , Prio = scheduler::FdEvent::EV_PRIO /**< FileHandle priority data is readable */ + , Write = scheduler::FdEvent::EV_WRITE /**< FileHandle is writable */ + , Hup = scheduler::FdEvent::EV_HUP /**< Hangup condition on FileHandle */ + , Err = scheduler::FdEvent::EV_ERR /**< Some other error condition on FileHandle */ + }; /////////////////////////////////////////////////////////////////////////// ///\name Structors and default members ///@{ + IOEvent(); + template IOEvent(Handle handle, unsigned events); ///@} /////////////////////////////////////////////////////////////////////////// + template + void set(Handle handle, unsigned events); + + /** \brief Unhandled error condition */ + struct ErrorException : public senf::Exception + { ErrorException() : senf::Exception("senf::ppi::IOEvent::ErrorException"){} }; + + /** \brief Unhandled hangup condition */ + struct HangupException : public senf::Exception + { HangupException() : senf::Exception("senf::ppi::IOEvent::HangupException"){} }; + protected: private: virtual void v_enable(); virtual void v_disable(); - void cb(int, Scheduler::EventId event); + void cb(int event); int fd_; - unsigned events_; + scheduler::FdEvent event_; }; }} ///////////////////////////////hh.e//////////////////////////////////////// -//#include "IOEvent.cci" -//#include "IOEvent.ct" +#include "IOEvent.cci" +#include "IOEvent.ct" #include "IOEvent.cti" #endif