A class which can be used in the implemention of classes derived from GNet::EventLoop. More...
#include <geventhandler.h>
Public Types | |
typedef std::map< Descriptor, EventHandler * > | Map |
typedef Map::const_iterator | Iterator |
Public Member Functions | |
EventHandlerList (const std::string &type) | |
Constructor. More... | |
void | add (Descriptor fd, EventHandler *handler) |
Adds a file-descriptor/handler pair to the list. More... | |
void | remove (Descriptor fd) |
Removes a file-descriptor from the list. More... | |
bool | contains (Descriptor fd) const |
Returns true if the list contains the given file-descriptor. More... | |
EventHandler * | find (Descriptor fd) |
Finds the handler associated with the given file descriptor. More... | |
void | lock () |
Called at the start of an iteration which might change the list. More... | |
void | unlock () |
Called at the end of an iteration. More... | |
Iterator | begin () const |
Returns a forward iterator. More... | |
Iterator | end () const |
Returns an end iterator. More... | |
Static Public Member Functions | |
static Descriptor | fd (Iterator i) |
Returns the iterator's file descriptor. More... | |
static EventHandler * | handler (Iterator i) |
Returns the iterator's handler. More... | |
A class which can be used in the implemention of classes derived from GNet::EventLoop.
Definition at line 96 of file geventhandler.h.
typedef Map::const_iterator GNet::EventHandlerList::Iterator |
Definition at line 100 of file geventhandler.h.
typedef std::map<Descriptor,EventHandler*> GNet::EventHandlerList::Map |
Definition at line 99 of file geventhandler.h.
|
explicit |
Constructor.
The type parameter (eg. "read") is used only in debugging messages.
Definition at line 52 of file geventhandler.cpp.
void GNet::EventHandlerList::add | ( | Descriptor | fd, |
EventHandler * | handler | ||
) |
Adds a file-descriptor/handler pair to the list.
Definition at line 80 of file geventhandler.cpp.
GNet::EventHandlerList::Iterator GNet::EventHandlerList::begin | ( | ) | const |
Returns a forward iterator.
Definition at line 59 of file geventhandler.cpp.
Referenced by GNet::FdSet::init(), and GNet::FdSet::raiseEvents().
bool GNet::EventHandlerList::contains | ( | Descriptor | fd | ) | const |
Returns true if the list contains the given file-descriptor.
Definition at line 69 of file geventhandler.cpp.
GNet::EventHandlerList::Iterator GNet::EventHandlerList::end | ( | ) | const |
Returns an end iterator.
Definition at line 64 of file geventhandler.cpp.
Referenced by GNet::FdSet::init(), and GNet::FdSet::raiseEvents().
|
inlinestatic |
Returns the iterator's file descriptor.
Definition at line 156 of file geventhandler.h.
Referenced by GNet::FdSet::init(), and GNet::FdSet::raiseEvents().
GNet::EventHandler * GNet::EventHandlerList::find | ( | Descriptor | fd | ) |
Finds the handler associated with the given file descriptor.
Definition at line 74 of file geventhandler.cpp.
|
inlinestatic |
Returns the iterator's handler.
Returns null if the fd has been remove()d but the list is still lock()ed.
Definition at line 162 of file geventhandler.h.
Referenced by GNet::FdSet::raiseEvents().
void GNet::EventHandlerList::lock | ( | ) |
Called at the start of an iteration which might change the list.
Definition at line 106 of file geventhandler.cpp.
Referenced by GNet::Lock::Lock().
void GNet::EventHandlerList::remove | ( | Descriptor | fd | ) |
Removes a file-descriptor from the list.
Definition at line 88 of file geventhandler.cpp.
References G_DEBUG.
void GNet::EventHandlerList::unlock | ( | ) |
Called at the end of an iteration.
Definition at line 111 of file geventhandler.cpp.
References G_ASSERT.