DispatchInterface Class Reference
[Callback and Event Handling Interfaces]

Environment-Independent Event Dispatcher Interface. More...

#include <events.h>

List of all members.

Public Types

enum  logtype_t { EVLOG_ERROR = 1, EVLOG_WARNING, EVLOG_INFO, EVLOG_DEBUG }
 Log Levels. More...

Public Member Functions

virtual SocketNotifierNewSocket (int fh, bool writable)=0
 Factory interface for SocketNotifier objects.
virtual TimerNotifierNewTimer (void)=0
 Factory interface for TimerNotifier objects.
virtual void LogVa (logtype_t lt, const char *fmt, va_list ap)=0
 Back-end Logging Function.
void LogError (const char *fmt,...) __attribute__((format(printf
 Submit an error message to the application log.


Detailed Description

Environment-Independent Event Dispatcher Interface.

Most components of libhfp are event-driven state machines, and are designed to operate under a polling event loop. The DispatchInterface describes all methods that they use to schedule event notifications. Two types of notifications are required: socket (file handle) activity and timeouts. As an abstract interface, a DispatchInterface may be implemented for every environment that libhfp is to run in, e.g. Qt, Gtk+.

To adapt libhfp to a new environment, the DispatchInterface, SocketNotifier, and TimerNotifier interfaces must be implemented. An instance of the environment-specific DispatchInterface must then be provided as part of constructing most libhfp objects.

DispatchInterface is inherently single threaded and not meant for event dispatchers that support multithreading.

See also:
BtHub::BtHub(), SoundIoPump::SoundIoPump()

Member Enumeration Documentation

enum logtype_t

Log Levels.

Log levels are used to express messages submitted by LogError(), LogWarn(), LogInfo(), and LogDebug() to LogVa(). With this, DispatchInterface implementations need only implement one virtual method to support logging.

Enumerator:
EVLOG_ERROR  Error messages, highest priority.
EVLOG_WARNING  Warning messages.
EVLOG_INFO  Informational messages.
EVLOG_DEBUG  Debug messages of limited interest to end users.


Member Function Documentation

virtual SocketNotifier* NewSocket ( int  fh,
bool  writable 
) [pure virtual]

Factory interface for SocketNotifier objects.

Creates an event dispatcher dependent SocketNotifier object that can be used to receive events on a specific socket.

Parameters:
fh File handle to be monitored for activity
writable true to notify on writability, false to notify on readability.

virtual TimerNotifier* NewTimer ( void   )  [pure virtual]

Factory interface for TimerNotifier objects.

Creates an event dispatcher dependent TimerNotifier object that can be used to trigger time-based actions.

virtual void LogVa ( logtype_t  lt,
const char *  fmt,
va_list  ap 
) [pure virtual]

Back-end Logging Function.

To support logging, a DispatchInterface derived class need only implement this method. The LogError(), LogWarn(), LogInfo(), and LogDebug() methods exist only as convenient frontends.


The documentation for this class was generated from the following file:
Generated on Fri Jan 9 05:58:40 2009 for libhfp by  doxygen 1.5.4