#include <dispatch.h>
Public Types | |
enum | Event { Timer, Read, Write, Except, Signal, All, Remove, Moved } |
typedef SigC::Slot0 < void > | Handler |
typedef unsigned long | HandlerID |
Public Member Functions | |
Dispatcher () | |
virtual | ~Dispatcher () |
virtual HandlerID | add_input_handler (const Handler &h, int fd)=0 |
virtual HandlerID | add_output_handler (const Handler &h, int fd)=0 |
virtual HandlerID | add_exception_handler (const Handler &h, int fd)=0 |
virtual HandlerID | add_timeout_handler (const Handler &h, const TimeVal &tv)=0 |
HandlerID | add_timeout_handler_msec (const Handler &h, unsigned long tmout) |
virtual HandlerID | add_signal_handler (const Handler &h, int sig)=0 |
virtual void | remove (HandlerID id)=0 |
virtual bool | run (bool infinite=true)=0 |
virtual void | exit ()=0 |
virtual void | move (Dispatcher &d)=0 |
virtual bool | idle () const =0 |
This abstract class defines a generic interface to an event dispatcher.
typedef SigC::Slot0<void> SigCX::Dispatcher::Handler |
Event handler.
typedef unsigned long SigCX::Dispatcher::HandlerID |
Event handler ID.
SigCX::Dispatcher::Dispatcher | ( | ) | [inline] |
Constructor.
virtual SigCX::Dispatcher::~Dispatcher | ( | ) | [virtual] |
Destructor.
Add input handler.
The handler h is invoked when data is ready for reading from fd.
h | The input handler. | |
fd | File descriptor. |
virtual HandlerID SigCX::Dispatcher::add_output_handler | ( | const Handler & | h, | |
int | fd | |||
) | [pure virtual] |
Add output handler.
The handler h is invoked when fd is ready for writing.
h | The input handler. | |
fd | File descriptor. |
virtual HandlerID SigCX::Dispatcher::add_exception_handler | ( | const Handler & | h, | |
int | fd | |||
) | [pure virtual] |
Add exception handler.
The handler h is invoked when an exception occurs on fd.
h | The input handler. | |
fd | File descriptor. |
virtual HandlerID SigCX::Dispatcher::add_timeout_handler | ( | const Handler & | h, | |
const TimeVal & | tv | |||
) | [pure virtual] |
Add timeout handler.
The handler h is invoked when the time specified by tv has passed.
h | The input handler. | |
tv | TimeVal timeout. |
HandlerID SigCX::Dispatcher::add_timeout_handler_msec | ( | const Handler & | h, | |
unsigned long | tmout | |||
) | [inline] |
Add timeout handler.
The handler h is invoked when the time specified by tv has passed.
h | The input handler. | |
tmout | timeout in milliseconds. |
virtual HandlerID SigCX::Dispatcher::add_signal_handler | ( | const Handler & | h, | |
int | sig | |||
) | [pure virtual] |
Add signal handler.
The handler h is invoked when the signal sig is received by the program.
virtual void SigCX::Dispatcher::remove | ( | HandlerID | id | ) | [pure virtual] |
Remove a handler.
id | The ID of the handler. |
virtual bool SigCX::Dispatcher::run | ( | bool | infinite = true |
) | [pure virtual] |
Run the dispatcher.
Run the dispatcher event loop, receiving events and calling the registered callbacks.
infinite | If false, run only one iteration, else run until exit() is called on this dispatcher instance. |
true
if exit() was called. Implemented in SigCX::StandardDispatcher, and SigCX::GtkDispatcher.
virtual void SigCX::Dispatcher::exit | ( | ) | [pure virtual] |
virtual void SigCX::Dispatcher::move | ( | Dispatcher & | d | ) | [pure virtual] |
Move all callbacks to another dispatcher.
d | The dispatcher to move the callbacks to. |
Implemented in SigCX::StandardDispatcher, and SigCX::GtkDispatcher.
virtual bool SigCX::Dispatcher::idle | ( | ) | const [pure virtual] |
Get idle status.
true
if the dispatcher is idle. Implemented in SigCX::StandardDispatcher, and SigCX::GtkDispatcher.